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

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

Issue 56443002: Fix an issue that mediaplayer can return size(0,0) for a valid video (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use MATCH_PARENT Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/renderer/media/android/webmediaplayer_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 private ContentVideoViewClient mClient; 103 private ContentVideoViewClient mClient;
104 104
105 private class VideoSurfaceView extends SurfaceView { 105 private class VideoSurfaceView extends SurfaceView {
106 106
107 public VideoSurfaceView(Context context) { 107 public VideoSurfaceView(Context context) {
108 super(context); 108 super(context);
109 } 109 }
110 110
111 @Override 111 @Override
112 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 112 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
113 if (mVideoWidth == 0 && mVideoHeight == 0) {
114 setMeasuredDimension(1, 1);
115 return;
116 }
117 int width = getDefaultSize(mVideoWidth, widthMeasureSpec); 113 int width = getDefaultSize(mVideoWidth, widthMeasureSpec);
118 int height = getDefaultSize(mVideoHeight, heightMeasureSpec); 114 int height = getDefaultSize(mVideoHeight, heightMeasureSpec);
119 if (mVideoWidth > 0 && mVideoHeight > 0) { 115 if (mVideoWidth > 0 && mVideoHeight > 0) {
120 if ( mVideoWidth * height > width * mVideoHeight ) { 116 if ( mVideoWidth * height > width * mVideoHeight ) {
121 height = width * mVideoHeight / mVideoWidth; 117 height = width * mVideoHeight / mVideoWidth;
122 } else if ( mVideoWidth * height < width * mVideoHeight ) { 118 } else if ( mVideoWidth * height < width * mVideoHeight ) {
123 width = height * mVideoWidth / mVideoHeight; 119 width = height * mVideoWidth / mVideoHeight;
124 } 120 }
125 } 121 }
126 setMeasuredDimension(width, height); 122 setMeasuredDimension(width, height);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 mErrorButton = context.getString( 224 mErrorButton = context.getString(
229 org.chromium.content.R.string.media_player_error_button); 225 org.chromium.content.R.string.media_player_error_button);
230 mErrorTitle = context.getString( 226 mErrorTitle = context.getString(
231 org.chromium.content.R.string.media_player_error_title); 227 org.chromium.content.R.string.media_player_error_title);
232 mVideoLoadingText = context.getString( 228 mVideoLoadingText = context.getString(
233 org.chromium.content.R.string.media_player_loading_video); 229 org.chromium.content.R.string.media_player_loading_video);
234 } 230 }
235 231
236 private void showContentVideoView() { 232 private void showContentVideoView() {
237 FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( 233 FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
238 ViewGroup.LayoutParams.WRAP_CONTENT, 234 ViewGroup.LayoutParams.MATCH_PARENT,
239 ViewGroup.LayoutParams.WRAP_CONTENT, 235 ViewGroup.LayoutParams.MATCH_PARENT,
240 Gravity.CENTER); 236 Gravity.CENTER);
241 this.addView(mVideoSurfaceView, layoutParams); 237 this.addView(mVideoSurfaceView, layoutParams);
242 View progressView = mClient.getVideoLoadingProgressView(); 238 View progressView = mClient.getVideoLoadingProgressView();
243 if (progressView != null) { 239 if (progressView != null) {
244 mProgressView = progressView; 240 mProgressView = progressView;
245 } else { 241 } else {
246 mProgressView = new ProgressView(getContext(), mVideoLoadingText); 242 mProgressView = new ProgressView(getContext(), mVideoLoadingText);
247 } 243 }
248 this.addView(mProgressView, layoutParams); 244 this.addView(mProgressView, new FrameLayout.LayoutParams(
245 ViewGroup.LayoutParams.WRAP_CONTENT,
246 ViewGroup.LayoutParams.WRAP_CONTENT,
247 Gravity.CENTER));
249 mVideoSurfaceView.setZOrderOnTop(true); 248 mVideoSurfaceView.setZOrderOnTop(true);
250 mVideoSurfaceView.setOnKeyListener(this); 249 mVideoSurfaceView.setOnKeyListener(this);
251 mVideoSurfaceView.setOnTouchListener(this); 250 mVideoSurfaceView.setOnTouchListener(this);
252 mVideoSurfaceView.getHolder().addCallback(this); 251 mVideoSurfaceView.getHolder().addCallback(this);
253 mVideoSurfaceView.setFocusable(true); 252 mVideoSurfaceView.setFocusable(true);
254 mVideoSurfaceView.setFocusableInTouchMode(true); 253 mVideoSurfaceView.setFocusableInTouchMode(true);
255 mVideoSurfaceView.requestFocus(); 254 mVideoSurfaceView.requestFocus();
256 } 255 }
257 256
258 @CalledByNative 257 @CalledByNative
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 }) 301 })
303 .setCancelable(false) 302 .setCancelable(false)
304 .show(); 303 .show();
305 } 304 }
306 } 305 }
307 306
308 @CalledByNative 307 @CalledByNative
309 private void onVideoSizeChanged(int width, int height) { 308 private void onVideoSizeChanged(int width, int height) {
310 mVideoWidth = width; 309 mVideoWidth = width;
311 mVideoHeight = height; 310 mVideoHeight = height;
312 if (mVideoWidth != 0 && mVideoHeight != 0) { 311 // This will trigger the SurfaceView.onMeasure() call.
313 mVideoSurfaceView.getHolder().setFixedSize(mVideoWidth, mVideoHeight ); 312 mVideoSurfaceView.getHolder().setFixedSize(mVideoWidth, mVideoHeight);
314 }
315 } 313 }
316 314
317 @CalledByNative 315 @CalledByNative
318 private void onBufferingUpdate(int percent) { 316 private void onBufferingUpdate(int percent) {
319 mCurrentBufferPercentage = percent; 317 mCurrentBufferPercentage = percent;
320 } 318 }
321 319
322 @CalledByNative 320 @CalledByNative
323 private void onPlaybackComplete() { 321 private void onPlaybackComplete() {
324 onCompletion(); 322 onCompletion();
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 private native int nativeGetDurationInMilliSeconds(int nativeContentVideoVie w); 650 private native int nativeGetDurationInMilliSeconds(int nativeContentVideoVie w);
653 private native void nativeUpdateMediaMetadata(int nativeContentVideoView); 651 private native void nativeUpdateMediaMetadata(int nativeContentVideoView);
654 private native int nativeGetVideoWidth(int nativeContentVideoView); 652 private native int nativeGetVideoWidth(int nativeContentVideoView);
655 private native int nativeGetVideoHeight(int nativeContentVideoView); 653 private native int nativeGetVideoHeight(int nativeContentVideoView);
656 private native boolean nativeIsPlaying(int nativeContentVideoView); 654 private native boolean nativeIsPlaying(int nativeContentVideoView);
657 private native void nativePause(int nativeContentVideoView); 655 private native void nativePause(int nativeContentVideoView);
658 private native void nativePlay(int nativeContentVideoView); 656 private native void nativePlay(int nativeContentVideoView);
659 private native void nativeSeekTo(int nativeContentVideoView, int msec); 657 private native void nativeSeekTo(int nativeContentVideoView, int msec);
660 private native void nativeSetSurface(int nativeContentVideoView, Surface sur face); 658 private native void nativeSetSurface(int nativeContentVideoView, Surface sur face);
661 } 659 }
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/android/webmediaplayer_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698