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.
auto video_audio = std::make_shared<SwitchComponent>(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.

View file

@ -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<SwitchComponent>(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<SwitchComponent>(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<TextComponent>(mWindow, "",
Font::get(FONT_SIZE_SMALL), 0x777777FF);

View file

@ -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.

View file

@ -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";
}

View file

@ -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);