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

View file

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

View file

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

View file

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

View file

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