Search in sources :

Example 1 with OnTimedTextListener

use of io.vov.vitamio.MediaPlayer.OnTimedTextListener in project VitamioBundle by yixia.

the class VideoViewSubtitle method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    if (!LibsChecker.checkVitamioLibs(this))
        return;
    setContentView(R.layout.subtitle2);
    mVideoView = (VideoView) findViewById(R.id.surface_view);
    mSubtitleView = (TextView) findViewById(R.id.subtitle_view);
    if (path == "") {
        // Tell the user to provide a media file URL/path.
        Toast.makeText(VideoViewSubtitle.this, "Please edit VideoViewSubtitle Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
        return;
    } else {
        /*
			 * Alternatively,for streaming media you can use
			 * mVideoView.setVideoURI(Uri.parse(URLstring));
			 */
        mVideoView.setVideoPath(path);
        // mVideoView.setMediaController(new MediaController(this));
        mVideoView.requestFocus();
        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                // optional need Vitamio 4.0
                mediaPlayer.setPlaybackSpeed(1.0f);
                mVideoView.addTimedTextSource(subtitle_path);
                mVideoView.setTimedTextShown(true);
            }
        });
        mVideoView.setOnTimedTextListener(new OnTimedTextListener() {

            @Override
            public void onTimedText(String text) {
                mSubtitleView.setText(text);
            }

            @Override
            public void onTimedTextUpdate(byte[] pixels, int width, int height) {
            }
        });
    }
}
Also used : OnTimedTextListener(io.vov.vitamio.MediaPlayer.OnTimedTextListener) MediaPlayer(io.vov.vitamio.MediaPlayer)

Aggregations

MediaPlayer (io.vov.vitamio.MediaPlayer)1 OnTimedTextListener (io.vov.vitamio.MediaPlayer.OnTimedTextListener)1