Fixed an issue where audio for static videos in the gamelist view would get muted on navigation.

This commit is contained in:
Leon Styhre 2022-09-29 20:18:33 +02:00
parent 28209ecf08
commit 993efe8504
5 changed files with 14 additions and 11 deletions

View file

@ -21,11 +21,9 @@ GamelistView::GamelistView(FileData* root)
, mRenderer {Renderer::getInstance()} , mRenderer {Renderer::getInstance()}
, mViewStyle {ViewController::BASIC} , mViewStyle {ViewController::BASIC}
, mLegacyMode {false} , mLegacyMode {false}
, mStaticVideoAudio {false}
{ {
mViewStyle = ViewController::getInstance()->getState().viewstyle; mViewStyle = ViewController::getInstance()->getState().viewstyle;
if (mLegacyMode)
return;
} }
GamelistView::~GamelistView() GamelistView::~GamelistView()
@ -108,6 +106,7 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
return; return;
} }
mStaticVideoAudio = false;
const bool isStartupSystem {Settings::getInstance()->getString("StartupSystem") == const bool isStartupSystem {Settings::getInstance()->getString("StartupSystem") ==
mRoot->getSystem()->getName()}; mRoot->getSystem()->getName()};
@ -199,6 +198,8 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
if (mStaticVideoComponents.back()->getMetadataElement()) if (mStaticVideoComponents.back()->getMetadataElement())
mStaticVideoComponents.back()->setScrollHide(true); mStaticVideoComponents.back()->setScrollHide(true);
mStaticVideoComponents.back()->setGeneralFade(true); mStaticVideoComponents.back()->setGeneralFade(true);
if (element.second.has("audio"))
mStaticVideoAudio = element.second.get<bool>("audio");
} }
else { else {
mVideoComponents.push_back(std::make_unique<VideoFFmpegComponent>()); mVideoComponents.push_back(std::make_unique<VideoFFmpegComponent>());
@ -552,7 +553,7 @@ void GamelistView::updateView(const CursorState& state)
if (file == nullptr) { if (file == nullptr) {
if (mVideoPlaying) { if (mVideoPlaying) {
for (auto& video : mVideoComponents) { for (auto& video : mVideoComponents) {
video->stopVideoPlayer(); video->stopVideoPlayer(!mStaticVideoAudio);
video->setVideo(""); video->setVideo("");
if (!video->hasStartDelay()) if (!video->hasStartDelay())
video->setImage(""); video->setImage("");
@ -576,7 +577,7 @@ void GamelistView::updateView(const CursorState& state)
for (auto& video : mVideoComponents) { for (auto& video : mVideoComponents) {
setGameImage(mRandomGame, video.get()); setGameImage(mRandomGame, video.get());
video->stopVideoPlayer(); video->stopVideoPlayer(!mStaticVideoAudio);
if (video->hasStaticVideo()) if (video->hasStaticVideo())
video->setStaticVideo(); video->setStaticVideo();
@ -593,7 +594,7 @@ void GamelistView::updateView(const CursorState& state)
} }
for (auto& video : mVideoComponents) { for (auto& video : mVideoComponents) {
video->stopVideoPlayer(); video->stopVideoPlayer(!mStaticVideoAudio);
video->setImage(""); video->setImage("");
video->setVideo(""); video->setVideo("");
if (video->hasStaticVideo()) { if (video->hasStaticVideo()) {
@ -612,7 +613,7 @@ void GamelistView::updateView(const CursorState& state)
for (auto& video : mVideoComponents) { for (auto& video : mVideoComponents) {
setGameImage(file, video.get()); setGameImage(file, video.get());
video->stopVideoPlayer(); video->stopVideoPlayer(!mStaticVideoAudio);
if (video->hasStaticVideo()) if (video->hasStaticVideo())
video->setStaticVideo(); video->setStaticVideo();

View file

@ -127,6 +127,7 @@ private:
HelpStyle mHelpStyle; HelpStyle mHelpStyle;
ViewController::GamelistViewStyle mViewStyle; ViewController::GamelistViewStyle mViewStyle;
bool mLegacyMode; bool mLegacyMode;
bool mStaticVideoAudio;
std::shared_ptr<ThemeData> mTheme; std::shared_ptr<ThemeData> mTheme;
std::vector<GuiComponent*> mThemeExtras; std::vector<GuiComponent*> mThemeExtras;

View file

@ -90,7 +90,7 @@ public:
// Basic video controls. // Basic video controls.
void startVideoPlayer(); void startVideoPlayer();
virtual void stopVideoPlayer() {} virtual void stopVideoPlayer(bool muteAudio = true) {}
virtual void pauseVideoPlayer() {} virtual void pauseVideoPlayer() {}
// Handle looping of the video. Must be called periodically. // Handle looping of the video. Must be called periodically.

View file

@ -1441,9 +1441,10 @@ void VideoFFmpegComponent::startVideoStream()
} }
} }
void VideoFFmpegComponent::stopVideoPlayer() void VideoFFmpegComponent::stopVideoPlayer(bool muteAudio)
{ {
muteVideoPlayer(); if (muteAudio)
muteVideoPlayer();
mIsPlaying = false; mIsPlaying = false;
mIsActuallyPlaying = false; mIsActuallyPlaying = false;

View file

@ -47,7 +47,7 @@ public:
// Never breaks the aspect ratio. setMaxSize() and setResize() are mutually exclusive. // Never breaks the aspect ratio. setMaxSize() and setResize() are mutually exclusive.
void setMaxSize(float width, float height) override; void setMaxSize(float width, float height) override;
// Basic video controls. // Basic video controls.
void stopVideoPlayer() override; void stopVideoPlayer(bool muteAudio = true) override;
void pauseVideoPlayer() override; void pauseVideoPlayer() override;
// Handle looping of the video. Must be called periodically. // Handle looping of the video. Must be called periodically.
void handleLooping() override; void handleLooping() override;