[Android] Disable subs picker & downloader for TS
Geoffrey Métais
git at videolan.org
Mon Nov 6 16:00:44 CET 2017
vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Nov 6 10:27:48 2017 +0100| [8569843bd7b3b863e37fd089f8f41275404ebbd0] | committer: Geoffrey Métais
Disable subs picker & downloader for TS
(cherry picked from commit a850b17158244c99da8837547339343b7cf7b847)
> https://code.videolan.org/videolan/vlc-android/commit/8569843bd7b3b863e37fd089f8f41275404ebbd0
---
.../vlc/gui/video/VideoPlayerActivity.java | 27 ++++++++++++++++------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 8cf3713f0..74dea0c54 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -73,6 +73,7 @@ import android.view.Display;
import android.view.GestureDetector;
import android.view.InputDevice;
import android.view.KeyEvent;
+import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
@@ -566,6 +567,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
setPlaybackParameters();
mForcedTime = mLastTime = -1;
setOverlayProgress();
+ enableSubs();
}
}
@@ -2422,12 +2424,14 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
anchor = mTracks;
}
final AppCompatActivity context = this;
- PopupMenu popupMenu = new PopupMenu(this, anchor);
- popupMenu.getMenuInflater().inflate(R.menu.audiosub_tracks, popupMenu.getMenu());
- popupMenu.getMenu().findItem(R.id.video_menu_audio_track).setEnabled(mService.getAudioTracksCount() > 0);
- popupMenu.getMenu().findItem(R.id.video_menu_subtitles).setEnabled(mService.getSpuTracksCount() > 0);
+ final PopupMenu popupMenu = new PopupMenu(this, anchor);
+ final Menu menu = popupMenu.getMenu();
+ popupMenu.getMenuInflater().inflate(R.menu.audiosub_tracks, menu);
//FIXME network subs cannot be enabled & screen cast display is broken with picker
- popupMenu.getMenu().findItem(R.id.video_menu_subtitles_picker).setEnabled(mPresentation == null);
+ menu.findItem(R.id.video_menu_subtitles_picker).setEnabled(mPresentation == null && enableSubs);
+ menu.findItem(R.id.video_menu_subtitles_download).setEnabled(enableSubs);
+ menu.findItem(R.id.video_menu_audio_track).setEnabled(mService.getAudioTracksCount() > 0);
+ menu.findItem(R.id.video_menu_subtitles).setEnabled(mService.getSpuTracksCount() > 0);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
@@ -2441,7 +2445,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (mUri == null)
return false;
mShowingDialog = true;
- Intent filePickerIntent = new Intent(context, FilePickerActivity.class);
+ final Intent filePickerIntent = new Intent(context, FilePickerActivity.class);
filePickerIntent.setData(Uri.parse(FileUtils.getParent(mUri.toString())));
context.startActivityForResult(filePickerIntent, 0);
return true;
@@ -2671,7 +2675,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (trackID < -1 || mService == null)
return false;
mService.setSpuTrack(trackID);
- MediaWrapper mw = mMedialibrary.findMedia(mService.getCurrentMediaWrapper());
+ final MediaWrapper mw = mMedialibrary.findMedia(mService.getCurrentMediaWrapper());
if (mw != null && mw.getId() != 0L)
mw.setLongMeta(MediaWrapper.META_SUBTITLE_TRACK, trackID);
return true;
@@ -3308,6 +3312,15 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mForcedTime = -1;
showOverlay(true);
}
+ enableSubs();
+ }
+
+ private boolean enableSubs = true;
+ private void enableSubs() {
+ if (mUri == null || mUri.getScheme().startsWith("http")) return;
+ final String lastPath = mUri.getLastPathSegment();
+ enableSubs = !TextUtils.isEmpty(lastPath) && !lastPath.endsWith(".ts") && !lastPath.endsWith(".m2ts")
+ && !lastPath.endsWith(".TS") && !lastPath.endsWith(".M2TS");
}
private SubtitlesGetTask mSubtitlesGetTask = null;
More information about the Android
mailing list