|
51 | 51 | * @version 2015.0527 |
52 | 52 | * @since 1.0 |
53 | 53 | */ |
54 | | -public class FullscreenVideoView extends RelativeLayout implements SurfaceHolder.Callback, OnPreparedListener, OnErrorListener, OnSeekCompleteListener, OnCompletionListener, OnInfoListener { |
| 54 | +public class FullscreenVideoView extends RelativeLayout implements SurfaceHolder.Callback, OnPreparedListener, OnErrorListener, OnSeekCompleteListener, OnCompletionListener, OnInfoListener, OnVideoSizeChangedListener { |
55 | 55 |
|
56 | 56 | /** |
57 | 57 | * Debug Tag for use logging debug output to LogCat |
@@ -277,6 +277,17 @@ public boolean onError(MediaPlayer mp, int what, int extra) { |
277 | 277 | return false; |
278 | 278 | } |
279 | 279 |
|
| 280 | + @Override |
| 281 | + public void onVideoSizeChanged(MediaPlayer mp, int width, int height) { |
| 282 | + Log.d(TAG, "onVideoSizeChanged = " + width + " - " + height); |
| 283 | + |
| 284 | + if (this.initialMovieWidth == 0 && this.initialMovieHeight == 0) { |
| 285 | + initialMovieWidth = width; |
| 286 | + initialMovieHeight = height; |
| 287 | + resize(); |
| 288 | + } |
| 289 | + } |
| 290 | + |
280 | 291 | /** |
281 | 292 | * Initializes the default configuration |
282 | 293 | */ |
@@ -353,6 +364,7 @@ protected void prepare() throws IllegalStateException { |
353 | 364 | this.mediaPlayer.setOnErrorListener(this); |
354 | 365 | this.mediaPlayer.setOnSeekCompleteListener(this); |
355 | 366 | this.mediaPlayer.setOnInfoListener(this); |
| 367 | + this.mediaPlayer.setOnVideoSizeChangedListener(this); |
356 | 368 | this.mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); |
357 | 369 |
|
358 | 370 | this.currentState = State.PREPARING; |
@@ -654,7 +666,6 @@ public void pause() throws IllegalStateException { |
654 | 666 | /** |
655 | 667 | * Due to a lack of access of SurfaceView, it rebuilds mediaPlayer and all |
656 | 668 | * views to update SurfaceView canvas |
657 | | - * |
658 | 669 | */ |
659 | 670 | public void reset() { |
660 | 671 | Log.d(TAG, "reset"); |
|
0 commit comments