Commit 549b9331 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

macosx/framework: Handle media changed events.

parent 5871680a
......@@ -124,6 +124,18 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
}
static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * self)
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaPlayerMediaChanged:)
withArgumentAsObject:[VLCMedia mediaWithLibVLCMediaDescriptor:event->u.media_player_media_changed.new_media]];
[pool release];
}
// TODO: Documentation
@interface VLCMediaPlayer (Private)
......@@ -134,6 +146,7 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
- (void)mediaPlayerTimeChanged:(NSNumber *)newTime;
- (void)mediaPlayerPositionChanged:(NSNumber *)newTime;
- (void)mediaPlayerStateChanged:(NSNumber *)newState;
- (void)mediaPlayerMediaChanged:(VLCMedia *)media;
@end
@implementation VLCMediaPlayer
......@@ -894,6 +907,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
/* FIXME: We may want to turn that off when none is interested by that */
libvlc_event_attach( p_em, libvlc_MediaPlayerPositionChanged, HandleMediaPositionChanged, self, &ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerTimeChanged, HandleMediaTimeChanged, self, &ex );
libvlc_event_attach( p_em, libvlc_MediaPlayerMediaChanged, HandleMediaPlayerMediaChanged, self, &ex );
catch_exception( &ex );
}
......@@ -906,6 +920,7 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
libvlc_event_detach( p_em, libvlc_MediaPlayerEndReached, HandleMediaInstanceStateChanged, self, NULL );
libvlc_event_detach( p_em, libvlc_MediaPlayerPositionChanged, HandleMediaPositionChanged, self, NULL );
libvlc_event_detach( p_em, libvlc_MediaPlayerTimeChanged, HandleMediaTimeChanged, self, NULL );
libvlc_event_attach( p_em, libvlc_MediaPlayerMediaChanged, HandleMediaPlayerMediaChanged, self, NULL );
}
- (void)mediaPlayerTimeChanged:(NSNumber *)newTime
......@@ -941,4 +956,15 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
[self didChangeValueForKey:@"state"];
}
- (void)mediaPlayerMediaChanged:(VLCMedia *)newMedia
{
[self willChangeValueForKey:@"media"];
if (media != newMedia)
{
[media release];
media = [newMedia retain];
}
[self didChangeValueForKey:@"media"];
}
@end
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