From ee98002fd3c67bd0fa0030855a5f4a3bac3c58d2 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Wed, 3 Feb 2016 14:22:01 +0300 Subject: [PATCH] gui/movieplayer.cpp: add subtitles auto-select for webtv --- src/gui/movieplayer.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index d271feab5..7a870c511 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -2218,8 +2218,10 @@ void CMoviePlayerGui::showSubtitle(neutrino_msg_data_t data) void CMoviePlayerGui::selectAutoLang() { - if (ext_subs) { + if (!numsubs) playback->FindAllSubs(spids, sub_supported, &numsubs, slanguage); + + if (ext_subs) { for (unsigned count = 0; count < numsubs; count++) { if (spids[count] == 0x1FFF) { currentspid = spids[count]; @@ -2258,6 +2260,34 @@ void CMoviePlayerGui::selectAutoLang() getCurrentAudioName(is_file_player, currentaudioname); } } + if (isWebTV && g_settings.auto_subs && numsubs > 0) { + for(int i = 0; i < 3; i++) { + if(g_settings.pref_subs[i].empty() || g_settings.pref_subs[i] == "none") + continue; + + std::string temp(g_settings.pref_subs[i]); + std::string slang; + for (int j = 0 ; j < numsubs; j++) { + if (!sub_supported[j]) + continue; + slang = slanguage[j].substr(0, 3); + std::map::const_iterator it; + for(it = iso639.begin(); it != iso639.end(); ++it) { + if(temp == it->second && slang == it->first) { + currentspid = spids[j]; + break; + } + } + if (currentspid > 0) + break; + } + if (currentspid > 0) { + playback->SelectSubtitles(currentspid, g_settings.subs_charset); + printf("[movieplayer] spid changed to %d %s (%s)\n", currentspid, temp.c_str(), slang.c_str()); + break; + } + } + } } void CMoviePlayerGui::parsePlaylist(CFile *file)