Skip to content

Commit

Permalink
[Pictures] Better control of play/stop annoucements
Browse files Browse the repository at this point in the history
  • Loading branch information
enen92 committed Jan 3, 2024
1 parent 1bd8470 commit ad54422
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
7 changes: 1 addition & 6 deletions xbmc/pictures/GUIWindowPictures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "guilib/GUIComponent.h"
#include "guilib/GUIWindowManager.h"
#include "input/actions/ActionIDs.h"
#include "interfaces/AnnouncementManager.h"
#include "media/MediaLockState.h"
#include "messaging/helpers/DialogOKHelper.h"
#include "pictures/SlideShowDelegator.h"
Expand Down Expand Up @@ -343,11 +342,7 @@ bool CGUIWindowPictures::ShowPicture(int iItem, bool startSlideShow)
slideShow.StartSlideShow();
else
{
CVariant param;
param["player"]["speed"] = 1;
param["player"]["playerid"] = PLAYLIST::TYPE_PICTURE;
CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnPlay",
slideShow.GetCurrentSlide(), param);
slideShow.PlayPicture();
}

//! @todo this should trigger some event that should led the window manager to activate another window
Expand Down
12 changes: 7 additions & 5 deletions xbmc/pictures/GUIWindowSlideShow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1317,16 +1317,18 @@ void CGUIWindowSlideShow::RunSlideShow(const std::string &strPath,
StartSlideShow();
else
{
CVariant param;
param["player"]["speed"] = 0;
param["player"]["playerid"] = PLAYLIST::TYPE_PICTURE;
CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnPlay",
GetCurrentSlide(), param);
PlayPicture();
}

CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_SLIDESHOW);
}

void CGUIWindowSlideShow::PlayPicture()
{
if (m_iCurrentSlide >= 0 && m_iCurrentSlide < static_cast<int>(m_slides.size()))
AnnouncePlayerPlay(m_slides.at(m_iCurrentSlide));
}

void CGUIWindowSlideShow::AddItems(const std::string &strPath, path_set *recursivePaths, SortBy method, SortOrder order, SortAttribute sortAttributes)
{
// check whether we've already added this path
Expand Down
1 change: 1 addition & 0 deletions xbmc/pictures/GUIWindowSlideShow.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class CGUIWindowSlideShow : public CGUIDialog, public ISlideShowDelegate
void GetSlideShowContents(CFileItemList& list) override;
std::shared_ptr<const CFileItem> GetCurrentSlide() override;
void StartSlideShow() override;
void PlayPicture() override;
bool InSlideShow() const override;
int NumSlides() const override;
int CurrentSlide() const override;
Expand Down
8 changes: 8 additions & 0 deletions xbmc/pictures/SlideShowDelegator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ void CSlideShowDelegator::StartSlideShow()
}
}

void CSlideShowDelegator::PlayPicture()
{
if (m_delegate)
{
m_delegate->PlayPicture();
}
}

bool CSlideShowDelegator::InSlideShow() const
{
if (m_delegate)
Expand Down
1 change: 1 addition & 0 deletions xbmc/pictures/SlideShowDelegator.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class CSlideShowDelegator : public ISlideShowDelegate
void GetSlideShowContents(CFileItemList& list) override;
std::shared_ptr<const CFileItem> GetCurrentSlide() override;
void StartSlideShow() override;
void PlayPicture() override;
bool InSlideShow() const override;
int NumSlides() const override;
int CurrentSlide() const override;
Expand Down
1 change: 1 addition & 0 deletions xbmc/pictures/interfaces/ISlideShowDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ISlideShowDelegate
virtual void GetSlideShowContents(CFileItemList& list) = 0;
virtual std::shared_ptr<const CFileItem> GetCurrentSlide() = 0;
virtual void StartSlideShow() = 0;
virtual void PlayPicture() = 0;
virtual bool InSlideShow() const = 0;
virtual int NumSlides() const = 0;
virtual int CurrentSlide() const = 0;
Expand Down

0 comments on commit ad54422

Please sign in to comment.