| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.app.AlertDialog; | 7 import android.app.AlertDialog; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.DialogInterface; | 9 import android.content.DialogInterface; |
| 10 import android.graphics.Point; | 10 import android.graphics.Point; |
| 11 import android.provider.Settings; | 11 import android.provider.Settings; |
| 12 import android.view.Display; | 12 import android.view.Display; |
| 13 import android.view.Gravity; | 13 import android.view.Gravity; |
| 14 import android.view.KeyEvent; | 14 import android.view.KeyEvent; |
| 15 import android.view.Surface; | 15 import android.view.Surface; |
| 16 import android.view.SurfaceHolder; | 16 import android.view.SurfaceHolder; |
| 17 import android.view.SurfaceView; | 17 import android.view.SurfaceView; |
| 18 import android.view.View; | 18 import android.view.View; |
| 19 import android.view.ViewGroup; | 19 import android.view.ViewGroup; |
| 20 import android.view.WindowManager; | 20 import android.view.WindowManager; |
| 21 import android.widget.FrameLayout; | 21 import android.widget.FrameLayout; |
| 22 import android.widget.LinearLayout; | 22 import android.widget.LinearLayout; |
| 23 import android.widget.ProgressBar; | 23 import android.widget.ProgressBar; |
| 24 import android.widget.TextView; | 24 import android.widget.TextView; |
| 25 | 25 |
| 26 import org.chromium.base.Log; | 26 import org.chromium.base.Log; |
| 27 import org.chromium.base.ThreadUtils; | 27 import org.chromium.base.ThreadUtils; |
| 28 import org.chromium.base.annotations.CalledByNative; | 28 import org.chromium.base.annotations.CalledByNative; |
| 29 import org.chromium.base.annotations.JNINamespace; | 29 import org.chromium.base.annotations.JNINamespace; |
| 30 import org.chromium.ui.base.WindowAndroid; |
| 30 | 31 |
| 31 /** | 32 /** |
| 32 * This class implements accelerated fullscreen video playback using surface vie
w. | 33 * This class implements accelerated fullscreen video playback using surface vie
w. |
| 33 */ | 34 */ |
| 34 @JNINamespace("content") | 35 @JNINamespace("content") |
| 35 public class ContentVideoView extends FrameLayout | 36 public class ContentVideoView extends FrameLayout |
| 36 implements SurfaceHolder.Callback { | 37 implements SurfaceHolder.Callback { |
| 37 | 38 |
| 38 private static final String TAG = "cr.ContentVideoView"; | 39 private static final String TAG = "cr.ContentVideoView"; |
| 39 | 40 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 return; | 222 return; |
| 222 } | 223 } |
| 223 | 224 |
| 224 // Ignore some invalid error codes. | 225 // Ignore some invalid error codes. |
| 225 if (errorType == MEDIA_ERROR_INVALID_CODE) { | 226 if (errorType == MEDIA_ERROR_INVALID_CODE) { |
| 226 return; | 227 return; |
| 227 } | 228 } |
| 228 | 229 |
| 229 mCurrentState = STATE_ERROR; | 230 mCurrentState = STATE_ERROR; |
| 230 | 231 |
| 231 if (ContentViewCore.activityFromContext(getContext()) == null) { | 232 if (WindowAndroid.activityFromContext(getContext()) == null) { |
| 232 Log.w(TAG, "Unable to show alert dialog because it requires an activ
ity context"); | 233 Log.w(TAG, "Unable to show alert dialog because it requires an activ
ity context"); |
| 233 return; | 234 return; |
| 234 } | 235 } |
| 235 | 236 |
| 236 /* Pop up an error dialog so the user knows that | 237 /* Pop up an error dialog so the user knows that |
| 237 * something bad has happened. Only try and pop up the dialog | 238 * something bad has happened. Only try and pop up the dialog |
| 238 * if we're attached to a window. When we're going away and no | 239 * if we're attached to a window. When we're going away and no |
| 239 * longer have a window, don't bother showing the user an error. | 240 * longer have a window, don't bother showing the user an error. |
| 240 * | 241 * |
| 241 * TODO(qinmin): We need to review whether this Dialog is OK with | 242 * TODO(qinmin): We need to review whether this Dialog is OK with |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 private native void nativeRequestMediaMetadata(long nativeContentVideoView); | 450 private native void nativeRequestMediaMetadata(long nativeContentVideoView); |
| 450 private native boolean nativeIsPlaying(long nativeContentVideoView); | 451 private native boolean nativeIsPlaying(long nativeContentVideoView); |
| 451 private native void nativeSetSurface(long nativeContentVideoView, Surface su
rface); | 452 private native void nativeSetSurface(long nativeContentVideoView, Surface su
rface); |
| 452 private native void nativeRecordFullscreenPlayback( | 453 private native void nativeRecordFullscreenPlayback( |
| 453 long nativeContentVideoView, boolean isVideoPortrait, boolean isOrie
ntationPortrait); | 454 long nativeContentVideoView, boolean isVideoPortrait, boolean isOrie
ntationPortrait); |
| 454 private native void nativeRecordExitFullscreenPlayback( | 455 private native void nativeRecordExitFullscreenPlayback( |
| 455 long nativeContentVideoView, boolean isOrientationPortrait, | 456 long nativeContentVideoView, boolean isOrientationPortrait, |
| 456 long playbackDurationBeforeOrientationChange, | 457 long playbackDurationBeforeOrientationChange, |
| 457 long playbackDurationAfterOrientationChange); | 458 long playbackDurationAfterOrientationChange); |
| 458 } | 459 } |
| OLD | NEW |