Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable progress listener #6504

Open
AzimLord opened this issue Oct 3, 2019 · 7 comments
Open

Add configurable progress listener #6504

AzimLord opened this issue Oct 3, 2019 · 7 comments
Assignees
Labels

Comments

@AzimLord
Copy link

@AzimLord AzimLord commented Oct 3, 2019

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?

@tonihei
Copy link
Contributor

@tonihei tonihei commented Oct 3, 2019

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 tonihei removed the needs triage label Oct 3, 2019
@tonihei
Copy link
Contributor

@tonihei tonihei commented Oct 3, 2019

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 tonihei added enhancement and removed question labels Oct 3, 2019
@tonihei tonihei changed the title How to do implement progress listener? Add configurable progress listener Oct 3, 2019
@AzimLord
Copy link
Author

@AzimLord AzimLord commented Oct 3, 2019

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.

@tonihei
Copy link
Contributor

@tonihei tonihei commented Oct 3, 2019

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

@ashraf-patel
Copy link

@ashraf-patel ashraf-patel commented Feb 4, 2020

Any updates on this?

@karuppasamys
Copy link

@karuppasamys karuppasamys commented Feb 22, 2020

@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.

@tonihei
Copy link
Contributor

@tonihei tonihei commented Feb 26, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants