Skip to content

Commit

Permalink
added: #10374 - "Play from here" context menu button for tv episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Montellese committed Jan 26, 2011
1 parent f9645fa commit 8f9809d
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 38 deletions.
2 changes: 1 addition & 1 deletion language/English/strings.xml
Expand Up @@ -1198,7 +1198,7 @@
<string id="13409">Top 250</string>
<string id="13410">Tune in on Last.fm</string>
<string id="13411">Minimum fan speed</string>

<string id="13412">Play from here</string>
<string id="13413">Downloading</string>
<string id="13414">Include artists who appear only on compilations</string>
<string id="13415">Render method</string>
Expand Down
1 change: 1 addition & 0 deletions xbmc/dialogs/GUIDialogContextMenu.h
Expand Up @@ -101,6 +101,7 @@ enum CONTEXT_BUTTON { CONTEXT_BUTTON_CANCELLED = 0,
CONTEXT_BUTTON_LASTFM_UNBAN_ITEM,
CONTEXT_BUTTON_SET_MOVIESET_THUMB,
CONTEXT_BUTTON_DELETE_PLUGIN,
CONTEXT_BUTTON_PLAY_AND_QUEUE,
CONTEXT_BUTTON_USER1,
CONTEXT_BUTTON_USER2,
CONTEXT_BUTTON_USER3,
Expand Down
18 changes: 18 additions & 0 deletions xbmc/video/windows/GUIWindowVideoBase.cpp
Expand Up @@ -1096,6 +1096,10 @@ void CGUIWindowVideoBase::GetContextButtons(int itemNumber, CContextButtons &but
{
buttons.Add(CONTEXT_BUTTON_RESUME_ITEM, GetResumeString(*(item.get()))); // Resume Video
}
if (item->HasVideoInfoTag() && !item->m_bIsFolder && item->GetVideoInfoTag()->m_iEpisode > -1)
{
buttons.Add(CONTEXT_BUTTON_PLAY_AND_QUEUE, 13412);
}
if (item->IsSmartPlayList() || m_vecItems->IsSmartPlayList())
buttons.Add(CONTEXT_BUTTON_EDIT_SMART_PLAYLIST, 586);
}
Expand Down Expand Up @@ -1270,6 +1274,8 @@ bool CGUIWindowVideoBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
CUtil::DeleteVideoDatabaseDirectoryCache();
Update(m_vecItems->m_strPath);
return true;
case CONTEXT_BUTTON_PLAY_AND_QUEUE:
return OnPlayAndQueueMedia(item);
default:
break;
}
Expand Down Expand Up @@ -1328,6 +1334,18 @@ bool CGUIWindowVideoBase::OnPlayMedia(int iItem)
return true;
}

bool CGUIWindowVideoBase::OnPlayAndQueueMedia(const CFileItemPtr &item)
{
// Get the current playlist and make sure it is not shuffled
int iPlaylist = m_guiState->GetPlaylist();
if (iPlaylist != PLAYLIST_NONE && g_playlistPlayer.IsShuffled(iPlaylist))
g_playlistPlayer.SetShuffle(iPlaylist, false);

// Call the base method to actually queue the items
// and start playing the given item
return CGUIMediaWindow::OnPlayAndQueueMedia(item);
}

void CGUIWindowVideoBase::PlayMovie(const CFileItem *item)
{
CFileItemList movieList;
Expand Down
1 change: 1 addition & 0 deletions xbmc/video/windows/GUIWindowVideoBase.h
Expand Up @@ -99,6 +99,7 @@ class CGUIWindowVideoBase : public CGUIMediaWindow, public IBackgroundLoaderObse
bool OnResumeItem(int iItem);
void PlayItem(int iItem);
virtual bool OnPlayMedia(int iItem);
virtual bool OnPlayAndQueueMedia(const CFileItemPtr &item);
void LoadPlayList(const CStdString& strPlayList, int iPlayList = PLAYLIST_VIDEO);

bool ShowIMDB(CFileItem *item, const ADDON::ScraperPtr& content);
Expand Down
87 changes: 50 additions & 37 deletions xbmc/windows/GUIMediaWindow.cpp
Expand Up @@ -967,43 +967,7 @@ bool CGUIMediaWindow::OnClick(int iItem)
if (autoplay && !g_partyModeManager.IsEnabled() &&
!pItem->IsPlayList() && !do_not_add_karaoke)
{
g_playlistPlayer.ClearPlaylist(iPlaylist);
g_playlistPlayer.Reset();
int songToPlay = 0;
CFileItemList queueItems;
for ( int i = 0; i < m_vecItems->Size(); i++ )
{
CFileItemPtr item = m_vecItems->Get(i);

if (item->m_bIsFolder)
continue;

if (!item->IsPlayList() && !item->IsZIP() && !item->IsRAR())
queueItems.Add(item);

if (item == pItem)
{ // item that was clicked
songToPlay = queueItems.Size() - 1;
}
}
g_playlistPlayer.Add(iPlaylist, queueItems);

// Save current window and directory to know where the selected item was
if (m_guiState.get())
m_guiState->SetPlaylistDirectory(m_vecItems->m_strPath);

// figure out where we start playback
if (g_playlistPlayer.IsShuffled(iPlaylist))
{
int iIndex = g_playlistPlayer.GetPlaylist(iPlaylist).FindOrder(songToPlay);
g_playlistPlayer.GetPlaylist(iPlaylist).Swap(0, iIndex);
songToPlay = 0;
}

// play
g_playlistPlayer.SetCurrentPlaylist(iPlaylist);
g_playlistPlayer.Play(songToPlay);
return true;
return OnPlayAndQueueMedia(pItem);
}
else
{
Expand Down Expand Up @@ -1222,6 +1186,55 @@ bool CGUIMediaWindow::OnPlayMedia(int iItem)
return bResult;
}

// \brief Override if you want to change the default behavior of what is done
// when the user clicks on a file in a "folder" with similar files.
// This function is called by OnClick()
bool CGUIMediaWindow::OnPlayAndQueueMedia(const CFileItemPtr &item)
{
//play and add current directory to temporary playlist
int iPlaylist = m_guiState->GetPlaylist();
if (iPlaylist != PLAYLIST_NONE)
{
g_playlistPlayer.ClearPlaylist(iPlaylist);
g_playlistPlayer.Reset();
int mediaToPlay = 0;
CFileItemList queueItems;
for ( int i = 0; i < m_vecItems->Size(); i++ )
{
CFileItemPtr nItem = m_vecItems->Get(i);

if (nItem->m_bIsFolder)
continue;

if (!nItem->IsPlayList() && !nItem->IsZIP() && !nItem->IsRAR())
queueItems.Add(nItem);

if (nItem == item)
{ // item that was clicked
mediaToPlay = queueItems.Size() - 1;
}
}
g_playlistPlayer.Add(iPlaylist, queueItems);

// Save current window and directory to know where the selected item was
if (m_guiState.get())
m_guiState->SetPlaylistDirectory(m_vecItems->m_strPath);

// figure out where we start playback
if (g_playlistPlayer.IsShuffled(iPlaylist))
{
int iIndex = g_playlistPlayer.GetPlaylist(iPlaylist).FindOrder(mediaToPlay);
g_playlistPlayer.GetPlaylist(iPlaylist).Swap(0, iIndex);
mediaToPlay = 0;
}

// play
g_playlistPlayer.SetCurrentPlaylist(iPlaylist);
g_playlistPlayer.Play(mediaToPlay);
}
return true;
}

// \brief Synchonize the fileitems with the playlistplayer
// It recreated the playlist of the playlistplayer based
// on the fileitems of the window
Expand Down
1 change: 1 addition & 0 deletions xbmc/windows/GUIMediaWindow.h
Expand Up @@ -95,6 +95,7 @@ class CGUIMediaWindow : public CGUIWindow
void SetHistoryForPath(const CStdString& strDirectory);
virtual void LoadPlayList(const CStdString& strFileName) {}
virtual bool OnPlayMedia(int iItem);
virtual bool OnPlayAndQueueMedia(const CFileItemPtr &item);
void UpdateFileList();
virtual void OnDeleteItem(int iItem);
void OnRenameItem(int iItem);
Expand Down

0 comments on commit 8f9809d

Please sign in to comment.