1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
26 #include "playlist.hpp"
27 #include "../utils/ustring.hpp"
29 Playlist::Playlist( intf_thread_t *pIntf ): VarList( pIntf )
31 // Get the playlist VLC object
32 m_pPlaylist = pIntf->p_sys->p_playlist;
43 void Playlist::delSelected()
45 // Remove the items from the VLC playlist
48 for( it = begin(); it != end(); it++ )
50 if( (*it).m_selected )
52 playlist_item_t *p_item = playlist_LockItemGetByPos( m_pPlaylist,
54 playlist_LockDelete( m_pPlaylist, p_item->input.i_id );
66 void Playlist::action( Elem_t *pItem )
68 // Find the index of the item
71 for( it = begin(); it != end(); it++ )
73 if( &*it == pItem ) break;
79 playlist_Goto( m_pPlaylist, index );
84 void Playlist::onChange()
91 void Playlist::buildList()
95 vlc_mutex_lock( &m_pPlaylist->object_lock );
96 for( int i = 0; i < m_pPlaylist->i_size; i++ )
98 // Get the name of the playlist item
100 new UString( getIntf(), m_pPlaylist->pp_items[i]->input.psz_name );
101 // Is it the played stream ?
102 bool playing = (i == m_pPlaylist->i_index );
103 // Add the item in the list
104 m_list.push_back( Elem_t( UStringPtr( pName ), false, playing ) );
106 vlc_mutex_unlock( &m_pPlaylist->object_lock );