Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java

Issue 25040002: Enables fullscreen subtitle and media control from Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@build_hack
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java b/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
index d3e760cd6872547833273843eb278a36a723f280..fad3a357b0e29f1886b05c569f18e27d01bc0c7c 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
@@ -38,8 +38,7 @@ import org.chromium.content.R;
@JNINamespace("content")
public class ContentVideoView
extends FrameLayout
- implements ContentVideoViewControls.Delegate,
- SurfaceHolder.Callback, View.OnTouchListener, View.OnKeyListener {
+ implements SurfaceHolder.Callback {
private static final String TAG = "ContentVideoView";
@@ -74,7 +73,6 @@ public class ContentVideoView
private int mVideoHeight;
private int mCurrentBufferPercentage;
private int mDuration;
- private ContentVideoViewControls mControls;
private boolean mCanPause;
private boolean mCanSeekBack;
private boolean mCanSeekForward;
@@ -146,58 +144,6 @@ public class ContentVideoView
}
}
- private static class FullScreenControls implements ContentVideoViewControls {
-
- View mVideoView;
- MediaController mMediaController;
-
- public FullScreenControls(Context context, View video) {
- mMediaController = new MediaController(context);
- mVideoView = video;
- }
-
- @Override
- public void show() {
- mMediaController.show();
- if (mVideoView != null) {
- mVideoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
- }
- }
-
- @Override
- public void show(int timeout_ms) {
- mMediaController.show(timeout_ms);
- }
-
- @Override
- public void hide() {
- if (mVideoView != null) {
- mVideoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
- }
- mMediaController.hide();
- }
-
- @Override
- public boolean isShowing() {
- return mMediaController.isShowing();
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- mMediaController.setEnabled(enabled);
- }
-
- @Override
- public void setDelegate(Delegate delegate) {
- mMediaController.setMediaPlayer(delegate);
- }
-
- @Override
- public void setAnchorView(View view) {
- mMediaController.setAnchorView(view);
- }
- }
-
private Runnable mExitFullscreenRunnable = new Runnable() {
@Override
public void run() {
@@ -213,7 +159,6 @@ public class ContentVideoView
initResources(context);
mCurrentBufferPercentage = 0;
mVideoSurfaceView = new VideoSurfaceView(context);
- setBackgroundColor(Color.BLACK);
qinmin 2013/09/27 19:39:23 why we need to change this? if the tab surface vie
trchen 2013/09/27 22:38:41 The black filler has a z-order higher than the Bli
showContentVideoView();
setVisibility(View.VISIBLE);
mClient.onShowCustomView(this);
@@ -246,9 +191,6 @@ public class ContentVideoView
mProgressView = new ProgressView(getContext(), mVideoLoadingText);
}
this.addView(mProgressView, layoutParams);
- mVideoSurfaceView.setZOrderOnTop(true);
- mVideoSurfaceView.setOnKeyListener(this);
- mVideoSurfaceView.setOnTouchListener(this);
mVideoSurfaceView.getHolder().addCallback(this);
mVideoSurfaceView.setFocusable(true);
mVideoSurfaceView.setFocusableInTouchMode(true);
@@ -268,9 +210,6 @@ public class ContentVideoView
}
mCurrentState = STATE_ERROR;
- if (mControls != null) {
- mControls.hide();
- }
/* Pop up an error dialog so the user knows that
* something bad has happened. Only try and pop up the dialog
@@ -337,15 +276,7 @@ public class ContentVideoView
mCanPause = canPause;
mCanSeekBack = canSeekBack;
mCanSeekForward = canSeekForward;
- mCurrentState = isPlaying() ? STATE_PLAYING : STATE_PAUSED;
- if (mControls != null) {
- mControls.setEnabled(true);
- // If paused , should show the controller for ever.
- if (isPlaying())
- mControls.show();
- else
- mControls.show(0);
- }
+ mCurrentState = nativeIsPlaying(mNativeContentVideoView) ? STATE_PLAYING : STATE_PAUSED;
onVideoSizeChanged(videoWidth, videoHeight);
}
@@ -354,9 +285,6 @@ public class ContentVideoView
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
mVideoSurfaceView.setFocusable(true);
mVideoSurfaceView.setFocusableInTouchMode(true);
- if (isInPlaybackState() && mControls != null) {
- mControls.show();
- }
}
@Override
@@ -374,32 +302,11 @@ public class ContentVideoView
post(mExitFullscreenRunnable);
}
- private void setControls(ContentVideoViewControls controls) {
- if (mControls != null) {
- mControls.hide();
- }
- mControls = controls;
- attachControls();
- }
-
- private void attachControls() {
- if (mControls != null) {
- mControls.setDelegate(this);
- mControls.setAnchorView(mVideoSurfaceView);
- mControls.setEnabled(false);
- }
- }
-
@CalledByNative
private void openVideo() {
if (mSurfaceHolder != null) {
mCurrentState = STATE_IDLE;
mCurrentBufferPercentage = 0;
- ContentVideoViewControls controls = mClient.createControls();
- if (controls == null) {
- controls = new FullScreenControls(getContext(), this);
- }
- setControls(controls);
if (mNativeContentVideoView != 0) {
nativeUpdateMediaMetadata(mNativeContentVideoView);
nativeSetSurface(mNativeContentVideoView,
@@ -410,166 +317,12 @@ public class ContentVideoView
private void onCompletion() {
mCurrentState = STATE_PLAYBACK_COMPLETED;
- if (mControls != null) {
- mControls.hide();
- }
- }
-
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- if (isInPlaybackState() && mControls != null &&
- event.getAction() == MotionEvent.ACTION_DOWN) {
- toggleMediaControlsVisiblity();
- }
- return true;
- }
-
- @Override
- public boolean onTrackballEvent(MotionEvent ev) {
- if (isInPlaybackState() && mControls != null) {
- toggleMediaControlsVisiblity();
- }
- return false;
- }
-
- @Override
- public boolean onKey(View v, int keyCode, KeyEvent event) {
- boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK &&
- keyCode != KeyEvent.KEYCODE_VOLUME_UP &&
- keyCode != KeyEvent.KEYCODE_VOLUME_DOWN &&
- keyCode != KeyEvent.KEYCODE_VOLUME_MUTE &&
- keyCode != KeyEvent.KEYCODE_CALL &&
- keyCode != KeyEvent.KEYCODE_MENU &&
- keyCode != KeyEvent.KEYCODE_SEARCH &&
- keyCode != KeyEvent.KEYCODE_ENDCALL;
- if (isInPlaybackState() && isKeyCodeSupported && mControls != null) {
- if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
- keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
- if (isPlaying()) {
- pause();
- mControls.show();
- } else {
- start();
- mControls.hide();
- }
- return true;
- } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
- if (!isPlaying()) {
- start();
- mControls.hide();
- }
- return true;
- } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
- || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
- if (isPlaying()) {
- pause();
- mControls.show();
- }
- return true;
- } else {
- toggleMediaControlsVisiblity();
- }
- } else if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
- exitFullscreen(false);
- return true;
- } else if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_SEARCH) {
- return true;
- }
- return super.onKeyDown(keyCode, event);
- }
-
- private void toggleMediaControlsVisiblity() {
- if (mControls.isShowing()) {
- mControls.hide();
- } else {
- mControls.show();
- }
}
private boolean isInPlaybackState() {
return (mCurrentState != STATE_ERROR && mCurrentState != STATE_IDLE);
}
- @Override
- public void start() {
- if (isInPlaybackState()) {
- if (mNativeContentVideoView != 0) {
- nativePlay(mNativeContentVideoView);
- }
- mCurrentState = STATE_PLAYING;
- }
- }
-
- @Override
- public void pause() {
- if (isInPlaybackState()) {
- if (isPlaying()) {
- if (mNativeContentVideoView != 0) {
- nativePause(mNativeContentVideoView);
- }
- mCurrentState = STATE_PAUSED;
- }
- }
- }
-
- // cache duration as mDuration for faster access
- @Override
- public int getDuration() {
- if (isInPlaybackState()) {
- if (mDuration > 0) {
- return mDuration;
- }
- if (mNativeContentVideoView != 0) {
- mDuration = nativeGetDurationInMilliSeconds(mNativeContentVideoView);
- } else {
- mDuration = 0;
- }
- return mDuration;
- }
- mDuration = -1;
- return mDuration;
- }
-
- @Override
- public int getCurrentPosition() {
- if (isInPlaybackState() && mNativeContentVideoView != 0) {
- return nativeGetCurrentPosition(mNativeContentVideoView);
- }
- return 0;
- }
-
- @Override
- public void seekTo(int msec) {
- if (mNativeContentVideoView != 0) {
- nativeSeekTo(mNativeContentVideoView, msec);
- }
- }
-
- @Override
- public boolean isPlaying() {
- return mNativeContentVideoView != 0 && nativeIsPlaying(mNativeContentVideoView);
- }
-
- @Override
- public int getBufferPercentage() {
- return mCurrentBufferPercentage;
- }
-
- @Override
- public boolean canPause() {
- return mCanPause;
- }
-
- @Override
- public boolean canSeekBackward() {
- return mCanSeekBack;
- }
-
- @Override
- public boolean canSeekForward() {
- return mCanSeekForward;
- }
-
public int getAudioSessionId() {
return 0;
}
@@ -586,14 +339,6 @@ public class ContentVideoView
return new ContentVideoView(context, nativeContentVideoView, client);
}
- private void removeControls() {
- if (mControls != null) {
- mControls.setEnabled(false);
- mControls.hide();
- mControls = null;
- }
- }
-
public void removeSurfaceView() {
removeView(mVideoSurfaceView);
removeView(mProgressView);
@@ -617,7 +362,6 @@ public class ContentVideoView
private void destroyContentVideoView(boolean nativeViewDestroyed) {
if (mVideoSurfaceView != null) {
mClient.onDestroyContentVideoView();
- removeControls();
removeSurfaceView();
setVisibility(View.GONE);
}
@@ -631,11 +375,6 @@ public class ContentVideoView
}
@Override
- public boolean onTouchEvent(MotionEvent ev) {
- return true;
- }
-
- @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
exitFullscreen(false);

Powered by Google App Engine
This is Rietveld 408576698