Show Menu
TOPICS×

Enable video playback

Create a PlaybackManager that handles the HLS stream setup and playback operation. No other configuration is required.
  1. Create the media player object by making sure the following code exists in PlayerFragment.java:
    private MediaPlayer createMediaPlayer() { 
            MediaPlayer mediaPlayer = DefaultMediaPlayer.create(getActivity().getApplicationContext()); 
            return mediaPlayer;
    
    
  2. Create the playback manager through the ManagerFactory :
    playbackManager = ManagerFactory.getPlaybackManager(config, mediaPlayer);
    
    
  3. Implement the PlaybackManagerEventListener in the PlayerFragment to handle the playback events:
    private final PlaybackManagerEventListener playbackManagerEventListener =  
      new PlaybackManagerEventListener() 
    
    
  4. Register the event listener in the PlayerFragment :
    playbackManager.addEventListener(playbackManagerEventListener);
    
    
  5. Set up the video resource:
    playbackManager.setupVideo(url, adsManager); 
    
    
  6. Set up the control bar operations in the PlayerFragment :
    controlBar.pressPlay() { 
        playbackManager.play();  
    }