diff --git a/res/values/strings.xml b/res/values/strings.xml index 23927b56..5544cbab 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -444,7 +444,7 @@ Get subtitles online Subtitles track found for this language Subtitles track not found for this language - subtitles web service outage + Subtitles web service outage Get missing subtitles Copying subtitles… Downloading subtitles… @@ -602,6 +602,8 @@ Select your languages for downloading subtitles Subtitles reading language Choose your favorite language for reading subtitles + Audio preferred language + Choose your favorite audio track language User interface mode Choose between TV and Tablet/Phone UI About diff --git a/res/xml/preferences_video.xml b/res/xml/preferences_video.xml index 52f51546..0a23bc49 100644 --- a/res/xml/preferences_video.xml +++ b/res/xml/preferences_video.xml @@ -116,6 +116,14 @@ android:summary="@string/preference_remove_dolby_vision_summary" android:title="@string/preference_remove_dolby_vision" app:iconSpaceReserved="false"/> + {} matching favorite audioTrack language {}", i, mAudioInfoController.getTrackNameAt(i).toString(), locale.getDisplayLanguage()); + mVideoInfo.audioTrack = i; + break; + } + } + } mAudioInfoController.setTrack(mVideoInfo.audioTrack); - } public void onSubtitleMetadataUpdated(VideoMetadata vMetadata, int newSubtitleTrack) { @@ -3699,7 +3716,12 @@ public void onAudioError(boolean isNotSupported,String msg) { @Override public void onVideoDb(final VideoDbInfo localVideoInfo, final VideoDbInfo remoteVideoInfo) { log.debug("onVideoDb: localVideoInfo.subtitleTrack={}, remoteVideoInfo.subtitleTrack={}", ((localVideoInfo != null) ? localVideoInfo.subtitleTrack : "none"), ((remoteVideoInfo != null) ? remoteVideoInfo.subtitleTrack : "none")); + log.debug("onVideoDb: localVideoInfo.audioTrack={}, remoteVideoInfo.audioTrack={}", ((localVideoInfo != null) ? localVideoInfo.audioTrack : "none"), ((remoteVideoInfo != null) ? remoteVideoInfo.audioTrack : "none")); log.debug("onVideoDb: trakt: " + localVideoInfo.traktResume+ " local "+ localVideoInfo.resume); + if (localVideoInfo.audioTrack == -1 && remoteVideoInfo.audioTrack == -1) { + log.debug("onVideoDb: first play"); + fileHasAlreadyPlayed = false; + } else fileHasAlreadyPlayed = true; if (localVideoInfo != null) { final int localTraktPosition = Math.abs(localVideoInfo.duration>0 ? (int)(localVideoInfo.traktResume * (double) localVideoInfo.duration / 100) : 0); log.info("onVideoDb: trakt calc: "+ localTraktPosition+ " local "+ localVideoInfo.resume); diff --git a/src/main/java/com/archos/mediacenter/video/player/PlayerService.java b/src/main/java/com/archos/mediacenter/video/player/PlayerService.java index 272845c0..72d951ff 100644 --- a/src/main/java/com/archos/mediacenter/video/player/PlayerService.java +++ b/src/main/java/com/archos/mediacenter/video/player/PlayerService.java @@ -1248,14 +1248,19 @@ public void onAudioMetadataUpdated(VideoMetadata vMetadata, int newAudioTrack) { if (mVideoInfo == null) { mNewAudioTrack = newAudioTrack; mAudioSubtitleNeedUpdate = true; + log.debug("onAudioMetadataUpdated: mVideoInfo == null, mNewAudioTrack=" + mNewAudioTrack + " newAudioTrack=" + newAudioTrack + " mAudioSubtitleNeedUpdate=" + mAudioSubtitleNeedUpdate); return; + } else { + log.debug("onAudioMetadataUpdated: mVideoInfo != null, mVideoInfo.audioTrack=" + mVideoInfo.audioTrack + " newAudioTrack=" + newAudioTrack + " mAudioSubtitleNeedUpdate=" + mAudioSubtitleNeedUpdate); } int nbTrack = vMetadata.getAudioTrackNb(); boolean supported = true; + if (mVideoInfo.audioTrack < 0 || mVideoInfo.audioTrack >= nbTrack || !vMetadata.getAudioTrack(mVideoInfo.audioTrack).supported) { for (int i = 0; i < nbTrack; ++i) { if (vMetadata.getAudioTrack(i).supported) { + log.debug("onAudioMetadataUpdated: selected first supported track #{} -> {}", i, vMetadata.getAudioTrack(i).name); mVideoInfo.audioTrack = i; supported = true; break; @@ -1275,7 +1280,6 @@ public void onAudioMetadataUpdated(VideoMetadata vMetadata, int newAudioTrack) { if(mPlayerFrontend!=null) { mPlayerFrontend.onAudioError(true, at != null ? at.format : "unknown"); } - } if(mPlayerFrontend!=null) { @@ -1317,6 +1321,7 @@ public void onSubtitleMetadataUpdated(VideoMetadata vMetadata, int newSubtitleTr } // mVideoInfo.subtitleTrack is the track number without the none track 0<=mVideoInfo.subtitleTrack= 0 && mVideoInfo.subtitleTrack < nbTrack) { + log.debug("onSubtitleMetadataUpdated: newSubtitleTrack={}, mVideoInfo.subtitleTrack={}", newSubtitleTrack, mVideoInfo.subtitleTrack); if (newSubtitleTrack != mVideoInfo.subtitleTrack && !mPlayer.setSubtitleTrack(mVideoInfo.subtitleTrack)) mVideoInfo.subtitleTrack = noneTrack; diff --git a/src/main/java/com/archos/mediacenter/video/utils/VideoPreferencesCommon.java b/src/main/java/com/archos/mediacenter/video/utils/VideoPreferencesCommon.java index 72f792d4..93424345 100644 --- a/src/main/java/com/archos/mediacenter/video/utils/VideoPreferencesCommon.java +++ b/src/main/java/com/archos/mediacenter/video/utils/VideoPreferencesCommon.java @@ -156,6 +156,7 @@ public class VideoPreferencesCommon implements OnSharedPreferenceChangeListener public static final String KEY_AUDIO_INTERFACE_CHOICE = "audio_interface_choice"; public static final String KEY_SUBTITLES_HIDE = "subtitles_hide_default"; public static final String KEY_SUBTITLES_FAV_LANG = "favSubLang"; + public static final String KEY_AUDIO_TRACK_FAV_LANG = "favAudioLang"; public static final String KEY_TRAKT_CATEGORY = "trakt_category"; public static final String KEY_TRAKT_GETFULL = "trakt_getfull"; public static final String KEY_TRAKT_SIGNIN = "trakt_signin"; @@ -220,6 +221,7 @@ public class VideoPreferencesCommon implements OnSharedPreferenceChangeListener private PreferenceCategory mScraperCategory = null; private ListPreference mSubtitlesFavLangPreferences = null; private MultiSelectListPreference mSubtitlesDownloadLanguagePreferences = null; + private ListPreference mAudioTrackFavoriteLanguage = null; private CheckBoxPreference mEnableSponsor = null; private CheckBoxPreference mWatchingUpNext = null; private PreferenceCategory mAboutPreferences = null; @@ -263,6 +265,7 @@ public class VideoPreferencesCommon implements OnSharedPreferenceChangeListener CharSequence[] languageListNewEntries; CharSequence[] languageListNewEntryValues; int systemLanguageIndex; + int systemAudioLanguageIndex; public VideoPreferencesCommon(PreferenceFragmentCompat preferencesFragment) { mPreferencesFragment = preferencesFragment; @@ -699,6 +702,11 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { mSubtitlesFavLangPreferences.setEntryValues(languageListNewEntryValues); if(systemLanguageIndex>=0) mSubtitlesFavLangPreferences.setValueIndex(systemLanguageIndex); + mAudioTrackFavoriteLanguage = (ListPreference) findPreference(KEY_AUDIO_TRACK_FAV_LANG); + mAudioTrackFavoriteLanguage.setEntries(languageListNewEntries); + mAudioTrackFavoriteLanguage.setEntryValues(languageListNewEntryValues); + if(systemLanguageIndex>=0) mAudioTrackFavoriteLanguage.setValueIndex(systemAudioLanguageIndex); + ListPreference lp = (ListPreference) findPreference("codepage"); int cp = MediaFactory.getCodepage(); int cpStringID = getResources().getIdentifier("codepage_extra_" + cp, "string", getActivity().getPackageName()); @@ -1015,16 +1023,23 @@ private void buildLanguageList() { languageListEntryValues.toArray(languageListNewEntryValues); systemLanguageIndex = -1; final String currentFavoriteLang; + final String currentAudioFavoriteLang; if (CustomApplication.useOpenSubtitlesRestApi()) currentFavoriteLang = getPreferenceManager().getSharedPreferences().getString(KEY_SUBTITLES_FAV_LANG, Locale.getDefault().getLanguage()); else currentFavoriteLang = getPreferenceManager().getSharedPreferences().getString(KEY_SUBTITLES_FAV_LANG, Locale.getDefault().getISO3Language()); - log.debug("onCreatePreferences: currentFavoriteLang={}", currentFavoriteLang); + + currentAudioFavoriteLang = getPreferenceManager().getSharedPreferences().getString(KEY_AUDIO_TRACK_FAV_LANG, Locale.getDefault().getLanguage()); + + log.debug("onCreatePreferences: currentSubFavoriteLang={}, currentAudioFavoriteLang={}", currentFavoriteLang, currentAudioFavoriteLang); int i = 0; for(CharSequence value : languageListNewEntryValues){ if(value.toString().equalsIgnoreCase(currentFavoriteLang)) { systemLanguageIndex = i; } + if(value.toString().equalsIgnoreCase(currentAudioFavoriteLang)) { + systemAudioLanguageIndex = i; + } i++; } } diff --git a/src/noamazon/play/release-notes/en-US/internal.txt b/src/noamazon/play/release-notes/en-US/internal.txt index f968bf00..abdd538a 100644 --- a/src/noamazon/play/release-notes/en-US/internal.txt +++ b/src/noamazon/play/release-notes/en-US/internal.txt @@ -1,3 +1,4 @@ +- Add preferred audio language option for multi audio track videos - Another attempt to fix ftp - libyuv upstep aligned on chromium master - Stability enhancements