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 @@ ...@@ -25,6 +25,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "VLCMedia.h" #import "VLCMedia.h"
#import "VLCVideoView.h" #import "VLCVideoView.h"
#import "VLCVideoLayer.h"
#import "VLCTime.h" #import "VLCTime.h"
/* Notification Messages */ /* Notification Messages */
...@@ -70,7 +71,6 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state); ...@@ -70,7 +71,6 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
@interface VLCMediaPlayer : NSObject @interface VLCMediaPlayer : NSObject
{ {
id delegate; //< Object delegate id delegate; //< Object delegate
VLCVideoView * videoView; //< NSView instance where media is rendered to
void * instance; // Internal void * instance; // Internal
VLCMedia * media; //< Current media being played VLCMedia * media; //< Current media being played
...@@ -81,6 +81,7 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state); ...@@ -81,6 +81,7 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
/* Initializers */ /* Initializers */
- (id)initWithVideoView:(VLCVideoView *)aVideoView; - (id)initWithVideoView:(VLCVideoView *)aVideoView;
- (id)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer;
/* Properties */ /* Properties */
- (void)setDelegate:(id)value; - (void)setDelegate:(id)value;
...@@ -89,9 +90,8 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state); ...@@ -89,9 +90,8 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
/* Video View Options */ /* Video View Options */
// TODO: Should be it's own object? // TODO: Should be it's own object?
// TODO: use VLCVideoView instead of NSView - (void)setVideoView:(VLCVideoView *)aVideoView;
- (void)setVideoView:(VLCVideoView *)value; - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
- (VLCVideoView *)videoView;
- (void)setFullscreen:(BOOL)value; - (void)setFullscreen:(BOOL)value;
- (BOOL)fullscreen; - (BOOL)fullscreen;
......
...@@ -112,6 +112,9 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void * ...@@ -112,6 +112,9 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
// TODO: Documentation // TODO: Documentation
@interface VLCMediaPlayer (Private) @interface VLCMediaPlayer (Private)
- (id)initWithDrawable:(id)aDrawable;
- (void)setDrawable:(id)aDrawable;
- (void)registerObservers; - (void)registerObservers;
- (void)unregisterObservers; - (void)unregisterObservers;
- (void)mediaPlayerTimeChanged:(NSNumber *)newTime; - (void)mediaPlayerTimeChanged:(NSNumber *)newTime;
...@@ -123,34 +126,17 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void * ...@@ -123,34 +126,17 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
- (id)init - (id)init
{ {
return [self initWithVideoView:nil]; return [self initWithDrawable:nil];
} }
- (id)initWithVideoView:(VLCVideoView *)aVideoView - (id)initWithVideoView:(VLCVideoView *)aVideoView
{ {
if (self = [super init]) return [self initWithDrawable: aVideoView];
{ }
[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 - (id)initWithVideoLayer:(VLCVideoLayer *)aVideoLayer
// it will change depending on the media descriptor provided to the media {
// instance return [self initWithDrawable: aVideoLayer];
libvlc_exception_t ex;
libvlc_exception_init( &ex );
instance = (void *)libvlc_media_instance_new([VLCLibrary sharedInstance], &ex);
catch_exception( &ex );
[self registerObservers];
[self setVideoView:aVideoView];
}
return self;
} }
- (void)release - (void)release
...@@ -193,22 +179,14 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void * ...@@ -193,22 +179,14 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
return delegate; return delegate;
} }
- (void)setVideoView:(VLCVideoView *)value - (void)setVideoView:(VLCVideoView *)aVideoView
{ {
videoView = value; [self setDrawable: aVideoView];
// 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 );
} }
- (VLCVideoView *)videoView - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer
{ {
return videoView; [self setDrawable: aVideoLayer];
} }
- (void)setFullscreen:(BOOL)value - (void)setFullscreen:(BOOL)value
...@@ -554,6 +532,44 @@ static const VLCMediaPlayerState libvlc_to_local_state[] = ...@@ -554,6 +532,44 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
@end @end
@implementation VLCMediaPlayer (Private) @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 - (void)registerObservers
{ {
libvlc_exception_t ex; 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