Detect pause/resume in ExoPlayer

后端 未结 7 1939
予麋鹿
予麋鹿 2021-02-06 23:02

I searched two days for this question in github but i can\'t find true answer . I want example for detecting pause / resume in ExoPlayer > 2.x . An

7条回答
  •  再見小時候
    2021-02-06 23:37

    Please try below code snipped. The player listener(onPlayerStateChanged) isn't good to observe play / pause action its called multiple time and also invoke while player configuring.

    videoView.setControlDispatcher(object : DefaultControlDispatcher() {
                override fun dispatchSetPlayWhenReady(player: Player, playWhenReady: Boolean): Boolean {
                    if (playWhenReady)
                      // Tap on Play button  
                    else
                     // Tap on Pause button
                    return super.dispatchSetPlayWhenReady(player, playWhenReady)
                }
            })
    

提交回复
热议问题