Browse Source

MacOSX/Framework: Publish @property id drawable. Make sure the KVO will be sent for isPlaying.

Pierre d'Herbemont 17 years ago
parent
commit
4e1a0224f3
2 changed files with 30 additions and 12 deletions
  1. 2 0
      Headers/Public/VLCMediaPlayer.h
  2. 28 12
      Sources/VLCMediaPlayer.m

+ 2 - 0
Headers/Public/VLCMediaPlayer.h

@@ -93,6 +93,8 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
 - (void)setVideoView:(VLCVideoView *)aVideoView;
 - (void)setVideoLayer:(VLCVideoLayer *)aVideoLayer;
 
+@property (retain) id drawable; /* The videoView or videoLayer */
+
 - (void)setVideoAspectRatio:(char *)value;
 - (char *)videoAspectRatio;
 - (void)setVideoSubTitles:(int)value;

+ 28 - 12
Sources/VLCMediaPlayer.m

@@ -114,7 +114,6 @@ 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;
@@ -214,6 +213,27 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
     [self setDrawable: aVideoLayer];
 }
 
+- (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 );
+}
+
+- (id)drawable
+{
+    libvlc_exception_t ex;
+    libvlc_exception_init( &ex );
+    libvlc_drawable_t ret = libvlc_media_instance_get_drawable ((libvlc_media_instance_t *)instance, 
+                                        &ex);
+    catch_exception( &ex );
+    return (id)ret;
+}
+
 - (void)setVideoAspectRatio:(char *)value
 {
     libvlc_video_set_aspect_ratio( instance, value, NULL );
@@ -508,6 +528,11 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
     [self setRate: -rate];
 }
 
++ (NSSet *)keyPathsForValuesAffectingIsPlaying
+{
+    return [NSSet setWithObjects:@"state", nil];
+}
+
 - (BOOL)isPlaying
 {
     VLCMediaPlayerState state = [self state];
@@ -575,6 +600,8 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
     catch_exception( &ex );
     return ret;
 }
+
+
 @end
 
 @implementation VLCMediaPlayer (Private)
@@ -603,17 +630,6 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
     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;