Search code examples
androidandroid-studioexoplayerexoplayer2.x

Exoplayer how can you detect if someone clicks on the Play Button?


I know I could test with PlayerStateChanged if something is playing or not but I need the moment someone presses the play button... Does somebody know the code for this ?


Solution

  • I want to make the player prepare(mediasource) only when the user clicks on the play button so I can save ressources otherwise it will keep loading everytime a video when I go into the feed.

    Then you can just simply add a button to your layout and call prepare(mediaSource) whenever button is clicked.

    BTW : you can override the control view of ExoPlayer to achieve the same