Implement a play/pause button

Using PSDK methods, you can set up pause and play buttons for the user.

  1. Wait for the PSDK to call your PlaybackEventListener.onPrepared callback.

    This ensures that the media resource has successfully loaded. If the player is not in the PREPARED state, attempting to call the following methods throws an IllegalStateException.

  2. Create a pause/play button and have it call the PSDK:
    • To start playback.

      void play() throws IllegalStateException;
    • To pause playback.

      void pause() throws IllegalStateException;
  3. Use the MediaPlayer.PlaybackEventListener.onStateChanged callback to check for errors or to take other appropriate actions.

    The PSDK calls this callback when the pause or play methods are called. The PSDK passes information about the state change in the callback, including the new state, such as PAUSED or PLAYING.