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

Playback buffer value #4023

Closed
kanthicn1 opened this issue Mar 22, 2018 · 4 comments
Closed

Playback buffer value #4023

kanthicn1 opened this issue Mar 22, 2018 · 4 comments
Assignees
Labels

Comments

@kanthicn1
Copy link

I am writing a DASH video player using ExoPlayer demo app as the base for my application. How can I get the actual playback buffer size in seconds, without messing with the actual MediaSource and other code libraries (and short of maintaining my own variable tracking media downloaded, played, paused and all that mess)?
By actual playback buffer size, I mean the 'total duration duration of the video chunks that's already buffered' - 'total duration of the video chunks that's been watched'.
For example, if the player has downloaded 60s worth of data and the renderer has already played 50s of this video, I want to know that there's 10 more seconds to go before the player might hit a re-buffer. I am trying to eventually get to a feature that minimizes re-buffering events.
I want to do this with minimal changes to the existing code and achieve this with event listeners, as much as possible. I know if I write my own trackSelector, this is easy to obtain. But, can I get it at the app layer?
Thanks for any pointers.

@tonihei
Copy link
Collaborator

tonihei commented Mar 23, 2018

player.getBufferedPosition() - player.getCurrentPosition() should give you what you want for most situations.

The only exception is when the player pre-buffers the following items in a playlist. In this case the calculation would only give you the buffered duration in the current playlist item. But, we are planning to fix this soon.

@tonihei tonihei self-assigned this Mar 23, 2018
@kanthicn1
Copy link
Author

Thank you! This works perfectly for me right now. However, I want to understand the caveat in this solution that you mentioned. If the player pre-buffers the other items in the playlist, are you saying this method won't give me the buffer values of all the tracks? But, this method will always give me the correct buffer value of the track that is currently being played. Correct?

@tonihei
Copy link
Collaborator

tonihei commented Mar 23, 2018

Yes, that's correct. We are currently adding a new method the interface Player.getTotalBufferedDuration() which returns the total duration of buffered media across all playlist items.

@kanthicn1
Copy link
Author

Great!
Thanks again for your help.

ojw28 pushed a commit that referenced this issue Jun 18, 2018
Currently only the buffered position in the current media period can be queried.

To achieve this, we save the buffered positions of all MediaPeriods to the
PlaybackInfo together with a list of MediaPeriodIds. ExoPlayerImpl can then
determine the correct buffered position for multi-period windows and windows
with midroll ads.

In addition, this change adds two new convenience methods to the Player interface
to query the total buffered duration across all windows and to get the buffered
duration of the content while playing an ad.

Issue:#4023

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=200041791
@google google locked and limited conversation to collaborators Aug 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants