啟用視頻播放

建立可處理HLS串流設定和播放作業的PlaybackManager。 不需要其他配置。

  1. 請確定PlayerFragment.java中存在以下代碼,以建立媒體播放器對象:

    private MediaPlayer createMediaPlayer() { 
            MediaPlayer mediaPlayer = DefaultMediaPlayer.create(getActivity().getApplicationContext()); 
            return mediaPlayer;
    
  2. 通過ManagerFactory建立播放管理器:

    playbackManager = ManagerFactory.getPlaybackManager(config, mediaPlayer);
    
  3. PlayerFragment中實作PlaybackManagerEventListener以處理播放事件:

    private final PlaybackManagerEventListener playbackManagerEventListener =  
      new PlaybackManagerEventListener() 
    
  4. PlayerFragment中註冊事件偵聽器:

    playbackManager.addEventListener(playbackManagerEventListener);
    
  5. 設定視訊資源:

    playbackManager.setupVideo(url, adsManager); 
    
  6. PlayerFragment中設定控制欄操作:

    controlBar.pressPlay() { 
        playbackManager.play();  
    }
    

本頁內容

Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now