Open AdityaSinghShekhawat opened 1 month ago
@tonihei Any update?
Errors from the player have no way of telling exactly when its underlying error condition goes away, this can only be done on a case by case basis. Some errors are automatically marked as "recoverable" though, which means the player automatically retries playback immediately without even calling onPlayerError
. If I understand your question correctly, the concrete use case is about network recovery though, which may happen at an arbitrary point in the future.
There have been similar questions before, e.g. https://github.com/androidx/media/issues/1140. The easiest solution is to listen to network changes in your app and then call player.prepare()
again to restart playback. The linked issue also describes how you could use LoadErrorHandlingPolicy
to handle this internally (without ever getting an onLoadError
), but there is likely not too much benefit for that.
Note that we can't easily do this automatically because the network may recover at any future point and many apps wouldn't want to restart playback if the original request happened a long time ago. I don't see why this couldn't be an optional feature though that an app can opt-in to if it wants. I'll mark it as an enhancement request, but it's unlikely we get around to implement it soon. Happy to look into high-quality pull requests though if you or someone else wants to contribute this feature.
Current behaviour
When an error is triggered, we get the error ID using the onPlayerError event. When errors like slow/no internet are recovered, the playback is still stuck.
Usecase
We need to resume playback if error is recovered.
Work done so far
I have listened to various player event, but I have not found any trigger point to resume the playback after the error is recovered.
Ask:
Is there any event which gets triggered after error is recovered?. Else is there any other way to resume playback after error is recovered.