ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Add configurable progress listener

Open AzimLord opened this issue 5 years ago • 10 comments

I already look in the code, documentation and search in stack overflow. I see the PlayerControlView have ProgressUpdateListener interface which similar that what I need. But not sure how to use it or can even use it

I wanted to have a player.currentPosition listener for my player But I'm not sure how to do it.

So far I just use Handler() and Runnable() to get the currentPosition but it is not accurate since the start of the Runnable() can be out of sync with the played video

Is there any kind of function or workaround for this?

AzimLord avatar Oct 03 '19 07:10 AzimLord

I wanted to have a player.currentPosition listener for my player But I'm not sure how to do it.

As you already said, just use a regular running task to retrieve player.currentPosition as often as you like. We don't provide a Listener for this because this values changes continuously and it doesn't make sense to send hundreds of callbacks per second. Having your own task allows you to schedule your own update interval depending on your needs.

I see the PlayerControlView have ProgressUpdateListener interface which similar that what I need. But not sure how to use it or can even use it

The ProgressUpdateListener in PlayerControlView just tells you when the progress view in the UI has been updated. You won't get callbacks if the view is hidden for example.

So far I just use Handler() and Runnable() to get the currentPosition but it is not accurate since the start of the Runnable() can be out of sync with the played video

I don't understand this. player.currentPosition is always accurate at the time you call it.

tonihei avatar Oct 03 '19 08:10 tonihei

We get this question from time to time - so I'll mark as an enhancement to add such a listener to ExoPlayer. The main benefit of us implementing this callback is that we can better align it with certain media times (e.g. always send at at a full media second). This callback needs to be configurable for how often it's called and at what playback rate (e.g. rate: every 500ms of media and/or every 2 seconds, or similar).

tonihei avatar Oct 03 '19 08:10 tonihei

I don't understand this. player.currentPosition is always accurate at the time you call it.

I know the player.currentPosition is accurate. I mean, the Handler() will not start the same time as player starts playing the video. So using Handler() it will return 1979 milliseconds instead of 2000 milliseconds if the Handler() interval is 1000 milliseconds.

AzimLord avatar Oct 03 '19 09:10 AzimLord

Thanks for explaining. That kind of problem would be solved by a listener provided by us.

tonihei avatar Oct 03 '19 10:10 tonihei

Any updates on this?

ashraf-patel avatar Feb 04 '20 20:02 ashraf-patel

@tonihei Do you have any idea what are all the info need to be provided in the listener ? Do you wants to be this as a separate listener ?. If I am clear in the requirement I can implement this.

karuppasamys avatar Feb 22 '20 17:02 karuppasamys

If I am clear in the requirement I can implement this.

We haven't discussed detailed requirements yet (mostly around configuration options). The actual implementation needs to check whether to trigger the callbacks from ExoPlayerImplInternal.updatePlaybackPositions and whenever playbackInfo.copyWithNewPosition is called. If you want to contribute a PR for this, it would be helpful to provide a more detailed plan of how this may look like to avoid disappointment later.

tonihei avatar Feb 26 '20 11:02 tonihei

I just finished a custom implementation of player controls (my own layout), by following the implementation of PlayerControllarView class. It is still easier to control and sync seek bar with playback than the mediaplayer.

Mr-Ramzan avatar Jun 23 '21 10:06 Mr-Ramzan

Any updates on this? I could use a handler but How can I get a callback whenever current position of exoplayer get changed?

@tonihei it’s been a long time. Now that the player is deprecated, what’s the plan?

laxuscullen avatar Mar 26 '24 20:03 laxuscullen