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 VLC authors and VideoLAN
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 it
13 * under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this program; if not, write to the Free Software Foundation,
24 * 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_media_list_player_play_item(instance, [media libVLCMediaDescriptor]);
110 libvlc_media_list_player_play(instance);
115 libvlc_media_list_player_stop(instance);
118 - (void)setRepeatMode:(VLCRepeatMode)repeatMode
120 libvlc_playback_mode_t mode;
121 switch (repeatMode) {
122 case VLCRepeatAllItems:
123 mode = libvlc_playback_mode_loop;
126 mode = libvlc_playback_mode_default;
128 case VLCRepeatCurrentItem:
129 mode = libvlc_playback_mode_repeat;
132 NSAssert(0, @"Should not be reached");
135 libvlc_media_list_player_set_playback_mode(instance, mode);
137 _repeatMode = repeatMode;
140 - (VLCRepeatMode)repeatMode