From 6090ff3df84affcb6f05d9aae4011397fa5142eb Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 27 Jul 2020 21:31:02 +0200 Subject: [PATCH] Improved handling of audio settings for video files. --- es-app/src/guis/GuiMenu.cpp | 6 +++--- es-app/src/guis/GuiVideoScreensaverOptions.cpp | 12 +++++++----- es-core/src/Settings.cpp | 4 ++-- es-core/src/components/VideoPlayerComponent.cpp | 4 ++-- es-core/src/components/VideoVlcComponent.cpp | 11 ++++++----- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 7868cedc6..f590d06eb 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -179,9 +179,9 @@ void GuiMenu::openSoundSettings() // Video audio. auto video_audio = std::make_shared(mWindow); - video_audio->setState(Settings::getInstance()->getBool("VideoAudio")); - s->addWithLabel("AUDIO FOR VIDEO FILES", video_audio); - s->addSaveFunc([video_audio] { Settings::getInstance()->setBool("VideoAudio", + video_audio->setState(Settings::getInstance()->getBool("GamelistVideoAudio")); + s->addWithLabel("PLAY AUDIO FOR VIDEO FILES IN GAMELIST VIEWS", video_audio); + s->addSaveFunc([video_audio] { Settings::getInstance()->setBool("GamelistVideoAudio", video_audio->getState()); }); // Navigation sounds. diff --git a/es-app/src/guis/GuiVideoScreensaverOptions.cpp b/es-app/src/guis/GuiVideoScreensaverOptions.cpp index 19407f36c..e041a9fda 100644 --- a/es-app/src/guis/GuiVideoScreensaverOptions.cpp +++ b/es-app/src/guis/GuiVideoScreensaverOptions.cpp @@ -78,13 +78,15 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha int subSize = (int)Math::round(ss_omx_font_size->getValue()); Settings::getInstance()->setInt("SubtitleSize", subSize); }); + #endif - auto ss_video_mute = std::make_shared(mWindow); - ss_video_mute->setState(Settings::getInstance()->getBool("ScreenSaverVideoMute")); - addWithLabel("MUTE SCREENSAVER AUDIO", ss_video_mute); - addSaveFunc([ss_video_mute] { Settings::getInstance()-> - setBool("ScreenSaverVideoMute", ss_video_mute->getState()); }); + auto ss_video_audio = std::make_shared(mWindow); + ss_video_audio->setState(Settings::getInstance()->getBool("ScreenSaverVideoAudio")); + addWithLabel("PLAY AUDIO FOR SCREENSAVER VIDEO FILES", ss_video_audio); + addSaveFunc([ss_video_audio] { Settings::getInstance()-> + setBool("ScreenSaverVideoAudio", ss_video_audio->getState()); }); + #ifdef _RPI_ // Define subtitle font. auto ss_omx_font_file = std::make_shared(mWindow, "", Font::get(FONT_SIZE_SMALL), 0x777777FF); diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index e66f72c32..1fc2c423f 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -100,7 +100,7 @@ void Settings::setDefaults() mIntMap["ScreenSaverSwapVideoTimeout"] = 20000; mBoolMap["ScreenSaverStretchVideos"] = false; mStringMap["ScreenSaverGameInfo"] = "never"; - mBoolMap["ScreenSaverVideoMute"] = false; // Raspberry Pi only + mBoolMap["ScreenSaverVideoAudio"] = false; // UI settings -> screensaver settings -> slideshow screensaver settings. mIntMap["ScreenSaverSwapImageTimeout"] = 10000; @@ -132,7 +132,7 @@ void Settings::setDefaults() //#else // mStringMap["AudioDevice"] = "Master"; #endif - mBoolMap["VideoAudio"] = true; + mBoolMap["GamelistVideoAudio"] = true; mBoolMap["NavigationSounds"] = true; // Game collection settings. diff --git a/es-core/src/components/VideoPlayerComponent.cpp b/es-core/src/components/VideoPlayerComponent.cpp index 698cfae4a..aada37351 100644 --- a/es-core/src/components/VideoPlayerComponent.cpp +++ b/es-core/src/components/VideoPlayerComponent.cpp @@ -162,9 +162,9 @@ void VideoPlayerComponent::startVideo() "", "", "", "", "", NULL }; // Check if we want to mute the audio. - if ((!Settings::getInstance()->getBool("VideoAudio") || + if ((!Settings::getInstance()->getBool("GamelistVideoAudio") || (float)VolumeControl::getInstance()->getVolume() == 0) || - (Settings::getInstance()->getBool("ScreenSaverVideoMute") && + (!Settings::getInstance()->getBool("ScreenSaverVideoAudio") && mScreensaverMode)) { argv[8] = "-1000000"; } diff --git a/es-core/src/components/VideoVlcComponent.cpp b/es-core/src/components/VideoVlcComponent.cpp index dbd09b7e9..c780b8837 100644 --- a/es-core/src/components/VideoVlcComponent.cpp +++ b/es-core/src/components/VideoVlcComponent.cpp @@ -227,8 +227,8 @@ void VideoVlcComponent::handleLooping() if (mIsPlaying && mMediaPlayer) { libvlc_state_t state = libvlc_media_player_get_state(mMediaPlayer); if (state == libvlc_Ended) { - if (!Settings::getInstance()->getBool("VideoAudio") || - (Settings::getInstance()->getBool("ScreenSaverVideoMute") && mScreensaverMode)) + if (!Settings::getInstance()->getBool("GamelistVideoAudio") || + (!Settings::getInstance()->getBool("ScreenSaverVideoAudio") && mScreensaverMode)) libvlc_audio_set_mute(mMediaPlayer, 1); libvlc_media_player_set_media(mMediaPlayer, mMedia); @@ -307,9 +307,10 @@ void VideoVlcComponent::startVideo() // Setup the media player. mMediaPlayer = libvlc_media_player_new_from_media(mMedia); - if (!Settings::getInstance()->getBool("VideoAudio") || - (Settings::getInstance()->getBool("ScreenSaverVideoMute") && - mScreensaverMode)) + if ((!Settings::getInstance()->getBool("GamelistVideoAudio") && + !mScreensaverMode) || + (!Settings::getInstance()->getBool("ScreenSaverVideoAudio") && + mScreensaverMode)) libvlc_audio_set_mute(mMediaPlayer, 1); libvlc_media_player_play(mMediaPlayer);