Getting informed about user actions
See original GitHub issueSearched documentation and issues
Official ExoPlayer documentation and source code of MediaControllerCompat
, MediaSessionConnector
, MediaSession
classes.
Question
Is it possible to get notified about user actions? I’m using ExoPlayer
and MediaSessionConnector
for handling MediaSession, so I’m not able to register MediaSession.Callback
, that would have solved my problem, because it can be registered only once and it is done inside of MediaSessionConnector
class.
I would like to be informed about user actions like “PLAY”, “PAUSE”, “SKIP TO NEXT”, “SKIP TO PREVIOUS” etc. The only way to do it, I have found, is to register MediaControllerCompat.Callback
, that has onPlaybackStateChanged
method. The problem is that after testing it, I have found that only states that are dispatched to this method are STATE_NONE
, STATE_PAUSED
, STATE_PLAYING
and STATE_BUFFERING
. There are other states like STATE_SKIPPING_TO_PREVIOUS
, STATE_SKIPPING_TO_NEXT
I would like to be notified about, but it never happens.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
I think in this case it’s best to register an
EventListener
withplayer.addListener(eventListener)
.The player will call
onPositionDiscontinuity(int reason)
and pass a reason. If it’s a seek by the user (skip is a seek) the reason isPlayer.DISCONTINUITY_REASON_SEEK
. If playback transitioned automatically the reason isPlayer.DISCONTINUITY_REASON_PERIOD_TRANSITION
.You may also want to look into
AnalyticsListener
if you want to collect other events. You can add it by usingSimpleExoPlayer.addAnalyticsListener(AnalyticsListener)
.Great to hear. I’m closing this issue. Please re-open if needed.