Commit 5a07a426 authored by Erwan Tulou's avatar Erwan Tulou

skins2: add support for tracking current playing item correctly

parent 376635fa
......@@ -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 )
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment