Tuniac1/TuniacApp/TuniacApp.cpp
//bAuto		0 = user interaction caused song change
//			1 = auto selected song from Tuniac logic(eg track ended and next track plays)

bAuto           0 = user interaction caused song change
1 = auto selected song from Tuniac logic
bAuto 0 = user interaction caused song change 1 = auto selected song from Tuniac logic
bool	CTuniacApp::PlayEntry(IPlaylistEntry * pIPE, bool bStart, bool bAuto, bool bResetAudio, bool bRebuild)
{
	if(pIPE)
	{
		if(m_Preferences.GetShowAlbumArt())
			GetArt((LPTSTR)pIPE->GetField(FIELD_URL));
		IPlaylist * pPlaylist = m_PlaylistManager.GetActivePlaylist();
		if (pPlaylist)
		{
			if (!pPlaylist->SetActiveNormalFilteredIndex(pPlaylist->GetNormalFilteredIndexforEntry(pIPE)))
			{
				IPlaylistEX * pPlaylistEX = (IPlaylistEX *)pPlaylist;
				if (pPlaylistEX)
					pPlaylistEX->SetActiveRealIndex(pPlaylistEX->GetRealIndexforEntry(pIPE));
			}
			if (CCoreAudio::Instance()->SetSource((LPTSTR)pIPE->GetField(FIELD_URL), (float *)pIPE->GetField(FIELD_REPLAYGAIN_ALBUM_GAIN), (float *)pIPE->GetField(FIELD_REPLAYGAIN_TRACK_GAIN), bResetAudio))
			{
				if (bStart)
					CCoreAudio::Instance()->Play();
				if (!bAuto)
				{
					m_SoftPause.bNow = false;
					m_SoftPause.ulPlaylistID = INVALID_PLAYLIST_INDEX;
					m_SoftPause.ulEntryID = INVALID_PLAYLIST_INDEX;
					tuniacApp.SetStatusPlayMode();
				}
				else if (m_SoftPause.bNow || (pPlaylist->GetPlaylistID() == m_SoftPause.ulPlaylistID && m_SoftPause.ulEntryID == pIPE->GetEntryID()))
				{
					m_SoftPause.bNow = false;
					m_SoftPause.ulPlaylistID = INVALID_PLAYLIST_INDEX;
					m_SoftPause.ulEntryID = INVALID_PLAYLIST_INDEX;
					SendMessage(m_hWnd, WM_MENUSELECT, 0, 0);
					CCoreAudio::Instance()->StopLast();
					tuniacApp.SetStatusPlayMode();
				}
				UpdateState();
				if (m_SourceSelectorWindow)
				{
					m_SourceSelectorWindow->UpdateView();
					if (m_SourceSelectorWindow->GetVisiblePlaylistIndex() == m_PlaylistManager.GetActivePlaylistIndex() && m_Preferences.GetFollowCurrentSongMode())
						m_SourceSelectorWindow->ShowCurrentlyPlaying();
				}
				if (pPlaylist->GetFlags() & PLAYLIST_FLAGS_EXTENDED)
				{
					m_History.AddHistoryItem(pPlaylist->GetPlaylistID(), pIPE->GetEntryID());
					unsigned long ulIndex = pPlaylist->GetActiveNormalFilteredIndex();
					if (m_PlaySelected.GetCount())
					{
						if (ulIndex == m_PlaySelected[0])
						{
							m_PlaySelected.RemoveAt(0);
							m_SourceSelectorWindow->m_PlaylistSourceView->DeselectItem(ulIndex);
						}
					}
					for (unsigned long i = 0; i < m_Queue.GetCount(); i++)
					{
						unsigned long ulEntryID = m_Queue.GetEntryIDAtIndex(i);
						unsigned long ulFilteredIndex = ((IPlaylistEX *)pPlaylist)->GetNormalFilteredIndexforEntryID(ulEntryID);
						if (ulFilteredIndex == ulIndex)
						{
							for (unsigned long x = 0; x <= i; x++)
							{
								m_Queue.Remove(0);
								if (m_Preferences.GetRepeatMode() == RepeatAllQueued)
									m_Queue.Append(pPlaylist->GetPlaylistID(), ulEntryID);
							}
							break;
						}
					}
				}
				if (bRebuild)
					RebuildFutureMenu();
				if (GetForegroundWindow() == m_hWnd && !IsIconic(m_hWnd))
				{
					if (bAuto)
						m_PluginManager.PostMessage(PLUGINNOTIFY_SONGCHANGE, NULL, NULL);
					else
						m_PluginManager.PostMessage(PLUGINNOTIFY_SONGCHANGE_MANUAL, NULL, NULL);
				}
				else
				{
					if (bAuto)
						m_PluginManager.PostMessage(PLUGINNOTIFY_SONGCHANGE_BLIND, NULL, NULL);
					else
						m_PluginManager.PostMessage(PLUGINNOTIFY_SONGCHANGE_MANUALBLIND, NULL, NULL);
				}
				return true;
			}
		}
	}
	return false;
}
bool CTuniacApp :: PlayEntry ( IPlaylistEntry * pIPE , bool bStart , bool bAuto , bool bResetAudio , bool bRebuild ) { if ( pIPE ) { if ( m_Preferences . GetShowAlbumArt ( ) ) GetArt ( ( LPTSTR ) pIPE -> GetField ( FIELD_URL ) ) ; IPlaylist * pPlaylist = m_PlaylistManager . GetActivePlaylist ( ) ; if ( pPlaylist ) { if ( ! pPlaylist -> SetActiveNormalFilteredIndex ( pPlaylist -> GetNormalFilteredIndexforEntry ( pIPE ) ) ) { IPlaylistEX * pPlaylistEX = ( IPlaylistEX * ) pPlaylist ; if ( pPlaylistEX ) pPlaylistEX -> SetActiveRealIndex ( pPlaylistEX -> GetRealIndexforEntry ( pIPE ) ) ; } if ( CCoreAudio :: Instance ( ) -> SetSource ( ( LPTSTR ) pIPE -> GetField ( FIELD_URL ) , ( float * ) pIPE -> GetField ( FIELD_REPLAYGAIN_ALBUM_GAIN ) , ( float * ) pIPE -> GetField ( FIELD_REPLAYGAIN_TRACK_GAIN ) , bResetAudio ) ) { if ( bStart ) CCoreAudio :: Instance ( ) -> Play ( ) ; if ( ! bAuto ) { m_SoftPause . bNow = false ; m_SoftPause . ulPlaylistID = INVALID_PLAYLIST_INDEX ; m_SoftPause . ulEntryID = INVALID_PLAYLIST_INDEX ; tuniacApp . SetStatusPlayMode ( ) ; } else if ( m_SoftPause . bNow || ( pPlaylist -> GetPlaylistID ( ) == m_SoftPause . ulPlaylistID && m_SoftPause . ulEntryID == pIPE -> GetEntryID ( ) ) ) { m_SoftPause . bNow = false ; m_SoftPause . ulPlaylistID = INVALID_PLAYLIST_INDEX ; m_SoftPause . ulEntryID = INVALID_PLAYLIST_INDEX ; SendMessage ( m_hWnd , WM_MENUSELECT , 0 , 0 ) ; CCoreAudio :: Instance ( ) -> StopLast ( ) ; tuniacApp . SetStatusPlayMode ( ) ; } UpdateState ( ) ; if ( m_SourceSelectorWindow ) { m_SourceSelectorWindow -> UpdateView ( ) ; if ( m_SourceSelectorWindow -> GetVisiblePlaylistIndex ( ) == m_PlaylistManager . GetActivePlaylistIndex ( ) && m_Preferences . GetFollowCurrentSongMode ( ) ) m_SourceSelectorWindow -> ShowCurrentlyPlaying ( ) ; } if ( pPlaylist -> GetFlags ( ) & PLAYLIST_FLAGS_EXTENDED ) { m_History . AddHistoryItem ( pPlaylist -> GetPlaylistID ( ) , pIPE -> GetEntryID ( ) ) ; unsigned long ulIndex = pPlaylist -> GetActiveNormalFilteredIndex ( ) ; if ( m_PlaySelected . GetCount ( ) ) { if ( ulIndex == m_PlaySelected [ 0 ] ) { m_PlaySelected . RemoveAt ( 0 ) ; m_SourceSelectorWindow -> m_PlaylistSourceView -> DeselectItem ( ulIndex ) ; } } for ( unsigned long i = 0 ; i < m_Queue . GetCount ( ) ; i ++ ) { unsigned long ulEntryID = m_Queue . GetEntryIDAtIndex ( i ) ; unsigned long ulFilteredIndex = ( ( IPlaylistEX * ) pPlaylist ) -> GetNormalFilteredIndexforEntryID ( ulEntryID ) ; if ( ulFilteredIndex == ulIndex ) { for ( unsigned long x = 0 ; x <= i ; x ++ ) { m_Queue . Remove ( 0 ) ; if ( m_Preferences . GetRepeatMode ( ) == RepeatAllQueued ) m_Queue . Append ( pPlaylist -> GetPlaylistID ( ) , ulEntryID ) ; } break ; } } } if ( bRebuild ) RebuildFutureMenu ( ) ; if ( GetForegroundWindow ( ) == m_hWnd && ! IsIconic ( m_hWnd ) ) { if ( bAuto ) m_PluginManager . PostMessage ( PLUGINNOTIFY_SONGCHANGE , NULL , NULL ) ; else m_PluginManager . PostMessage ( PLUGINNOTIFY_SONGCHANGE_MANUAL , NULL , NULL ) ; } else { if ( bAuto ) m_PluginManager . PostMessage ( PLUGINNOTIFY_SONGCHANGE_BLIND , NULL , NULL ) ; else m_PluginManager . PostMessage ( PLUGINNOTIFY_SONGCHANGE_MANUALBLIND , NULL , NULL ) ; } return true ; } } } return false ; }
bAuto           0 = user interaction caused song change
1 = auto selected song from Tuniac logic(eg track ended and next track plays)
bAuto 0 = user interaction caused song change 1 = auto selected song from Tuniac logic ( eg track ended and next track plays )
//open for art before opening for decode.
 //history can pick songs that are filtered out
 //reset softpause on manual song changes
 //reset feature/GUI menu for  feature
 //this will only stop the last stream, not all of them
 //focus current song if we are following playback
 //update queues
 //add history
 //remove playselected
 //remove playqueue, find first oocurance and remove all before it if needed
 //else if(::IsWindowVisible(m_hWnd) && !IsIconic(m_hWnd))
