]> git.sesse.net Git - vlc/commitdiff
skins2: add support for tracking current playing item correctly
authorErwan Tulou <erwan10@videolan.org>
Sat, 13 Feb 2010 10:43:50 +0000 (11:43 +0100)
committerErwan Tulou <erwan10@videolan.org>
Sat, 13 Feb 2010 15:29:16 +0000 (16:29 +0100)
modules/gui/skins2/vars/playtree.cpp
modules/gui/skins2/vars/playtree.hpp

index 28a8735d2c370acc2d4d818264eec0104fe5f33b..4e9680833ff5a0dea0c937b91625d1bb857abc77 100644 (file)
@@ -36,6 +36,7 @@ Playtree::Playtree( intf_thread_t *pIntf ): VarTree( pIntf )
 {
     // Get the VLC playlist object
     m_pPlaylist = pIntf->p_sys->p_playlist;
+    m_playingIt = end();
 
     i_items_to_append = 0;
 
@@ -133,10 +134,6 @@ void Playtree::onUpdateItem( int id )
         playlist_item_t* pNode = (playlist_item_t*)(it->m_pData);
         UString *pName = new UString( getIntf(), pNode->p_input->psz_name );
         it->m_cString = UStringPtr( pName );
-        playlist_Lock( m_pPlaylist );
-        it->m_playing = playlist_CurrentPlayingItem( m_pPlaylist ) == pNode;
-        playlist_Unlock( m_pPlaylist );
-        if( it->m_playing ) descr.b_active_item = true;
     }
     else
     {
@@ -146,6 +143,33 @@ void Playtree::onUpdateItem( int id )
     notify( &descr );
 }
 
+
+void Playtree::onUpdateCurrent()
+{
+    playlist_Lock( m_pPlaylist );
+
+    playlist_item_t* current = playlist_CurrentPlayingItem( m_pPlaylist );
+    if( !current )
+    {
+        playlist_Unlock( m_pPlaylist );
+        return;
+    }
+
+    Iterator it = findById( current->i_id );
+    it->m_playing = true;
+    if( m_playingIt != end() )
+        m_playingIt->m_playing = false;
+    m_playingIt = it;
+
+    playlist_Unlock( m_pPlaylist );
+
+    tree_update descr;
+    descr.b_active_item = true;
+    descr.i_type = 0;
+    notify( &descr );
+}
+
+
 /// \todo keep a list of "recently removed" to avoid looking up if we
 //  already removed it
 void Playtree::onDelete( int i_id )
index 07eadd30fc095c330ce6bf5810c1ab45c54db8e4..0c1a2ad742e0d929875a0203e1c4210974e7e6b6 100644 (file)
@@ -46,6 +46,9 @@ public:
     /// Function called to notify playlist item update
     void onUpdateItem( int id );
 
+    /// Function called to notify about current playing item
+    void onUpdateCurrent( );
+
     /// Function called to notify playlist item append
     void onAppend( playlist_add_t * );
 
@@ -64,6 +67,9 @@ private:
 
     /// Update Node's children
     void buildNode( playlist_item_t *p_node, VarTree &m_pNode );
+
+    /// keep track of item being played
+    Iterator m_playingIt;
 };
 
 #endif