diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index b58632531..3f98b1c95 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -585,15 +585,8 @@ void CMoviePlayerGui::PlayFile(void) playback->SetSpeed(1); } } - if (is_file_player && ext_subs) { - playback->FindAllSubs(spids, sub_supported, &numsubs, slanguage); - for (unsigned count = 0; count < numsubs; count++) { - if (spids[count] == 0x1FFF) { - currentspid = spids[count]; - playback->SelectSubtitles(currentspid); - } - } - } + if (is_file_player) + selectAutoLang(); CAudioMute::getInstance()->enableMuteIcon(true); InfoClock->enableInfoClock(true); @@ -1557,3 +1550,41 @@ void CMoviePlayerGui::showSubtitle(neutrino_msg_data_t data) avsubtitle_free(sub); delete sub; } + +void CMoviePlayerGui::selectAutoLang() +{ + if (ext_subs) { + playback->FindAllSubs(spids, sub_supported, &numsubs, slanguage); + for (unsigned count = 0; count < numsubs; count++) { + if (spids[count] == 0x1FFF) { + currentspid = spids[count]; + playback->SelectSubtitles(currentspid); + } + } + } + if(g_settings.auto_lang) { + int pref_idx = -1; + + playback->FindAllPids(apids, ac3flags, &numpida, language); + for(int i = 0; i < 3; i++) { + for (unsigned j = 0; j < numpida; j++) { + std::map::const_iterator it; + for(it = iso639.begin(); it != iso639.end(); ++it) { + if (g_settings.pref_lang[i] == it->second && strncasecmp(language[j].c_str(), it->first.c_str(), 3) == 0) { + pref_idx = j; + break; + } + } + if (pref_idx >= 0) + break; + } + if (pref_idx >= 0) + break; + } + if (pref_idx >= 0) { + currentapid = apids[pref_idx]; + currentac3 = ac3flags[pref_idx]; + playback->SetAPid(currentapid, currentac3); + } + } +} diff --git a/src/gui/movieplayer.h b/src/gui/movieplayer.h index c4068ef5e..7a2144951 100644 --- a/src/gui/movieplayer.h +++ b/src/gui/movieplayer.h @@ -141,6 +141,7 @@ class CMoviePlayerGui : public CMenuTarget void showSubtitle(neutrino_msg_data_t data); void clearSubtitle(); void selectChapter(); + void selectAutoLang(); void Cleanup(); static void *ShowStartHint(void *arg);