Open avidraghav opened 2 years ago
I'm not sure the expectation is correct that the bytes reported by onLoadCancelled
should be added somewhere. As far as I understand a load is started (onLoadStarted
) and then it either is completed, cancelled or it fails. In each of these cases there is a callback like onLoadCompleted
, onLoadCanceled
or onLoadError
that is called.
I think this corresponds to the comment in the issue you referenced above.
If you want to know the total amount of bytes loaded then your app needs to sum up what is reported by any of these callbacks.
Sorry if I misunderstood something. In this case can you please clarify your expectation.
Thanks for the reply, My doubt is, the media is streaming perfectly when bytes are being loaded through onLoadCancelled()
.
The bytes are being loaded, the media is being played then why these bytes are not added to the bytes as calculated in onLoadStarted(
), onLoadCompleted(
)?
Some videos in my project are being played with onLoadStarted()
being called followed by onLoadCompleted()
things are fine here,
but some videos are streamed with onLoadStarted()
called followed by onLoadCanceled()
, the media streams perfectly in both cases but the bytes in the second case don't add up.
If the bytes aren't suppose to add up inside onLoadCancelled() then why media continues to stream
Am I clear now? please let me know
In general there are two main reasons I can see why a load is canceled. The first is when the user seeks to another position in the stream and a chunk of media that the player started to load is not required anymore and hence is cancelled. The other option is that the selected track has changed and the player is discarding data from a track from which the selection is moving away to another variant.
I think to further investigate this, we would need more information like at least what type of media you are playing as in progressive vs. adaptive media. Track selection obviously only happens for adaptive media like HLS/DASH.
You may want to find out why Loader.cancelLoading
is called. If you want a quick answer to this, you can put a breakpoint in that method and see from where the call is coming.
If you think this is a bug in the library, then you should provide us with the media, so we can look into this. I also would recommend that you first look into this with your media in the demo app of the most recent version of the library that is currently 2.17.1. Because if this is a bug it may have been fixed in the meantime. We also would investigate this on the most recent version because we do not back port bug fixes to older versions like 2.14.0.
Will get back to you on this with the info
ExoPlayer Version
2.14.0
Devices that reproduce the issue
Samsung Galaxy A7 running Android 10 and other Android Devices
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
I wanted to get network bytes consumed while streaming videos with Exoplayer and I got my answer after finding this issue https://github.com/google/ExoPlayer/issues/7401
I followed the steps exactly, The bug I want to mention here is that the bytes loaded inside onLoadCancelled() are not added to the total bytes calculated by onLoadStarted(), onLoadCompleted() and onLoadError().
After placing logs inside all of the provided methods to calculate network bytes, I found that the videos in which onLoadCompleted() is getting called, the bytes of these video are getting recorded but the bytes of those video in which onLoadCancelled() is being called are not.
So the steps will be just to attach the anayltics listener and add log statements inside them to check for the bytes loaded calculated
Expected result
Exoplyer1
represent onLoadStarted() being calledExoplayer4
represent onLoadCompleted() being calledExoplayer2
represents onLoadCancelled being calledExample -1
For the above case I am getting 2297 (0 + 2297) bytes as a result which is exactly as expected.
Example -2 But in some cases only onLoadedCancelled() is called and the video keeps on streaming without any issue, though the 2124144 bytes are being recorded here but they don't add up to the total. Hence in the below example I'll get the output as 0. Expected result here is 2124144 bytes ( 0 + 2124144 ).
Actual result
For Example-1 Actual result is 2297 For Example-2 Actual result is 0
Media
Exoplyer1
represent onLoadStarted() being calledExoplayer4
represent onLoadCompleted() being calledExoplayer2
represents onLoadCancelled being calledBug Report
adb bugreport
to dev.exoplayer@gmail.com after filing this issue.