Commit 53d2132c authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

macosx/framework: VLCAudio now use a media_player. Cool.

parent 812707a1
...@@ -147,10 +147,10 @@ extern void __catch_exception( void * e, const char * function, const char * fil ...@@ -147,10 +147,10 @@ extern void __catch_exception( void * e, const char * function, const char * fil
@interface VLCAudio (VLCAudioBridging) @interface VLCAudio (VLCAudioBridging)
/* Initializers */ /* Initializers */
/** /**
* Initializes a new object using the specified library instance. * Initializes a new object using the specified mediaPlayer instance.
* \return Newly created audio object using specified VLCLibrary instance. * \return Newly created audio object using specified VLCMediaPlayer instance.
*/ */
- (id)initWithLibrary:(VLCLibrary *)library; - (id)initWithMediaPlayer:(VLCMediaPlayer *)mediaPlayer;
@end @end
/** /**
......
...@@ -28,14 +28,14 @@ ...@@ -28,14 +28,14 @@
*/ */
extern NSString * VLCMediaPlayerVolumeChanged; extern NSString * VLCMediaPlayerVolumeChanged;
@class VLCLibrary; @class VLCMediaPlayer;
/** /**
* TODO: Documentation VLCAudio * TODO: Documentation VLCAudio
*/ */
@interface VLCAudio : NSObject @interface VLCAudio : NSObject
{ {
VLCLibrary * library; //< Library to control audio for void *instance;
} }
/* Properties */ /* Properties */
......
...@@ -86,6 +86,7 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state); ...@@ -86,6 +86,7 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
VLCMediaPlayerState cachedState; //< Cached state of the media being played VLCMediaPlayerState cachedState; //< Cached state of the media being played
float position; //< The position of the media being played float position; //< The position of the media being played
id drawable; //< The drawable associated to this media player id drawable; //< The drawable associated to this media player
VLCAudio *audio;
} }
/* Initializers */ /* Initializers */
......
...@@ -35,31 +35,45 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged"; ...@@ -35,31 +35,45 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged";
/* libvlc event callback */ /* libvlc event callback */
// TODO: Callbacks // TODO: Callbacks
@implementation VLCAudio @implementation VLCAudio
/**
* Use this method instead of instance directly as this one is type checked.
*/
- (libvlc_media_player_t *)instance
{
return instance;
}
- (id)init - (id)init
{ {
return nil; return nil;
} }
- (id)initWithLibrary:(VLCLibrary *)aLibrary - (id)initWithMediaPlayer:(VLCMediaPlayer *)mediaPlayer
{ {
if (![library audio] && (self = [super init])) self = [super init];
{ if (!self)
library = aLibrary; return nil;
[library setAudio:self]; instance = [mediaPlayer libVLCMediaPlayer];
} libvlc_media_player_retain([self instance]);
return self; return self;
} }
- (void) dealloc
{
libvlc_media_player_release([self instance]);
[super dealloc];
}
- (void)setMute:(BOOL)value - (void)setMute:(BOOL)value
{ {
libvlc_audio_set_mute([library instance], value); libvlc_audio_set_mute([self instance], value);
} }
- (BOOL)isMuted - (BOOL)isMuted
{ {
return libvlc_audio_get_mute([library instance]); return libvlc_audio_get_mute([self instance]);
} }
- (void)setVolume:(NSUInteger)value - (void)setVolume:(NSUInteger)value
...@@ -68,7 +82,7 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged"; ...@@ -68,7 +82,7 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged";
value = VOLUME_MIN; value = VOLUME_MIN;
else if (value > VOLUME_MAX) else if (value > VOLUME_MAX)
value = VOLUME_MAX; value = VOLUME_MAX;
libvlc_audio_set_volume([library instance], value); libvlc_audio_set_volume([self instance], value);
} }
- (void)volumeUp - (void)volumeUp
...@@ -93,6 +107,6 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged"; ...@@ -93,6 +107,6 @@ NSString * VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged";
- (NSUInteger)volume - (NSUInteger)volume
{ {
return libvlc_audio_get_volume([library instance]); return libvlc_audio_get_volume([self instance]);
} }
@end @end
...@@ -225,6 +225,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s ...@@ -225,6 +225,7 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
[cachedTime release]; [cachedTime release];
[cachedRemainingTime release]; [cachedRemainingTime release];
[drawable release]; [drawable release];
[audio release];
[super dealloc]; [super dealloc];
} }
...@@ -262,7 +263,9 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s ...@@ -262,7 +263,9 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
- (VLCAudio *)audio - (VLCAudio *)audio
{ {
return [[VLCLibrary sharedLibrary] audio]; if (!audio)
audio = [[VLCAudio alloc] initWithMediaPlayer:self];
return audio;
} }
#pragma mark - #pragma mark -
......
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