static VLCLibrary * sharedLibrary = nil;
-void __catch_exception( void * e, const char * function, const char * file, int line_number )
-{
- libvlc_exception_t * ex = (libvlc_exception_t *)e;
- if( libvlc_exception_raised( ex ) )
- {
- NSException* libvlcException = [NSException
- exceptionWithName:@"LibVLCException"
- reason:[NSString stringWithFormat:@"libvlc has thrown us an error: %s (%s:%d %s)",
- libvlc_errmsg(), file, line_number, function]
- userInfo:nil];
- libvlc_exception_clear( ex );
- @throw libvlcException;
- }
-}
-
@implementation VLCLibrary
+ (VLCLibrary *)sharedLibrary
{
{
if (self = [super init])
{
- libvlc_exception_t ex;
- libvlc_exception_init( &ex );
NSArray *vlcParams = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"VLCParams"];
if (!vlcParams) {
{
mlib = libvlc_media_library_new( [VLCLibrary sharedInstance]);
- libvlc_exception_t p_e;
- libvlc_exception_init( &p_e );
- libvlc_media_library_load( mlib, &p_e );
- catch_exception( &p_e );
+ libvlc_media_library_load( mlib );
allMedia = nil;
}
{
if( !allMedia )
{
- libvlc_media_list_t * p_mlist = libvlc_media_library_media_list( mlib, NULL );
+ libvlc_media_list_t * p_mlist = libvlc_media_library_media_list( mlib );
allMedia = [[VLCMediaList mediaListWithLibVLCMediaList:p_mlist] retain];
libvlc_media_list_release(p_mlist);
}
- (void)playMedia:(VLCMedia *)media
{
- libvlc_exception_t ex;
- libvlc_exception_init(&ex);
libvlc_media_list_player_play_item(instance, [media libVLCMediaDescriptor]);
- catch_exception(&ex);
}
- (void)play
{
- libvlc_exception_t ex;
- libvlc_exception_init(&ex);
libvlc_media_list_player_play(instance);
- catch_exception(&ex);
}
- (void)stop
// Create a media instance, it doesn't matter what library we start off with
// it will change depending on the media descriptor provided to the media
// instance
- libvlc_exception_t ex;
- libvlc_exception_init( &ex );
instance = libvlc_media_player_new([VLCLibrary sharedInstance]);
- catch_exception( &ex );
[self registerObservers];