1 /*****************************************************************************
2 * VLCMediaListPlayer.m: VLCKit.framework VLCMediaListPlayer implementation
3 *****************************************************************************
4 * Copyright (C) 2009 Pierre d'Herbemont
5 * Partial Copyright (C) 2009 Felix Paul Kühne
6 * Copyright (C) 2009 the VideoLAN team
9 * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
10 * Felix Paul Kühne <fkuehne # videolan.org
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 #import "VLCMediaListPlayer.h"
29 #import "VLCMediaPlayer.h"
30 #import "VLCMediaList.h"
31 #import "VLCLibVLCBridging.h"
33 @implementation VLCMediaListPlayer
36 if (self = [super init])
38 _mediaPlayer = [[VLCMediaPlayer alloc] init];
40 instance = libvlc_media_list_player_new([VLCLibrary sharedInstance]);
41 libvlc_media_list_player_set_media_player(instance, [_mediaPlayer libVLCMediaPlayer]);
48 libvlc_media_list_player_release(instance);
49 [_mediaPlayer release];
54 - (VLCMediaPlayer *)mediaPlayer
59 - (void)setMediaList:(VLCMediaList *)mediaList
61 if (_mediaList == mediaList)
64 _mediaList = [mediaList retain];
66 libvlc_media_list_player_set_media_list(instance, [mediaList libVLCMediaList]);
67 [self willChangeValueForKey:@"rootMedia"];
70 [self didChangeValueForKey:@"rootMedia"];
73 - (VLCMediaList *)mediaList
78 - (void)setRootMedia:(VLCMedia *)media
80 if (_rootMedia == media)
85 VLCMediaList *mediaList = [[VLCMediaList alloc] init];
87 [mediaList addMedia:media];
89 // This will clean rootMedia
90 [self setMediaList:mediaList];
92 // Thus set rootMedia here.
93 _rootMedia = [media retain];
98 - (VLCMedia *)rootMedia
103 - (void)playMedia:(VLCMedia *)media
105 libvlc_exception_t ex;
106 libvlc_exception_init(&ex);
107 libvlc_media_list_player_play_item(instance, [media libVLCMediaDescriptor]);
108 catch_exception(&ex);
113 libvlc_exception_t ex;
114 libvlc_exception_init(&ex);
115 libvlc_media_list_player_play(instance);
116 catch_exception(&ex);
121 libvlc_media_list_player_stop(instance);
124 - (void)setRepeatMode:(VLCRepeatMode)repeatMode
126 libvlc_playback_mode_t mode;
127 switch (repeatMode) {
128 case VLCRepeatAllItems:
129 mode = libvlc_playback_mode_loop;
132 mode = libvlc_playback_mode_default;
134 case VLCRepeatCurrentItem:
135 mode = libvlc_playback_mode_repeat;
138 NSAssert(0, @"Should not be reached");
141 libvlc_media_list_player_set_playback_mode(instance, mode);
143 _repeatMode = repeatMode;
146 - (VLCRepeatMode)repeatMode