Skip to content

Commit

Permalink
bug fix - width and height was undefined after prepare.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtoshiro committed Jun 27, 2016
1 parent 5679d9b commit 37818d3
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* @version 2015.0527
* @since 1.0
*/
public class FullscreenVideoView extends RelativeLayout implements SurfaceHolder.Callback, OnPreparedListener, OnErrorListener, OnSeekCompleteListener, OnCompletionListener, OnInfoListener {
public class FullscreenVideoView extends RelativeLayout implements SurfaceHolder.Callback, OnPreparedListener, OnErrorListener, OnSeekCompleteListener, OnCompletionListener, OnInfoListener, OnVideoSizeChangedListener {

/**
* Debug Tag for use logging debug output to LogCat
Expand Down Expand Up @@ -277,6 +277,17 @@ public boolean onError(MediaPlayer mp, int what, int extra) {
return false;
}

@Override
public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
Log.d(TAG, "onVideoSizeChanged = " + width + " - " + height);

if (this.initialMovieWidth == 0 && this.initialMovieHeight == 0) {
initialMovieWidth = width;
initialMovieHeight = height;
resize();
}
}

/**
* Initializes the default configuration
*/
Expand Down Expand Up @@ -353,6 +364,7 @@ protected void prepare() throws IllegalStateException {
this.mediaPlayer.setOnErrorListener(this);
this.mediaPlayer.setOnSeekCompleteListener(this);
this.mediaPlayer.setOnInfoListener(this);
this.mediaPlayer.setOnVideoSizeChangedListener(this);
this.mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

this.currentState = State.PREPARING;
Expand Down Expand Up @@ -654,7 +666,6 @@ public void pause() throws IllegalStateException {
/**
* Due to a lack of access of SurfaceView, it rebuilds mediaPlayer and all
* views to update SurfaceView canvas
*
*/
public void reset() {
Log.d(TAG, "reset");
Expand Down

0 comments on commit 37818d3

Please sign in to comment.