Improved handling of audio settings for video files.

This commit is contained in:
Leon Styhre 2020-07-27 21:31:02 +02:00
parent 9f0e587b1a
commit 6090ff3df8
5 changed files with 20 additions and 17 deletions

View file

@ -179,9 +179,9 @@ void GuiMenu::openSoundSettings()
// Video audio. // Video audio.
auto video_audio = std::make_shared<SwitchComponent>(mWindow); auto video_audio = std::make_shared<SwitchComponent>(mWindow);
video_audio->setState(Settings::getInstance()->getBool("VideoAudio")); video_audio->setState(Settings::getInstance()->getBool("GamelistVideoAudio"));
s->addWithLabel("AUDIO FOR VIDEO FILES", video_audio); s->addWithLabel("PLAY AUDIO FOR VIDEO FILES IN GAMELIST VIEWS", video_audio);
s->addSaveFunc([video_audio] { Settings::getInstance()->setBool("VideoAudio", s->addSaveFunc([video_audio] { Settings::getInstance()->setBool("GamelistVideoAudio",
video_audio->getState()); }); video_audio->getState()); });
// Navigation sounds. // Navigation sounds.

View file

@ -78,13 +78,15 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha
int subSize = (int)Math::round(ss_omx_font_size->getValue()); int subSize = (int)Math::round(ss_omx_font_size->getValue());
Settings::getInstance()->setInt("SubtitleSize", subSize); Settings::getInstance()->setInt("SubtitleSize", subSize);
}); });
#endif
auto ss_video_mute = std::make_shared<SwitchComponent>(mWindow); auto ss_video_audio = std::make_shared<SwitchComponent>(mWindow);
ss_video_mute->setState(Settings::getInstance()->getBool("ScreenSaverVideoMute")); ss_video_audio->setState(Settings::getInstance()->getBool("ScreenSaverVideoAudio"));
addWithLabel("MUTE SCREENSAVER AUDIO", ss_video_mute); addWithLabel("PLAY AUDIO FOR SCREENSAVER VIDEO FILES", ss_video_audio);
addSaveFunc([ss_video_mute] { Settings::getInstance()-> addSaveFunc([ss_video_audio] { Settings::getInstance()->
setBool("ScreenSaverVideoMute", ss_video_mute->getState()); }); setBool("ScreenSaverVideoAudio", ss_video_audio->getState()); });
#ifdef _RPI_
// Define subtitle font. // Define subtitle font.
auto ss_omx_font_file = std::make_shared<TextComponent>(mWindow, "", auto ss_omx_font_file = std::make_shared<TextComponent>(mWindow, "",
Font::get(FONT_SIZE_SMALL), 0x777777FF); Font::get(FONT_SIZE_SMALL), 0x777777FF);

View file

@ -100,7 +100,7 @@ void Settings::setDefaults()
mIntMap["ScreenSaverSwapVideoTimeout"] = 20000; mIntMap["ScreenSaverSwapVideoTimeout"] = 20000;
mBoolMap["ScreenSaverStretchVideos"] = false; mBoolMap["ScreenSaverStretchVideos"] = false;
mStringMap["ScreenSaverGameInfo"] = "never"; mStringMap["ScreenSaverGameInfo"] = "never";
mBoolMap["ScreenSaverVideoMute"] = false; // Raspberry Pi only mBoolMap["ScreenSaverVideoAudio"] = false;
// UI settings -> screensaver settings -> slideshow screensaver settings. // UI settings -> screensaver settings -> slideshow screensaver settings.
mIntMap["ScreenSaverSwapImageTimeout"] = 10000; mIntMap["ScreenSaverSwapImageTimeout"] = 10000;
@ -132,7 +132,7 @@ void Settings::setDefaults()
//#else //#else
// mStringMap["AudioDevice"] = "Master"; // mStringMap["AudioDevice"] = "Master";
#endif #endif
mBoolMap["VideoAudio"] = true; mBoolMap["GamelistVideoAudio"] = true;
mBoolMap["NavigationSounds"] = true; mBoolMap["NavigationSounds"] = true;
// Game collection settings. // Game collection settings.

View file

@ -162,9 +162,9 @@ void VideoPlayerComponent::startVideo()
"", "", "", "", "", NULL }; "", "", "", "", "", NULL };
// Check if we want to mute the audio. // Check if we want to mute the audio.
if ((!Settings::getInstance()->getBool("VideoAudio") || if ((!Settings::getInstance()->getBool("GamelistVideoAudio") ||
(float)VolumeControl::getInstance()->getVolume() == 0) || (float)VolumeControl::getInstance()->getVolume() == 0) ||
(Settings::getInstance()->getBool("ScreenSaverVideoMute") && (!Settings::getInstance()->getBool("ScreenSaverVideoAudio") &&
mScreensaverMode)) { mScreensaverMode)) {
argv[8] = "-1000000"; argv[8] = "-1000000";
} }

View file

@ -227,8 +227,8 @@ void VideoVlcComponent::handleLooping()
if (mIsPlaying && mMediaPlayer) { if (mIsPlaying && mMediaPlayer) {
libvlc_state_t state = libvlc_media_player_get_state(mMediaPlayer); libvlc_state_t state = libvlc_media_player_get_state(mMediaPlayer);
if (state == libvlc_Ended) { if (state == libvlc_Ended) {
if (!Settings::getInstance()->getBool("VideoAudio") || if (!Settings::getInstance()->getBool("GamelistVideoAudio") ||
(Settings::getInstance()->getBool("ScreenSaverVideoMute") && mScreensaverMode)) (!Settings::getInstance()->getBool("ScreenSaverVideoAudio") && mScreensaverMode))
libvlc_audio_set_mute(mMediaPlayer, 1); libvlc_audio_set_mute(mMediaPlayer, 1);
libvlc_media_player_set_media(mMediaPlayer, mMedia); libvlc_media_player_set_media(mMediaPlayer, mMedia);
@ -307,9 +307,10 @@ void VideoVlcComponent::startVideo()
// Setup the media player. // Setup the media player.
mMediaPlayer = libvlc_media_player_new_from_media(mMedia); mMediaPlayer = libvlc_media_player_new_from_media(mMedia);
if (!Settings::getInstance()->getBool("VideoAudio") || if ((!Settings::getInstance()->getBool("GamelistVideoAudio") &&
(Settings::getInstance()->getBool("ScreenSaverVideoMute") && !mScreensaverMode) ||
mScreensaverMode)) (!Settings::getInstance()->getBool("ScreenSaverVideoAudio") &&
mScreensaverMode))
libvlc_audio_set_mute(mMediaPlayer, 1); libvlc_audio_set_mute(mMediaPlayer, 1);
libvlc_media_player_play(mMediaPlayer); libvlc_media_player_play(mMediaPlayer);