ExoPlayer and start / pause / seekTo commands

前端 未结 2 1631
情话喂你
情话喂你 2020-12-25 11:58

I am trying to use ExoPlayer, as opposed to MediaPlayer and I can\'t seem to figure it out...

MediaPlayer has .start()

2条回答
  •  暖寄归人
    2020-12-25 12:46

    Here's how the example code does it for Exoplayer 2:

    player.setPlayWhenReady(true);
    

    starts playback, (false stops)

    If the player is already in the ready state then this method can be used to pause and resume playback.

    To seek, they use

    boolean haveStartPosition = startWindow != C.INDEX_UNSET;
    if (haveStartPosition) {
      player.seekTo(startWindow, startPosition);
    }
    player.prepare(mediaSource, !haveStartPosition, false);
    

    So it seems you need to prepare after the seekTo.

提交回复
热议问题