| 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.Surface; | 14 import android.view.Surface; |
| 15 import android.view.SurfaceHolder; | 15 import android.view.SurfaceHolder; |
| 16 import android.view.SurfaceView; | 16 import android.view.SurfaceView; |
| 17 import android.view.View; | 17 import android.view.View; |
| 18 import android.view.ViewGroup; | 18 import android.view.ViewGroup; |
| 19 import android.view.WindowManager; | 19 import android.view.WindowManager; |
| 20 import android.widget.FrameLayout; | 20 import android.widget.FrameLayout; |
| 21 import android.widget.LinearLayout; | 21 import android.widget.LinearLayout; |
| 22 import android.widget.ProgressBar; | 22 import android.widget.ProgressBar; |
| 23 import android.widget.TextView; | 23 import android.widget.TextView; |
| 24 | 24 |
| 25 import org.chromium.base.Log; | 25 import org.chromium.base.Log; |
| 26 import org.chromium.base.ThreadUtils; | 26 import org.chromium.base.ThreadUtils; |
| 27 import org.chromium.base.annotations.CalledByNative; | 27 import org.chromium.base.annotations.CalledByNative; |
| 28 import org.chromium.base.annotations.JNINamespace; | 28 import org.chromium.base.annotations.JNINamespace; |
| 29 import org.chromium.ui.base.WindowAndroid; |
| 29 | 30 |
| 30 /** | 31 /** |
| 31 * This class implements accelerated fullscreen video playback using surface vie
w. | 32 * This class implements accelerated fullscreen video playback using surface vie
w. |
| 32 */ | 33 */ |
| 33 @JNINamespace("content") | 34 @JNINamespace("content") |
| 34 public class ContentVideoView extends FrameLayout | 35 public class ContentVideoView extends FrameLayout |
| 35 implements SurfaceHolder.Callback { | 36 implements SurfaceHolder.Callback { |
| 36 | 37 |
| 37 private static final String TAG = "cr.ContentVideoView"; | 38 private static final String TAG = "cr.ContentVideoView"; |
| 38 | 39 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 return; | 221 return; |
| 221 } | 222 } |
| 222 | 223 |
| 223 // Ignore some invalid error codes. | 224 // Ignore some invalid error codes. |
| 224 if (errorType == MEDIA_ERROR_INVALID_CODE) { | 225 if (errorType == MEDIA_ERROR_INVALID_CODE) { |
| 225 return; | 226 return; |
| 226 } | 227 } |
| 227 | 228 |
| 228 mCurrentState = STATE_ERROR; | 229 mCurrentState = STATE_ERROR; |
| 229 | 230 |
| 230 if (ContentViewCore.activityFromContext(getContext()) == null) { | 231 if (WindowAndroid.activityFromContext(getContext()) == null) { |
| 231 Log.w(TAG, "Unable to show alert dialog because it requires an activ
ity context"); | 232 Log.w(TAG, "Unable to show alert dialog because it requires an activ
ity context"); |
| 232 return; | 233 return; |
| 233 } | 234 } |
| 234 | 235 |
| 235 /* Pop up an error dialog so the user knows that | 236 /* Pop up an error dialog so the user knows that |
| 236 * something bad has happened. Only try and pop up the dialog | 237 * something bad has happened. Only try and pop up the dialog |
| 237 * if we're attached to a window. When we're going away and no | 238 * if we're attached to a window. When we're going away and no |
| 238 * longer have a window, don't bother showing the user an error. | 239 * longer have a window, don't bother showing the user an error. |
| 239 * | 240 * |
| 240 * TODO(qinmin): We need to review whether this Dialog is OK with | 241 * TODO(qinmin): We need to review whether this Dialog is OK with |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 private native void nativeRequestMediaMetadata(long nativeContentVideoView); | 436 private native void nativeRequestMediaMetadata(long nativeContentVideoView); |
| 436 private native boolean nativeIsPlaying(long nativeContentVideoView); | 437 private native boolean nativeIsPlaying(long nativeContentVideoView); |
| 437 private native void nativeSetSurface(long nativeContentVideoView, Surface su
rface); | 438 private native void nativeSetSurface(long nativeContentVideoView, Surface su
rface); |
| 438 private native void nativeRecordFullscreenPlayback( | 439 private native void nativeRecordFullscreenPlayback( |
| 439 long nativeContentVideoView, boolean isVideoPortrait, boolean isOrie
ntationPortrait); | 440 long nativeContentVideoView, boolean isVideoPortrait, boolean isOrie
ntationPortrait); |
| 440 private native void nativeRecordExitFullscreenPlayback( | 441 private native void nativeRecordExitFullscreenPlayback( |
| 441 long nativeContentVideoView, boolean isOrientationPortrait, | 442 long nativeContentVideoView, boolean isOrientationPortrait, |
| 442 long playbackDurationBeforeOrientationChange, | 443 long playbackDurationBeforeOrientationChange, |
| 443 long playbackDurationAfterOrientationChange); | 444 long playbackDurationAfterOrientationChange); |
| 444 } | 445 } |
| OLD | NEW |