Commit 096ebc37 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/Framework: Implement -canPause and the various setRate related functions.

parent 79179c9e
...@@ -104,8 +104,7 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state); ...@@ -104,8 +104,7 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
- (void)setVideoTeleText:(int)value; - (void)setVideoTeleText:(int)value;
- (int)videoTeleText; - (int)videoTeleText;
- (void)setRate:(int)value; @property float rate;
- (int)rate;
/* Video Information */ /* Video Information */
- (NSSize)videoSize; - (NSSize)videoSize;
...@@ -157,24 +156,24 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state); ...@@ -157,24 +156,24 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
/** /**
* Fast forwards through the feed at the standard 1x rate. * Fast forwards through the feed at the standard 1x rate.
*/ */
//- (void)fastForward; - (void)fastForward;
/** /**
* Fast forwards through the feed at the rate specified. * Fast forwards through the feed at the rate specified.
* \param rate Rate at which the feed should be fast forwarded. * \param rate Rate at which the feed should be fast forwarded.
*/ */
//- (void)fastForwardAtRate:(int)rate; - (void)fastForwardAtRate:(float)rate;
/** /**
* Rewinds through the feed at the standard 1x rate. * Rewinds through the feed at the standard 1x rate.
*/ */
//- (void)rewind; - (void)rewind;
/** /**
* Rewinds through the feed at the rate specified. * Rewinds through the feed at the rate specified.
* \param rate Rate at which the feed should be fast rewound. * \param rate Rate at which the feed should be fast rewound.
*/ */
//- (void)rewindAtRate:(int)rate; - (void)rewindAtRate:(float)rate;
/* Playback Information */ /* Playback Information */
/** /**
...@@ -204,4 +203,6 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state); ...@@ -204,4 +203,6 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
- (BOOL)isSeekable; - (BOOL)isSeekable;
- (BOOL)canPause;
@end @end
...@@ -59,6 +59,7 @@ static void HandleMediaInstanceVolumeChanged(const libvlc_event_t * event, void ...@@ -59,6 +59,7 @@ static void HandleMediaInstanceVolumeChanged(const libvlc_event_t * event, void
static void HandleMediaTimeChanged(const libvlc_event_t * event, void * self) static void HandleMediaTimeChanged(const libvlc_event_t * event, void * self)
{ {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[[VLCEventManager sharedManager] callOnMainThreadObject:self [[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaPlayerTimeChanged:) withMethod:@selector(mediaPlayerTimeChanged:)
withArgumentAsObject:[NSNumber numberWithLongLong:event->u.media_instance_time_changed.new_time]]; withArgumentAsObject:[NSNumber numberWithLongLong:event->u.media_instance_time_changed.new_time]];
...@@ -82,7 +83,7 @@ static void HandleMediaPositionChanged(const libvlc_event_t * event, void * self ...@@ -82,7 +83,7 @@ static void HandleMediaPositionChanged(const libvlc_event_t * event, void * self
static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void * self) static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void * self)
{ {
VLCMediaPlayerState newState; VLCMediaPlayerState newState;
if( event->type == libvlc_MediaInstancePlayed ) if( event->type == libvlc_MediaInstancePlayed )
newState = VLCMediaPlayerStatePlaying; newState = VLCMediaPlayerStatePlaying;
else if( event->type == libvlc_MediaInstancePaused ) else if( event->type == libvlc_MediaInstancePaused )
...@@ -128,14 +129,22 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void * ...@@ -128,14 +129,22 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key
{ {
static NSDictionary * dict = nil; static NSDictionary * dict = nil;
NSSet * superKeyPaths;
if( !dict ) if( !dict )
{ {
dict = [[NSDictionary dictionaryWithObjectsAndKeys: dict = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSSet setWithObject:@"state"], @"playing", [NSSet setWithObject:@"state"], @"playing",
[NSSet setWithObjects:@"state", @"media", nil], @"seekable", [NSSet setWithObjects:@"state", @"media", nil], @"seekable",
[NSSet setWithObjects:@"state", @"media", nil], @"canPause",
[NSSet setWithObjects:@"state", @"media", nil], @"description", [NSSet setWithObjects:@"state", @"media", nil], @"description",
nil] retain]; nil] retain];
} }
if( (superKeyPaths = [super keyPathsForValuesAffectingValueForKey: key]) )
{
NSMutableSet * ret = [NSMutableSet setWithSet:[dict objectForKey: key]];
[ret unionSet:superKeyPaths];
return ret;
}
return [dict objectForKey: key]; return [dict objectForKey: key];
} }
...@@ -261,12 +270,12 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void * ...@@ -261,12 +270,12 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
return result; return result;
} }
- (void)setRate:(int)value - (void)setRate:(float)value
{ {
libvlc_media_instance_set_rate( instance, value, NULL ); libvlc_media_instance_set_rate( instance, value, NULL );
} }
- (int)rate - (float)rate
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init( &ex ); libvlc_exception_init( &ex );
...@@ -467,10 +476,25 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void * ...@@ -467,10 +476,25 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
// TODO: Should we pause this or destroy the media instance so that it appears as being "stopped"? // TODO: Should we pause this or destroy the media instance so that it appears as being "stopped"?
} }
//- (void)fastForward; - (void)fastForward
//- (void)fastForwardAtRate:(int)rate; {
//- (void)rewind; [self fastForwardAtRate: 2.0];
//- (void)rewindAtRate:(int)rate; }
- (void)fastForwardAtRate:(float)rate
{
[self setRate:rate];
}
- (void)rewind
{
[self rewindAtRate: 2.0];
}
- (void)rewindAtRate:(float)rate
{
[self setRate: -rate];
}
- (BOOL)isPlaying - (BOOL)isPlaying
{ {
...@@ -531,6 +555,14 @@ static const VLCMediaPlayerState libvlc_to_local_state[] = ...@@ -531,6 +555,14 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
return ret; return ret;
} }
- (BOOL)canPause
{
libvlc_exception_t ex;
libvlc_exception_init( &ex );
BOOL ret = libvlc_media_instance_can_pause( instance, &ex );
catch_exception( &ex );
return ret;
}
@end @end
@implementation VLCMediaPlayer (Private) @implementation VLCMediaPlayer (Private)
......
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