Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

playlist.cpp

00001 /*****************************************************************************
00002  * playlist.cpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: playlist.cpp 11991 2005-08-03 21:00:03Z ipkiss $
00006  *
00007  * Authors: Cyril Deguet     <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 #include <vlc/vlc.h>
00025 
00026 #include "playlist.hpp"
00027 #include "../utils/ustring.hpp"
00028 
00029 Playlist::Playlist( intf_thread_t *pIntf ): VarList( pIntf )
00030 {
00031     // Get the playlist VLC object
00032     m_pPlaylist = pIntf->p_sys->p_playlist;
00033 
00034     buildList();
00035 }
00036 
00037 
00038 Playlist::~Playlist()
00039 {
00040 }
00041 
00042 
00043 void Playlist::delSelected()
00044 {
00045     // Remove the items from the VLC playlist
00046     int index = 0;
00047     ConstIterator it;
00048     for( it = begin(); it != end(); it++ )
00049     {
00050         if( (*it).m_selected )
00051         {
00052             playlist_item_t *p_item = playlist_LockItemGetByPos( m_pPlaylist,
00053                                                                  index );
00054             playlist_LockDelete( m_pPlaylist, p_item->input.i_id );
00055         }
00056         else
00057         {
00058             index++;
00059         }
00060     }
00061 
00062     notify();
00063 }
00064 
00065 
00066 void Playlist::action( Elem_t *pItem )
00067 {
00068     // Find the index of the item
00069     int index = 0;
00070     ConstIterator it;
00071     for( it = begin(); it != end(); it++ )
00072     {
00073         if( &*it == pItem ) break;
00074         index++;
00075     }
00076     // Item found ?
00077     if( index < size() )
00078     {
00079         playlist_Goto( m_pPlaylist, index );
00080     }
00081 }
00082 
00083 
00084 void Playlist::onChange()
00085 {
00086     buildList();
00087     notify();
00088 }
00089 
00090 
00091 void Playlist::buildList()
00092 {
00093     clear();
00094 
00095     vlc_mutex_lock( &m_pPlaylist->object_lock );
00096     for( int i = 0; i < m_pPlaylist->i_size; i++ )
00097     {
00098         // Get the name of the playlist item
00099         UString *pName =
00100             new UString( getIntf(), m_pPlaylist->pp_items[i]->input.psz_name );
00101         // Is it the played stream ?
00102         bool playing = (i == m_pPlaylist->i_index );
00103         // Add the item in the list
00104         m_list.push_back( Elem_t( UStringPtr( pName ), false, playing ) );
00105     }
00106     vlc_mutex_unlock( &m_pPlaylist->object_lock );
00107 }
00108 

Generated on Tue Dec 20 10:14:43 2005 for vlc-0.8.4a by  doxygen 1.4.2