Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Add method which set OnSeekCompleteListener callback #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnInfoListener;
import android.media.MediaPlayer.OnSeekCompleteListener;
import android.net.Uri;
import android.opengl.GLES20;
import android.os.Build;
Expand Down Expand Up @@ -106,6 +107,7 @@ public class TextureVideoView extends TextureView
private int mVideoWidth;
private int mVideoHeight;
private MediaController mMediaController;
private OnSeekCompleteListener mOnSeekCompleteListener;
private OnCompletionListener mOnCompletionListener;
private MediaPlayer.OnPreparedListener mOnPreparedListener;
private int mCurrentBufferPercentage;
Expand Down Expand Up @@ -340,6 +342,7 @@ private void openVideo() {
}
mMediaPlayer.setOnPreparedListener(mPreparedListener);
mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
mMediaPlayer.setOnSeekCompleteListener(mOnSeekCompleteListener);
mMediaPlayer.setOnCompletionListener(mCompletionListener);
mMediaPlayer.setOnErrorListener(mErrorListener);
mMediaPlayer.setOnInfoListener(mInfoListener);
Expand Down Expand Up @@ -446,6 +449,15 @@ public void onPrepared(MediaPlayer mp) {
}
};

private MediaPlayer.OnSeekCompleteListener mSeekCompleteListener =
new MediaPlayer.OnSeekCompleteListener() {
public void onSeekComplete(MediaPlayer mp) {
if (mOnSeekCompleteListener != null) {
mOnSeekCompleteListener.onSeekComplete(mMediaPlayer);
}
}
};

private MediaPlayer.OnCompletionListener mCompletionListener =
new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
Expand Down Expand Up @@ -540,6 +552,16 @@ public void setOnPreparedListener(MediaPlayer.OnPreparedListener l)
mOnPreparedListener = l;
}

/**
* Register a callback to be invoked indicating the completion of a seek operation.
*
* @param l The callback that will be run
*/
public void setOnSeekCompleteListener(MediaPlayer.OnSeekCompleteListener l)
{
mOnSeekCompleteListener = l;
}

/**
* Register a callback to be invoked when the end of a media file
* has been reached during playback.
Expand Down