Skip to content

Commit

Permalink
Merge pull request #13699 from FernetMenta/busy
Browse files Browse the repository at this point in the history
Player: re-add busy dialog on start
  • Loading branch information
FernetMenta committed Mar 29, 2018
2 parents ad9770f + 85c3058 commit 7a4609f
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 91 deletions.
193 changes: 110 additions & 83 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "network/Network.h"
#include "threads/SystemClock.h"
#include "Application.h"
#include "dialogs/GUIDialogBusy.h"
#include "events/EventLog.h"
#include "events/NotificationEvent.h"
#include "interfaces/builtins/Builtins.h"
Expand Down Expand Up @@ -3219,15 +3220,59 @@ bool CApplication::PlayFile(CFileItem item, const std::string& player, bool bRes
return true;
}

void CApplication::OnPlayBackEnded()
void CApplication::PlaybackCleanup()
{
CLog::LogF(LOGDEBUG ,"CApplication::OnPlayBackEnded");
if (!m_appPlayer.IsPlaying())
{
g_audioManager.Enable(true);
m_appPlayer.OpenNext(m_ServiceManager->GetPlayerCoreFactory());
}

// informs python script currently running playback has ended
// (does nothing if python is not loaded)
#ifdef HAS_PYTHON
g_pythonParser.OnPlayBackEnded();
if (!m_appPlayer.IsPlayingVideo())
{
if(g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO ||
g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_GAME)
{
g_windowManager.PreviousWindow();
}
else
{
// resets to res_desktop or look&feel resolution (including refreshrate)
g_graphicsContext.SetFullScreenVideo(false);
}
#ifdef TARGET_DARWIN_IOS
CDarwinUtils::SetScheduling(false);
#endif
}

if (!m_appPlayer.IsPlayingAudio() && CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_NONE && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION)
{
m_ServiceManager->GetSettings().Save(); // save vis settings
WakeUpScreenSaverAndDPMS();
g_windowManager.PreviousWindow();
}

// DVD ejected while playing in vis ?
if (!m_appPlayer.IsPlayingAudio() && (m_itemCurrentFile->IsCDDA() || m_itemCurrentFile->IsOnDVD()) && !g_mediaManager.IsDiscInDrive() && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION)
{
// yes, disable vis
m_ServiceManager->GetSettings().Save(); // save vis settings
WakeUpScreenSaverAndDPMS();
g_windowManager.PreviousWindow();
}

if (!m_appPlayer.IsPlaying())
{
m_stackHelper.Clear();
}

if (IsEnableTestMode())
CApplicationMessenger::GetInstance().PostMsg(TMSG_QUIT);
}

void CApplication::OnPlayBackEnded()
{
CLog::LogF(LOGDEBUG ,"CApplication::OnPlayBackEnded");

CServiceBroker::GetPVRManager().OnPlaybackEnded(m_itemCurrentFile);

Expand All @@ -3247,12 +3292,6 @@ void CApplication::OnPlayBackStarted(const CFileItem &file)
if (file.GetProperty("get_stream_details_from_player").asBoolean())
m_appPlayer.SetUpdateStreamDetails();

#ifdef HAS_PYTHON
// informs python script currently running playback has started
// (does nothing if python is not loaded)
g_pythonParser.OnPlayBackStarted(file);
#endif

if (m_stackHelper.IsPlayingISOStack() || m_stackHelper.IsPlayingRegularStack())
m_itemCurrentFile.reset(new CFileItem(*m_stackHelper.GetRegisteredStack(file)));
else
Expand Down Expand Up @@ -3349,11 +3388,6 @@ void CApplication::OnPlayBackStopped()
{
CLog::LogF(LOGDEBUG, "CApplication::OnPlayBackStopped");

// informs python script currently running playback has ended
// (does nothing if python is not loaded)
#ifdef HAS_PYTHON
g_pythonParser.OnPlayBackStopped();
#endif
#if defined(TARGET_DARWIN_IOS)
CDarwinUtils::EnableOSScreenSaver(true);
#endif
Expand Down Expand Up @@ -3442,9 +3476,18 @@ void CApplication::OnPlayBackSeekChapter(int iChapter)
#endif
}

void CApplication::OnAVStarted(const CFileItem &file)
{
CGUIMessage msg(GUI_MSG_PLAYBACK_AVSTARTED, 0, 0);
g_windowManager.SendThreadMessage(msg);
}

void CApplication::OnAVChange()
{
CStereoscopicsManager::GetInstance().OnStreamChange();

CGUIMessage msg(GUI_MSG_PLAYBACK_AVCHANGE, 0, 0);
g_windowManager.SendThreadMessage(msg);
}

void CApplication::RequestVideoSettings(const CFileItem &fileItem)
Expand Down Expand Up @@ -3897,7 +3940,8 @@ bool CApplication::OnMessage(CGUIMessage& message)
case GUI_MSG_PLAYBACK_STARTED:
{
#ifdef TARGET_DARWIN_IOS
CDarwinUtils::SetScheduling(message.GetMessage());
// @TODO move this away to platform code
CDarwinUtils::SetScheduling(m_appPlayer.IsPlayingVideo());
#endif
CPlayList playList = CServiceBroker::GetPlaylistPlayer().GetPlaylist(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist());

Expand All @@ -3922,10 +3966,26 @@ bool CApplication::OnMessage(CGUIMessage& message)
g_infoManager.SetCurrentItem(*m_itemCurrentFile);
g_partyModeManager.OnSongChange(true);

#ifdef HAS_PYTHON
// informs python script currently running playback has started
// (does nothing if python is not loaded)
g_pythonParser.OnPlayBackStarted(*m_itemCurrentFile);
#endif

CVariant param;
param["player"]["speed"] = 1;
param["player"]["playerid"] = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist();
CAnnouncementManager::GetInstance().Announce(Player, "xbmc", "OnPlay", m_itemCurrentFile, param);

// we don't want a busy dialog when switching channels
if (!m_itemCurrentFile->IsPVR())
{
m_playerEvent.Reset();
CGUIDialogBusy* dialog = g_windowManager.GetWindow<CGUIDialogBusy>(WINDOW_DIALOG_BUSY);
if (dialog)
dialog->WaitOnEvent(m_playerEvent);
}

return true;
}
break;
Expand Down Expand Up @@ -3983,79 +4043,46 @@ bool CApplication::OnMessage(CGUIMessage& message)
break;

case GUI_MSG_PLAYBACK_STOPPED:
case GUI_MSG_PLAYBACK_ENDED:
case GUI_MSG_PLAYLISTPLAYER_STOPPED:
{
#ifdef TARGET_DARWIN_IOS
CDarwinUtils::SetScheduling(message.GetMessage());
m_playerEvent.Set();
m_itemCurrentFile->Reset();
g_infoManager.ResetCurrentItem();
PlaybackCleanup();
#ifdef HAS_PYTHON
g_pythonParser.OnPlayBackStopped();
#endif
// first check if we still have items in the stack to play
if (message.GetMessage() == GUI_MSG_PLAYBACK_ENDED)
{
if (m_stackHelper.IsPlayingRegularStack() && m_stackHelper.HasNextStackPartFileItem())
{ // just play the next item in the stack
PlayFile(m_stackHelper.SetNextStackPartCurrentFileItem(), "", true);
return true;
}
}

// reset the current playing file
m_itemCurrentFile->Reset();
g_infoManager.ResetCurrentItem();

if (message.GetMessage() == GUI_MSG_PLAYBACK_ENDED)
{
if (!CServiceBroker::GetPlaylistPlayer().PlayNext(1, true))
m_appPlayer.ClosePlayer();
}
return true;

if (!m_appPlayer.IsPlaying())
{
g_audioManager.Enable(true);
m_appPlayer.OpenNext(m_ServiceManager->GetPlayerCoreFactory());
}
case GUI_MSG_PLAYBACK_ENDED:
m_playerEvent.Set();
if (m_stackHelper.IsPlayingRegularStack() && m_stackHelper.HasNextStackPartFileItem())
{ // just play the next item in the stack
PlayFile(m_stackHelper.SetNextStackPartCurrentFileItem(), "", true);
return true;
}
m_itemCurrentFile->Reset();
g_infoManager.ResetCurrentItem();
if (!CServiceBroker::GetPlaylistPlayer().PlayNext(1, true))
m_appPlayer.ClosePlayer();

if (!m_appPlayer.IsPlayingVideo())
{
if(g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO ||
g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_GAME)
{
g_windowManager.PreviousWindow();
}
else
{
// resets to res_desktop or look&feel resolution (including refreshrate)
g_graphicsContext.SetFullScreenVideo(false);
}
}
PlaybackCleanup();

if (!m_appPlayer.IsPlayingAudio() && CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_NONE && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION)
{
m_ServiceManager->GetSettings().Save(); // save vis settings
WakeUpScreenSaverAndDPMS();
g_windowManager.PreviousWindow();
}
#ifdef HAS_PYTHON
g_pythonParser.OnPlayBackEnded();
#endif
return true;

// DVD ejected while playing in vis ?
if (!m_appPlayer.IsPlayingAudio() && (m_itemCurrentFile->IsCDDA() || m_itemCurrentFile->IsOnDVD()) && !g_mediaManager.IsDiscInDrive() && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION)
{
// yes, disable vis
m_ServiceManager->GetSettings().Save(); // save vis settings
WakeUpScreenSaverAndDPMS();
g_windowManager.PreviousWindow();
}
case GUI_MSG_PLAYLISTPLAYER_STOPPED:
m_itemCurrentFile->Reset();
g_infoManager.ResetCurrentItem();
PlaybackCleanup();
return true;

if (!m_appPlayer.IsPlaying())
{
m_itemCurrentFile.reset(new CFileItem());
m_stackHelper.Clear();
}
case GUI_MSG_PLAYBACK_AVSTARTED:
m_playerEvent.Set();
return true;

if (IsEnableTestMode())
CApplicationMessenger::GetInstance().PostMsg(TMSG_QUIT);
case GUI_MSG_PLAYBACK_AVCHANGE:
return true;
}
break;

case GUI_MSG_PLAYBACK_ERROR:
HELPERS::ShowOKDialogText(CVariant{16026}, CVariant{16027});
Expand Down
5 changes: 3 additions & 2 deletions xbmc/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
void OnPlayBackSeekChapter(int iChapter) override;
void OnPlayBackSpeedChanged(int iSpeed) override;
void OnAVChange() override;
void OnAVStarted(const CFileItem &file) override;
void RequestVideoSettings(const CFileItem &fileItem) override;
void StoreVideoSettings(const CFileItem &fileItem, CVideoSettings vs) override;

Expand Down Expand Up @@ -383,17 +384,16 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs

protected:
bool OnSettingsSaving() const override;

bool Load(const TiXmlNode *settings) override;
bool Save(TiXmlNode *settings) const override;

void OnSettingChanged(std::shared_ptr<const CSetting> setting) override;
void OnSettingAction(std::shared_ptr<const CSetting> setting) override;
bool OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) override;

bool LoadSkin(const std::string& skinID);

void CheckOSScreenSaverInhibitionSetting();
void PlaybackCleanup();

/*!
\brief Delegates the action to all registered action handlers.
Expand Down Expand Up @@ -501,6 +501,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
unsigned int m_ProcessedExternalCalls; /*!< counts calls wich are processed during one "door open" cycle in FrameMove */
unsigned int m_ProcessedExternalDecay = 0; /*!< counts to close door after a few frames of no python activity */
CApplicationPlayer m_appPlayer;
CEvent m_playerEvent;
CApplicationStackHelper m_stackHelper;
};

Expand Down
2 changes: 2 additions & 0 deletions xbmc/GUIUserMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,5 @@
#define GUI_MSG_UPDATE_RADIOTEXT GUI_MSG_USER + 41

#define GUI_MSG_PLAYBACK_ERROR GUI_MSG_USER + 42
#define GUI_MSG_PLAYBACK_AVCHANGE GUI_MSG_USER + 43
#define GUI_MSG_PLAYBACK_AVSTARTED GUI_MSG_USER + 44
1 change: 1 addition & 0 deletions xbmc/cores/ExternalPlayer/ExternalPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ void CExternalPlayer::Process()
}

m_callback.OnPlayBackStarted(m_file);
m_callback.OnAVStarted(m_file);

bool ret = true;
#if defined(TARGET_WINDOWS_DESKTOP)
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/IPlayerCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class IPlayerCallback
virtual void OnPlayBackSeekChapter(int iChapter) {};
virtual void OnPlayBackSpeedChanged(int iSpeed) {};
virtual void OnAVChange() {};
virtual void OnAVStarted(const CFileItem &file) {};
virtual void RequestVideoSettings(const CFileItem &fileItem) {};
virtual void StoreVideoSettings(const CFileItem &fileItem, CVideoSettings vs) {};
};
1 change: 1 addition & 0 deletions xbmc/cores/RetroPlayer/RetroPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ bool CRetroPlayer::OpenFile(const CFileItem& file, const CPlayerOptions& options
RegisterWindowCallbacks();
SetSpeedInternal(1.0);
m_callback.OnPlayBackStarted(fileCopy);
m_callback.OnAVStarted(fileCopy);
if (!bStandalone)
m_autoSave.reset(new CRetroPlayerAutoSave(*m_gameClient));
m_processInfo->SetVideoFps(static_cast<float>(m_gameClient->Timing().GetFrameRate()));
Expand Down
16 changes: 13 additions & 3 deletions xbmc/cores/VideoPlayer/VideoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,16 @@ void CVideoPlayer::HandlePlaySpeed()
UpdatePlayState(0);

m_syncTimer.Set(3000);

if (!m_State.streamsReady)
{
IPlayerCallback *cb = &m_callback;
CFileItem fileItem = m_item;
m_outboundEvents->Submit([=]() {
cb->OnAVStarted(fileItem);
});
m_State.streamsReady = true;
}
}
else
{
Expand Down Expand Up @@ -2503,10 +2513,10 @@ void CVideoPlayer::OnExit()
bool error = m_error;
bool abort = m_bAbortRequest;
m_outboundEvents->Submit([=]() {
if (error)
cb->OnPlayBackError();
else if (abort)
if (abort)
cb->OnPlayBackStopped();
else if (error)
cb->OnPlayBackError();
else
cb->OnPlayBackEnded();
});
Expand Down
2 changes: 2 additions & 0 deletions xbmc/cores/VideoPlayer/VideoPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ struct SPlayerState
cache_delay = 0.0;
cache_offset = 0.0;
lastSeek = 0;
streamsReady = false;
}

double timestamp; // last time of update
Expand All @@ -125,6 +126,7 @@ struct SPlayerState
std::string player_state; // full player state
bool isInMenu;
bool hasMenu;
bool streamsReady;

int chapter; // current chapter
std::vector<std::pair<std::string, int64_t>> chapters; // name and position for chapters
Expand Down
Loading

0 comments on commit 7a4609f

Please sign in to comment.