import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.base.ThreadUtils;
-import org.chromium.ui.base.ViewAndroid;
-import org.chromium.ui.base.ViewAndroidDelegate;
-import org.chromium.ui.base.WindowAndroid;
/**
* This class implements accelerated fullscreen video playback using surface view.
*/
@JNINamespace("content")
public class ContentVideoView extends FrameLayout
- implements SurfaceHolder.Callback, ViewAndroidDelegate {
+ implements SurfaceHolder.Callback {
private static final String TAG = "ContentVideoView";
// Progress view when the video is loading.
private View mProgressView;
- // The ViewAndroid is used to keep screen on during video playback.
- private ViewAndroid mViewAndroid;
-
private final ContentVideoViewClient mClient;
private boolean mInitialOrientation;
// If we have never switched orientation, record the orientation
// time.
if (mPlaybackStartTime == mOrientationChangedTime) {
- if (isOrientationPortrait() != mInitialOrientation) {
- mOrientationChangedTime = System.currentTimeMillis();
- }
+ if (isOrientationPortrait() != mInitialOrientation) {
+ mOrientationChangedTime = System.currentTimeMillis();
+ }
} else {
- // if user quickly switched the orientation back and force, don't
- // count it in UMA.
- if (!mPossibleAccidentalChange &&
- isOrientationPortrait() == mInitialOrientation &&
- System.currentTimeMillis() - mOrientationChangedTime < 5000) {
- mPossibleAccidentalChange = true;
- }
+ // if user quickly switched the orientation back and force, don't
+ // count it in UMA.
+ if (!mPossibleAccidentalChange
+ && isOrientationPortrait() == mInitialOrientation
+ && System.currentTimeMillis() - mOrientationChangedTime < 5000) {
+ mPossibleAccidentalChange = true;
+ }
}
}
setMeasuredDimension(width, height);
ContentVideoViewClient client) {
super(context);
mNativeContentVideoView = nativeContentVideoView;
- mViewAndroid = new ViewAndroid(new WindowAndroid(context.getApplicationContext()), this);
mClient = client;
mUmaRecorded = false;
mPossibleAccidentalChange = false;
.setMessage(message)
.setPositiveButton(mErrorButton,
new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int whichButton) {
- /* Inform that the video is over.
- */
- onCompletion();
- }
- })
+ @Override
+ public void onClick(DialogInterface dialog, int whichButton) {
+ // Inform that the video is over.
+ onCompletion();
+ }
+ })
.setCancelable(false)
.show();
} catch (RuntimeException e) {
@CalledByNative
private static ContentVideoView createContentVideoView(
- Context context, long nativeContentVideoView, ContentVideoViewClient client) {
+ ContentViewCore contentViewCore, long nativeContentVideoView) {
ThreadUtils.assertOnUiThread();
+ Context context = contentViewCore.getContext();
+ ContentVideoViewClient client = contentViewCore.getContentVideoViewClient();
ContentVideoView videoView = new ContentVideoView(context, nativeContentVideoView, client);
- if (videoView.getContentVideoViewClient().onShowCustomView(videoView)) {
- return videoView;
- }
- return null;
+ client.enterFullscreenVideo(videoView);
+ return videoView;
}
private static boolean isActivityContext(Context context) {
setVisibility(View.GONE);
// To prevent re-entrance, call this after removeSurfaceView.
- mClient.onDestroyContentVideoView();
+ mClient.exitFullscreenVideo();
}
if (nativeViewDestroyed) {
mNativeContentVideoView = 0;
return super.onKeyUp(keyCode, event);
}
- @Override
- public View acquireAnchorView() {
- View anchorView = new View(getContext());
- addView(anchorView);
- return anchorView;
- }
-
- @Override
- public void setAnchorViewPosition(View view, float x, float y, float width, float height) {
- Log.e(TAG, "setAnchorViewPosition isn't implemented");
- }
-
- @Override
- public void releaseAnchorView(View anchorView) {
- removeView(anchorView);
- }
-
- @CalledByNative
- private long getNativeViewAndroid() {
- return mViewAndroid.getNativePointer();
- }
-
private boolean isOrientationPortrait() {
Context context = getContext();
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);