Commit 5870b4cf authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/Framework/VLCMediaPlayer: Expose -setVideoLayer: and -initWithVideoLayer:.

parent 66304ec7
......@@ -25,6 +25,7 @@
#import <Cocoa/Cocoa.h>
#import "VLCMedia.h"
#import "VLCVideoView.h"
#import "VLCVideoLayer.h"
#import "VLCTime.h"
/* Notification Messages */
......@@ -70,7 +71,6 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
@interface VLCMediaPlayer : NSObject
{
id delegate; //< Object delegate
VLCVideoView * videoView; //< NSView instance where media is rendered to
void * instance; // Internal
VLCMedia * media; //< Current media being played
......@@ -81,6 +81,7 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
/* Initializers */
- (id)initWithVideoView:(VLCVideoView *)aVideoView;
- (id)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer;
/* Properties */
- (void)setDelegate:(id)value;
......@@ -89,9 +90,8 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
/* Video View Options */
// TODO: Should be it's own object?
// TODO: use VLCVideoView instead of NSView
- (void)setVideoView:(VLCVideoView *)value;
- (VLCVideoView *)videoView;
- (void)setVideoView:(VLCVideoView *)aVideoView;
- (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
- (void)setFullscreen:(BOOL)value;
- (BOOL)fullscreen;
......
......@@ -112,6 +112,9 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
// TODO: Documentation
@interface VLCMediaPlayer (Private)
- (id)initWithDrawable:(id)aDrawable;
- (void)setDrawable:(id)aDrawable;
- (void)registerObservers;
- (void)unregisterObservers;
- (void)mediaPlayerTimeChanged:(NSNumber *)newTime;
......@@ -123,34 +126,17 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
- (id)init
{
return [self initWithVideoView:nil];
return [self initWithDrawable:nil];
}
- (id)initWithVideoView:(VLCVideoView *)aVideoView
{
if (self = [super init])
{
[VLCMediaPlayer setKeys:[NSArray arrayWithObject:@"state"] triggerChangeNotificationsForDependentKey:@"playing"];
[VLCMediaPlayer setKeys:[NSArray arrayWithObjects:@"state", @"media", nil] triggerChangeNotificationsForDependentKey:@"seekable"];
delegate = nil;
media = nil;
cachedTime = [[VLCTime nullTime] retain];
position = 0.0f;
cachedState = VLCMediaPlayerStateStopped;
// Create a media instance, it doesn't matter what library we start off with
// it will change depending on the media descriptor provided to the media
// instance
libvlc_exception_t ex;
libvlc_exception_init( &ex );
instance = (void *)libvlc_media_instance_new([VLCLibrary sharedInstance], &ex);
catch_exception( &ex );
[self registerObservers];
return [self initWithDrawable: aVideoView];
}
[self setVideoView:aVideoView];
}
return self;
- (id)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer
{
return [self initWithDrawable: aVideoLayer];
}
- (void)release
......@@ -193,22 +179,14 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
return delegate;
}
- (void)setVideoView:(VLCVideoView *)value
- (void)setVideoView:(VLCVideoView *)aVideoView
{
videoView = value;
// Make sure that this instance has been associated with the drawing canvas.
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_media_instance_set_drawable ((libvlc_media_instance_t *)instance,
(libvlc_drawable_t)videoView,
&ex);
catch_exception( &ex );
[self setDrawable: aVideoView];
}
- (VLCVideoView *)videoView
- (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer
{
return videoView;
[self setDrawable: aVideoLayer];
}
- (void)setFullscreen:(BOOL)value
......@@ -554,6 +532,44 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
@end
@implementation VLCMediaPlayer (Private)
- (id)initWithDrawable:(id)aDrawable
{
if (self = [super init])
{
[VLCMediaPlayer setKeys:[NSArray arrayWithObject:@"state"] triggerChangeNotificationsForDependentKey:@"playing"];
[VLCMediaPlayer setKeys:[NSArray arrayWithObjects:@"state", @"media", nil] triggerChangeNotificationsForDependentKey:@"seekable"];
delegate = nil;
media = nil;
cachedTime = [[VLCTime nullTime] retain];
position = 0.0f;
cachedState = VLCMediaPlayerStateStopped;
// Create a media instance, it doesn't matter what library we start off with
// it will change depending on the media descriptor provided to the media
// instance
libvlc_exception_t ex;
libvlc_exception_init( &ex );
instance = (void *)libvlc_media_instance_new([VLCLibrary sharedInstance], &ex);
catch_exception( &ex );
[self registerObservers];
[self setDrawable:aDrawable];
}
return self;
}
- (void)setDrawable:(id)aDrawable
{
// Make sure that this instance has been associated with the drawing canvas.
libvlc_exception_t ex;
libvlc_exception_init( &ex );
libvlc_media_instance_set_drawable ((libvlc_media_instance_t *)instance,
(libvlc_drawable_t)aDrawable,
&ex);
catch_exception( &ex );
}
- (void)registerObservers
{
libvlc_exception_t ex;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment