Fixed the PlaybackQueue::CurrentTrackChanged signal to be called even with empty track.

This commit is contained in:
Daniel Önnerby 2008-04-29 20:54:59 +00:00
parent 94f71d27c5
commit c405f1d7f6
2 changed files with 30 additions and 25 deletions

View File

@ -112,10 +112,9 @@ void PlaybackQueue::Play(){
//////////////////////////////////////////
void PlaybackQueue::Next(){
musik::core::TrackPtr track( this->nowPlaying->NextTrack() );
if(track){
this->SetCurrentTrack(track->Copy());
this->Play();
}
this->SetCurrentTrack(track);
this->Play();
}
//////////////////////////////////////////
@ -124,10 +123,10 @@ void PlaybackQueue::Next(){
//////////////////////////////////////////
void PlaybackQueue::Previous(){
musik::core::TrackPtr track( this->nowPlaying->PreviousTrack() );
if(track){
this->SetCurrentTrack(track->Copy());
this->Play();
}
this->SetCurrentTrack(track);
this->Play();
}
//////////////////////////////////////////
@ -155,8 +154,7 @@ TrackPtr PlaybackQueue::CurrentTrack(){
if(!this->currentTrack){
// If the current track is empty, get a track from the nowPlaying tracklist
this->SetCurrentTrack( this->nowPlaying->CurrentTrack()->Copy() );
this->SetCurrentTrack( this->nowPlaying->CurrentTrack() );
}
return this->currentTrack;
}
@ -169,20 +167,24 @@ TrackPtr PlaybackQueue::CurrentTrack(){
///for all the tracks metadata
//////////////////////////////////////////
void PlaybackQueue::SetCurrentTrack(TrackPtr track){
if(this->currentTrack!=track){
this->currentTrack = track;
// Get all metadata to the track
if(this->currentTrack){
this->metadataQuery.Clear();
this->metadataQuery.RequestAllMetakeys();
this->metadataQuery.RequestTrack(this->currentTrack);
this->nowPlaying->Library()->AddQuery(this->metadataQuery,musik::core::Query::Wait|musik::core::Query::AutoCallback|musik::core::Query::UnCanceable|musik::core::Query::Prioritize);
}
if(track){
this->currentTrack = track->Copy();
}else{
this->currentTrack = musik::core::TrackPtr();
}
// Call the signal if track updates
this->CurrentTrackChanged(track);
// Get all metadata to the track
if(this->currentTrack){
this->metadataQuery.Clear();
this->metadataQuery.RequestAllMetakeys();
this->metadataQuery.RequestTrack(this->currentTrack);
this->nowPlaying->Library()->AddQuery(this->metadataQuery,musik::core::Query::Wait|musik::core::Query::AutoCallback|musik::core::Query::UnCanceable|musik::core::Query::Prioritize);
}
// Call the signal if track updates
this->CurrentTrackChanged(this->currentTrack);
}
//////////////////////////////////////////

View File

@ -115,12 +115,15 @@ void TransportController::OnTrackChange(musik::core::TrackPtr track){
win32cpp::uistring title(_T("-"));
win32cpp::uistring artist(_T("-"));
if(track->GetValue("title"))
title.assign( track->GetValue("title") );
if(track){
if(track->GetValue("visual_artist"))
artist.assign( track->GetValue("visual_artist") );
if(track->GetValue("title"))
title.assign( track->GetValue("title") );
if(track->GetValue("visual_artist"))
artist.assign( track->GetValue("visual_artist") );
}
this->transportView.titleLabel->SetCaption(title);
this->transportView.artistLabel->SetCaption(artist);