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