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

Side by Side 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, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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.Activity; 7 import android.app.Activity;
8 import android.app.AlertDialog; 8 import android.app.AlertDialog;
9 import android.content.Context; 9 import android.content.Context;
10 import android.content.DialogInterface; 10 import android.content.DialogInterface;
(...skipping 20 matching lines...) Expand all
31 31
32 import org.chromium.base.CalledByNative; 32 import org.chromium.base.CalledByNative;
33 import org.chromium.base.JNINamespace; 33 import org.chromium.base.JNINamespace;
34 import org.chromium.base.ThreadUtils; 34 import org.chromium.base.ThreadUtils;
35 import org.chromium.content.common.IChildProcessService; 35 import org.chromium.content.common.IChildProcessService;
36 import org.chromium.content.R; 36 import org.chromium.content.R;
37 37
38 @JNINamespace("content") 38 @JNINamespace("content")
39 public class ContentVideoView 39 public class ContentVideoView
40 extends FrameLayout 40 extends FrameLayout
41 implements ContentVideoViewControls.Delegate, 41 implements SurfaceHolder.Callback {
42 SurfaceHolder.Callback, View.OnTouchListener, View.OnKeyListener {
43 42
44 private static final String TAG = "ContentVideoView"; 43 private static final String TAG = "ContentVideoView";
45 44
46 /* Do not change these values without updating their counterparts 45 /* Do not change these values without updating their counterparts
47 * in include/media/mediaplayer.h! 46 * in include/media/mediaplayer.h!
48 */ 47 */
49 private static final int MEDIA_NOP = 0; // interface test message 48 private static final int MEDIA_NOP = 0; // interface test message
50 private static final int MEDIA_PREPARED = 1; 49 private static final int MEDIA_PREPARED = 1;
51 private static final int MEDIA_PLAYBACK_COMPLETE = 2; 50 private static final int MEDIA_PLAYBACK_COMPLETE = 2;
52 private static final int MEDIA_BUFFERING_UPDATE = 3; 51 private static final int MEDIA_BUFFERING_UPDATE = 3;
(...skipping 14 matching lines...) Expand all
67 private static final int STATE_IDLE = 0; 66 private static final int STATE_IDLE = 0;
68 private static final int STATE_PLAYING = 1; 67 private static final int STATE_PLAYING = 1;
69 private static final int STATE_PAUSED = 2; 68 private static final int STATE_PAUSED = 2;
70 private static final int STATE_PLAYBACK_COMPLETED = 3; 69 private static final int STATE_PLAYBACK_COMPLETED = 3;
71 70
72 private SurfaceHolder mSurfaceHolder; 71 private SurfaceHolder mSurfaceHolder;
73 private int mVideoWidth; 72 private int mVideoWidth;
74 private int mVideoHeight; 73 private int mVideoHeight;
75 private int mCurrentBufferPercentage; 74 private int mCurrentBufferPercentage;
76 private int mDuration; 75 private int mDuration;
77 private ContentVideoViewControls mControls;
78 private boolean mCanPause; 76 private boolean mCanPause;
79 private boolean mCanSeekBack; 77 private boolean mCanSeekBack;
80 private boolean mCanSeekForward; 78 private boolean mCanSeekForward;
81 79
82 // Native pointer to C++ ContentVideoView object. 80 // Native pointer to C++ ContentVideoView object.
83 private int mNativeContentVideoView; 81 private int mNativeContentVideoView;
84 82
85 // webkit should have prepared the media 83 // webkit should have prepared the media
86 private int mCurrentState = STATE_IDLE; 84 private int mCurrentState = STATE_IDLE;
87 85
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 LinearLayout.LayoutParams.WRAP_CONTENT, 137 LinearLayout.LayoutParams.WRAP_CONTENT,
140 LinearLayout.LayoutParams.WRAP_CONTENT)); 138 LinearLayout.LayoutParams.WRAP_CONTENT));
141 mProgressBar = new ProgressBar(context, null, android.R.attr.progres sBarStyleLarge); 139 mProgressBar = new ProgressBar(context, null, android.R.attr.progres sBarStyleLarge);
142 mTextView = new TextView(context); 140 mTextView = new TextView(context);
143 mTextView.setText(videoLoadingText); 141 mTextView.setText(videoLoadingText);
144 addView(mProgressBar); 142 addView(mProgressBar);
145 addView(mTextView); 143 addView(mTextView);
146 } 144 }
147 } 145 }
148 146
149 private static class FullScreenControls implements ContentVideoViewControls {
150
151 View mVideoView;
152 MediaController mMediaController;
153
154 public FullScreenControls(Context context, View video) {
155 mMediaController = new MediaController(context);
156 mVideoView = video;
157 }
158
159 @Override
160 public void show() {
161 mMediaController.show();
162 if (mVideoView != null) {
163 mVideoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
164 }
165 }
166
167 @Override
168 public void show(int timeout_ms) {
169 mMediaController.show(timeout_ms);
170 }
171
172 @Override
173 public void hide() {
174 if (mVideoView != null) {
175 mVideoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE );
176 }
177 mMediaController.hide();
178 }
179
180 @Override
181 public boolean isShowing() {
182 return mMediaController.isShowing();
183 }
184
185 @Override
186 public void setEnabled(boolean enabled) {
187 mMediaController.setEnabled(enabled);
188 }
189
190 @Override
191 public void setDelegate(Delegate delegate) {
192 mMediaController.setMediaPlayer(delegate);
193 }
194
195 @Override
196 public void setAnchorView(View view) {
197 mMediaController.setAnchorView(view);
198 }
199 }
200
201 private Runnable mExitFullscreenRunnable = new Runnable() { 147 private Runnable mExitFullscreenRunnable = new Runnable() {
202 @Override 148 @Override
203 public void run() { 149 public void run() {
204 exitFullscreen(true); 150 exitFullscreen(true);
205 } 151 }
206 }; 152 };
207 153
208 private ContentVideoView(Context context, int nativeContentVideoView, 154 private ContentVideoView(Context context, int nativeContentVideoView,
209 ContentVideoViewClient client) { 155 ContentVideoViewClient client) {
210 super(context); 156 super(context);
211 mNativeContentVideoView = nativeContentVideoView; 157 mNativeContentVideoView = nativeContentVideoView;
212 mClient = client; 158 mClient = client;
213 initResources(context); 159 initResources(context);
214 mCurrentBufferPercentage = 0; 160 mCurrentBufferPercentage = 0;
215 mVideoSurfaceView = new VideoSurfaceView(context); 161 mVideoSurfaceView = new VideoSurfaceView(context);
216 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
217 showContentVideoView(); 162 showContentVideoView();
218 setVisibility(View.VISIBLE); 163 setVisibility(View.VISIBLE);
219 mClient.onShowCustomView(this); 164 mClient.onShowCustomView(this);
220 } 165 }
221 166
222 private void initResources(Context context) { 167 private void initResources(Context context) {
223 if (mPlaybackErrorText != null) return; 168 if (mPlaybackErrorText != null) return;
224 mPlaybackErrorText = context.getString( 169 mPlaybackErrorText = context.getString(
225 org.chromium.content.R.string.media_player_error_text_invalid_pr ogressive_playback); 170 org.chromium.content.R.string.media_player_error_text_invalid_pr ogressive_playback);
226 mUnknownErrorText = context.getString( 171 mUnknownErrorText = context.getString(
(...skipping 12 matching lines...) Expand all
239 ViewGroup.LayoutParams.WRAP_CONTENT, 184 ViewGroup.LayoutParams.WRAP_CONTENT,
240 Gravity.CENTER); 185 Gravity.CENTER);
241 this.addView(mVideoSurfaceView, layoutParams); 186 this.addView(mVideoSurfaceView, layoutParams);
242 View progressView = mClient.getVideoLoadingProgressView(); 187 View progressView = mClient.getVideoLoadingProgressView();
243 if (progressView != null) { 188 if (progressView != null) {
244 mProgressView = progressView; 189 mProgressView = progressView;
245 } else { 190 } else {
246 mProgressView = new ProgressView(getContext(), mVideoLoadingText); 191 mProgressView = new ProgressView(getContext(), mVideoLoadingText);
247 } 192 }
248 this.addView(mProgressView, layoutParams); 193 this.addView(mProgressView, layoutParams);
249 mVideoSurfaceView.setZOrderOnTop(true);
250 mVideoSurfaceView.setOnKeyListener(this);
251 mVideoSurfaceView.setOnTouchListener(this);
252 mVideoSurfaceView.getHolder().addCallback(this); 194 mVideoSurfaceView.getHolder().addCallback(this);
253 mVideoSurfaceView.setFocusable(true); 195 mVideoSurfaceView.setFocusable(true);
254 mVideoSurfaceView.setFocusableInTouchMode(true); 196 mVideoSurfaceView.setFocusableInTouchMode(true);
255 mVideoSurfaceView.requestFocus(); 197 mVideoSurfaceView.requestFocus();
256 } 198 }
257 199
258 @CalledByNative 200 @CalledByNative
259 public void onMediaPlayerError(int errorType) { 201 public void onMediaPlayerError(int errorType) {
260 Log.d(TAG, "OnMediaPlayerError: " + errorType); 202 Log.d(TAG, "OnMediaPlayerError: " + errorType);
261 if (mCurrentState == STATE_ERROR || mCurrentState == STATE_PLAYBACK_COMP LETED) { 203 if (mCurrentState == STATE_ERROR || mCurrentState == STATE_PLAYBACK_COMP LETED) {
262 return; 204 return;
263 } 205 }
264 206
265 // Ignore some invalid error codes. 207 // Ignore some invalid error codes.
266 if (errorType == MEDIA_ERROR_INVALID_CODE) { 208 if (errorType == MEDIA_ERROR_INVALID_CODE) {
267 return; 209 return;
268 } 210 }
269 211
270 mCurrentState = STATE_ERROR; 212 mCurrentState = STATE_ERROR;
271 if (mControls != null) {
272 mControls.hide();
273 }
274 213
275 /* Pop up an error dialog so the user knows that 214 /* Pop up an error dialog so the user knows that
276 * something bad has happened. Only try and pop up the dialog 215 * something bad has happened. Only try and pop up the dialog
277 * if we're attached to a window. When we're going away and no 216 * if we're attached to a window. When we're going away and no
278 * longer have a window, don't bother showing the user an error. 217 * longer have a window, don't bother showing the user an error.
279 * 218 *
280 * TODO(qinmin): We need to review whether this Dialog is OK with 219 * TODO(qinmin): We need to review whether this Dialog is OK with
281 * the rest of the browser UI elements. 220 * the rest of the browser UI elements.
282 */ 221 */
283 if (getWindowToken() != null) { 222 if (getWindowToken() != null) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 int videoHeight, 269 int videoHeight,
331 int duration, 270 int duration,
332 boolean canPause, 271 boolean canPause,
333 boolean canSeekBack, 272 boolean canSeekBack,
334 boolean canSeekForward) { 273 boolean canSeekForward) {
335 mProgressView.setVisibility(View.GONE); 274 mProgressView.setVisibility(View.GONE);
336 mDuration = duration; 275 mDuration = duration;
337 mCanPause = canPause; 276 mCanPause = canPause;
338 mCanSeekBack = canSeekBack; 277 mCanSeekBack = canSeekBack;
339 mCanSeekForward = canSeekForward; 278 mCanSeekForward = canSeekForward;
340 mCurrentState = isPlaying() ? STATE_PLAYING : STATE_PAUSED; 279 mCurrentState = nativeIsPlaying(mNativeContentVideoView) ? STATE_PLAYING : STATE_PAUSED;
341 if (mControls != null) {
342 mControls.setEnabled(true);
343 // If paused , should show the controller for ever.
344 if (isPlaying())
345 mControls.show();
346 else
347 mControls.show(0);
348 }
349 280
350 onVideoSizeChanged(videoWidth, videoHeight); 281 onVideoSizeChanged(videoWidth, videoHeight);
351 } 282 }
352 283
353 @Override 284 @Override
354 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { 285 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
355 mVideoSurfaceView.setFocusable(true); 286 mVideoSurfaceView.setFocusable(true);
356 mVideoSurfaceView.setFocusableInTouchMode(true); 287 mVideoSurfaceView.setFocusableInTouchMode(true);
357 if (isInPlaybackState() && mControls != null) {
358 mControls.show();
359 }
360 } 288 }
361 289
362 @Override 290 @Override
363 public void surfaceCreated(SurfaceHolder holder) { 291 public void surfaceCreated(SurfaceHolder holder) {
364 mSurfaceHolder = holder; 292 mSurfaceHolder = holder;
365 openVideo(); 293 openVideo();
366 } 294 }
367 295
368 @Override 296 @Override
369 public void surfaceDestroyed(SurfaceHolder holder) { 297 public void surfaceDestroyed(SurfaceHolder holder) {
370 if (mNativeContentVideoView != 0) { 298 if (mNativeContentVideoView != 0) {
371 nativeSetSurface(mNativeContentVideoView, null); 299 nativeSetSurface(mNativeContentVideoView, null);
372 } 300 }
373 mSurfaceHolder = null; 301 mSurfaceHolder = null;
374 post(mExitFullscreenRunnable); 302 post(mExitFullscreenRunnable);
375 } 303 }
376 304
377 private void setControls(ContentVideoViewControls controls) {
378 if (mControls != null) {
379 mControls.hide();
380 }
381 mControls = controls;
382 attachControls();
383 }
384
385 private void attachControls() {
386 if (mControls != null) {
387 mControls.setDelegate(this);
388 mControls.setAnchorView(mVideoSurfaceView);
389 mControls.setEnabled(false);
390 }
391 }
392
393 @CalledByNative 305 @CalledByNative
394 private void openVideo() { 306 private void openVideo() {
395 if (mSurfaceHolder != null) { 307 if (mSurfaceHolder != null) {
396 mCurrentState = STATE_IDLE; 308 mCurrentState = STATE_IDLE;
397 mCurrentBufferPercentage = 0; 309 mCurrentBufferPercentage = 0;
398 ContentVideoViewControls controls = mClient.createControls();
399 if (controls == null) {
400 controls = new FullScreenControls(getContext(), this);
401 }
402 setControls(controls);
403 if (mNativeContentVideoView != 0) { 310 if (mNativeContentVideoView != 0) {
404 nativeUpdateMediaMetadata(mNativeContentVideoView); 311 nativeUpdateMediaMetadata(mNativeContentVideoView);
405 nativeSetSurface(mNativeContentVideoView, 312 nativeSetSurface(mNativeContentVideoView,
406 mSurfaceHolder.getSurface()); 313 mSurfaceHolder.getSurface());
407 } 314 }
408 } 315 }
409 } 316 }
410 317
411 private void onCompletion() { 318 private void onCompletion() {
412 mCurrentState = STATE_PLAYBACK_COMPLETED; 319 mCurrentState = STATE_PLAYBACK_COMPLETED;
413 if (mControls != null) {
414 mControls.hide();
415 }
416 }
417
418 @Override
419 public boolean onTouch(View v, MotionEvent event) {
420 if (isInPlaybackState() && mControls != null &&
421 event.getAction() == MotionEvent.ACTION_DOWN) {
422 toggleMediaControlsVisiblity();
423 }
424 return true;
425 }
426
427 @Override
428 public boolean onTrackballEvent(MotionEvent ev) {
429 if (isInPlaybackState() && mControls != null) {
430 toggleMediaControlsVisiblity();
431 }
432 return false;
433 }
434
435 @Override
436 public boolean onKey(View v, int keyCode, KeyEvent event) {
437 boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK &&
438 keyCode != KeyEvent.KEYCODE_VOLUME_UP &&
439 keyCode != KeyEvent.KEYCODE_VOLUME_DOWN &&
440 keyCode != KeyEvent.KEYCODE_VOLUME_MUTE &&
441 keyCode != KeyEvent.KEYCODE_CALL &&
442 keyCode != KeyEvent.KEYCODE_MENU &&
443 keyCode != KeyEvent.KEYCODE_SEARCH &&
444 keyCode != KeyEvent.KEYCODE_ENDCALL;
445 if (isInPlaybackState() && isKeyCodeSupported && mControls != null) {
446 if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
447 keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
448 if (isPlaying()) {
449 pause();
450 mControls.show();
451 } else {
452 start();
453 mControls.hide();
454 }
455 return true;
456 } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
457 if (!isPlaying()) {
458 start();
459 mControls.hide();
460 }
461 return true;
462 } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
463 || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
464 if (isPlaying()) {
465 pause();
466 mControls.show();
467 }
468 return true;
469 } else {
470 toggleMediaControlsVisiblity();
471 }
472 } else if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyE vent.ACTION_UP) {
473 exitFullscreen(false);
474 return true;
475 } else if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCO DE_SEARCH) {
476 return true;
477 }
478 return super.onKeyDown(keyCode, event);
479 }
480
481 private void toggleMediaControlsVisiblity() {
482 if (mControls.isShowing()) {
483 mControls.hide();
484 } else {
485 mControls.show();
486 }
487 } 320 }
488 321
489 private boolean isInPlaybackState() { 322 private boolean isInPlaybackState() {
490 return (mCurrentState != STATE_ERROR && mCurrentState != STATE_IDLE); 323 return (mCurrentState != STATE_ERROR && mCurrentState != STATE_IDLE);
491 } 324 }
492 325
493 @Override
494 public void start() {
495 if (isInPlaybackState()) {
496 if (mNativeContentVideoView != 0) {
497 nativePlay(mNativeContentVideoView);
498 }
499 mCurrentState = STATE_PLAYING;
500 }
501 }
502
503 @Override
504 public void pause() {
505 if (isInPlaybackState()) {
506 if (isPlaying()) {
507 if (mNativeContentVideoView != 0) {
508 nativePause(mNativeContentVideoView);
509 }
510 mCurrentState = STATE_PAUSED;
511 }
512 }
513 }
514
515 // cache duration as mDuration for faster access
516 @Override
517 public int getDuration() {
518 if (isInPlaybackState()) {
519 if (mDuration > 0) {
520 return mDuration;
521 }
522 if (mNativeContentVideoView != 0) {
523 mDuration = nativeGetDurationInMilliSeconds(mNativeContentVideoV iew);
524 } else {
525 mDuration = 0;
526 }
527 return mDuration;
528 }
529 mDuration = -1;
530 return mDuration;
531 }
532
533 @Override
534 public int getCurrentPosition() {
535 if (isInPlaybackState() && mNativeContentVideoView != 0) {
536 return nativeGetCurrentPosition(mNativeContentVideoView);
537 }
538 return 0;
539 }
540
541 @Override
542 public void seekTo(int msec) {
543 if (mNativeContentVideoView != 0) {
544 nativeSeekTo(mNativeContentVideoView, msec);
545 }
546 }
547
548 @Override
549 public boolean isPlaying() {
550 return mNativeContentVideoView != 0 && nativeIsPlaying(mNativeContentVid eoView);
551 }
552
553 @Override
554 public int getBufferPercentage() {
555 return mCurrentBufferPercentage;
556 }
557
558 @Override
559 public boolean canPause() {
560 return mCanPause;
561 }
562
563 @Override
564 public boolean canSeekBackward() {
565 return mCanSeekBack;
566 }
567
568 @Override
569 public boolean canSeekForward() {
570 return mCanSeekForward;
571 }
572
573 public int getAudioSessionId() { 326 public int getAudioSessionId() {
574 return 0; 327 return 0;
575 } 328 }
576 329
577 @CalledByNative 330 @CalledByNative
578 private static ContentVideoView createContentVideoView( 331 private static ContentVideoView createContentVideoView(
579 Context context, int nativeContentVideoView, ContentVideoViewClient client) { 332 Context context, int nativeContentVideoView, ContentVideoViewClient client) {
580 ThreadUtils.assertOnUiThread(); 333 ThreadUtils.assertOnUiThread();
581 // The context needs be Activity to create the ContentVideoView correctl y. 334 // The context needs be Activity to create the ContentVideoView correctl y.
582 if (!(context instanceof Activity)) { 335 if (!(context instanceof Activity)) {
583 Log.w(TAG, "Wrong type of context, can't create fullscreen video"); 336 Log.w(TAG, "Wrong type of context, can't create fullscreen video");
584 return null; 337 return null;
585 } 338 }
586 return new ContentVideoView(context, nativeContentVideoView, client); 339 return new ContentVideoView(context, nativeContentVideoView, client);
587 } 340 }
588 341
589 private void removeControls() {
590 if (mControls != null) {
591 mControls.setEnabled(false);
592 mControls.hide();
593 mControls = null;
594 }
595 }
596
597 public void removeSurfaceView() { 342 public void removeSurfaceView() {
598 removeView(mVideoSurfaceView); 343 removeView(mVideoSurfaceView);
599 removeView(mProgressView); 344 removeView(mProgressView);
600 mVideoSurfaceView = null; 345 mVideoSurfaceView = null;
601 mProgressView = null; 346 mProgressView = null;
602 } 347 }
603 348
604 public void exitFullscreen(boolean relaseMediaPlayer) { 349 public void exitFullscreen(boolean relaseMediaPlayer) {
605 destroyContentVideoView(false); 350 destroyContentVideoView(false);
606 if (mNativeContentVideoView != 0) { 351 if (mNativeContentVideoView != 0) {
607 nativeExitFullscreen(mNativeContentVideoView, relaseMediaPlayer); 352 nativeExitFullscreen(mNativeContentVideoView, relaseMediaPlayer);
608 mNativeContentVideoView = 0; 353 mNativeContentVideoView = 0;
609 } 354 }
610 } 355 }
611 356
612 /** 357 /**
613 * This method shall only be called by native and exitFullscreen, 358 * This method shall only be called by native and exitFullscreen,
614 * To exit fullscreen, use exitFullscreen in Java. 359 * To exit fullscreen, use exitFullscreen in Java.
615 */ 360 */
616 @CalledByNative 361 @CalledByNative
617 private void destroyContentVideoView(boolean nativeViewDestroyed) { 362 private void destroyContentVideoView(boolean nativeViewDestroyed) {
618 if (mVideoSurfaceView != null) { 363 if (mVideoSurfaceView != null) {
619 mClient.onDestroyContentVideoView(); 364 mClient.onDestroyContentVideoView();
620 removeControls();
621 removeSurfaceView(); 365 removeSurfaceView();
622 setVisibility(View.GONE); 366 setVisibility(View.GONE);
623 } 367 }
624 if (nativeViewDestroyed) { 368 if (nativeViewDestroyed) {
625 mNativeContentVideoView = 0; 369 mNativeContentVideoView = 0;
626 } 370 }
627 } 371 }
628 372
629 public static ContentVideoView getContentVideoView() { 373 public static ContentVideoView getContentVideoView() {
630 return nativeGetSingletonJavaContentVideoView(); 374 return nativeGetSingletonJavaContentVideoView();
631 } 375 }
632 376
633 @Override 377 @Override
634 public boolean onTouchEvent(MotionEvent ev) {
635 return true;
636 }
637
638 @Override
639 public boolean onKeyDown(int keyCode, KeyEvent event) { 378 public boolean onKeyDown(int keyCode, KeyEvent event) {
640 if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.AC TION_UP) { 379 if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.AC TION_UP) {
641 exitFullscreen(false); 380 exitFullscreen(false);
642 return true; 381 return true;
643 } 382 }
644 return super.onKeyDown(keyCode, event); 383 return super.onKeyDown(keyCode, event);
645 } 384 }
646 385
647 private static native ContentVideoView nativeGetSingletonJavaContentVideoVie w(); 386 private static native ContentVideoView nativeGetSingletonJavaContentVideoVie w();
648 private native void nativeExitFullscreen(int nativeContentVideoView, boolean relaseMediaPlayer); 387 private native void nativeExitFullscreen(int nativeContentVideoView, boolean relaseMediaPlayer);
649 private native int nativeGetCurrentPosition(int nativeContentVideoView); 388 private native int nativeGetCurrentPosition(int nativeContentVideoView);
650 private native int nativeGetDurationInMilliSeconds(int nativeContentVideoVie w); 389 private native int nativeGetDurationInMilliSeconds(int nativeContentVideoVie w);
651 private native void nativeUpdateMediaMetadata(int nativeContentVideoView); 390 private native void nativeUpdateMediaMetadata(int nativeContentVideoView);
652 private native int nativeGetVideoWidth(int nativeContentVideoView); 391 private native int nativeGetVideoWidth(int nativeContentVideoView);
653 private native int nativeGetVideoHeight(int nativeContentVideoView); 392 private native int nativeGetVideoHeight(int nativeContentVideoView);
654 private native boolean nativeIsPlaying(int nativeContentVideoView); 393 private native boolean nativeIsPlaying(int nativeContentVideoView);
655 private native void nativePause(int nativeContentVideoView); 394 private native void nativePause(int nativeContentVideoView);
656 private native void nativePlay(int nativeContentVideoView); 395 private native void nativePlay(int nativeContentVideoView);
657 private native void nativeSeekTo(int nativeContentVideoView, int msec); 396 private native void nativeSeekTo(int nativeContentVideoView, int msec);
658 private native void nativeSetSurface(int nativeContentVideoView, Surface sur face); 397 private native void nativeSetSurface(int nativeContentVideoView, Surface sur face);
659 } 398 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698