yqritc / Android-ScalableVideoView

Android Texture VideoView having a variety of scale types like the scale types of ImageView such as fitCenter, centerCrop, centerTopCrop and more
Apache License 2.0
1.09k stars 223 forks source link

Added ability to set MediaPlayer.OnErrorListener in prepare() and prepareAsync() #6

Closed oleynikd closed 8 years ago

oleynikd commented 9 years ago

Now you can set OnErrorListener in prepare() and prepareAsync() methods:

mVideoView.prepareAsync(new MediaPlayer.OnPreparedListener() {
    @Override
    public void onPrepared(MediaPlayer mp) {
        Log.v("mVideoView", "onPrepared");
    }
}, new MediaPlayer.OnErrorListener() {
    @Override
    public boolean onError(MediaPlayer mp, int what, int extra) {
        Log.e("mVideoView", "Error: " + waht);
        return false;
    }
});

Basically added 2 new methods:

public void prepare(@Nullable MediaPlayer.OnPreparedListener listener, @Nullable MediaPlayer.OnErrorListener eListener)
            throws IOException, IllegalStateException

public void prepareAsync(@Nullable MediaPlayer.OnPreparedListener listener, @Nullable MediaPlayer.OnErrorListener eListener)
            throws IllegalStateException
yqritc commented 9 years ago

@oleynikd Thanks for PR. I'm welcome to add an ability to set error listener, but I prefer to define it as separate method like the following.

public void setOnErrorListener(@Nullable MediaPlayer.OnErrorListener listener) {
    mMediaPlayer.setOnErrorListener(listener);
}

Please tell me if u have any trouble with this.

yqritc commented 8 years ago

I just published ver 1.0.2, which has setOnErrorListener.