UnityPlugin-AVProVideo
UnityPlugin-AVProVideo copied to clipboard
Stalled/Unstalled events do not fire on Android when playing video off a server and the connection is cut
- Play back a HLS video from a server
- Disable the wi-fi on the device
- Notice that no stalled event/situation occurs
I believe we need to catch this in the native plugin and pass it back up to c#.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
same problem occurs. Unusually, no events are received.
Same issue here. In fact, when playing on android device Stalled/Unstalled events do not fire at all, like they don't exist.
The android device Stalled/Unstalled events do not be call when the live stream connection is cut,but windows event can be executed. the avpro version is 2.7.3
We're noticing the exact same issue on Android devices. Reproducible by the same steps mentioned in the top message on Android only. On iOS it does work.
@Ste-RH Any updates on this issue? We would like to use the 'stalled' event to show user feedback. Telling the user that their connectivity is gone for example. Any other ways we could realize this feature?
We're noticing the exact same issue on Android devices. Reproducible by the same steps mentioned in the top message on Android only. On iOS it does work.
@Ste-RH Any updates on this issue? We would like to use the 'stalled' event to show user feedback. Telling the user that their connectivity is gone for example. Any other ways we could realize this feature?
the code could be help to you;
private int _textureFrameCount = 0;
private float _stallDetectionTimer;
private int _stallDetectionGuard;
private void CheckStreamingStall(){
float STALL_DETECTION_DURATION = 0.5f;
int frameCount = mediaPlayer.TextureProducer.GetTextureFrameCount();
if (_textureFrameCount != frameCount)
{
_stallDetectionTimer = 0f;
_textureFrameCount = frameCount;
}
else
{
if (_stallDetectionGuard != Time.frameCount)
{
_stallDetectionTimer += Time.deltaTime;
}
}
_stallDetectionGuard = Time.frameCount;
float thresholdDuration = STALL_DETECTION_DURATION;
thresholdDuration = Mathf.Max(thresholdDuration / Mathf.Abs(mediaPlayer.Control.GetPlaybackRate()), STALL_DETECTION_DURATION);
float fps = mediaPlayer.Info.GetVideoFrameRate();
if (fps > 0f && !float.IsNaN(fps))
{
thresholdDuration = Mathf.Max(thresholdDuration, 2f / fps);
}
if (_stallDetectionTimer > thresholdDuration)
{
mediaPlayer.Events.Invoke(mediaPlayer, MediaPlayerEvent.EventType.Stalled, ErrorCode.None);
_stallDetectionTimer = 0;
}
}
We tried checking mediaPlayer.Info.IsStalled
in an Update()
loop and alas, that does not seem to work either. Will try the above workaround soon. Thanks!
I can't get the code above to work, the player crashes and becomes unresponsive. Is there any other suggestions on how to solve this? This can't be the accepted behaviour of a video player.
We're noticing the exact same issue on Android devices. Reproducible by the same steps mentioned in the top message on Android only. On iOS it does work. @Ste-RH Any updates on this issue? We would like to use the 'stalled' event to show user feedback. Telling the user that their connectivity is gone for example. Any other ways we could realize this feature?
the code could be help to you; private int _textureFrameCount = 0; private float _stallDetectionTimer; private int _stallDetectionGuard; private void CheckStreamingStall(){ float STALL_DETECTION_DURATION = 0.5f; int frameCount = mediaPlayer.TextureProducer.GetTextureFrameCount(); if (_textureFrameCount != frameCount) { _stallDetectionTimer = 0f; _textureFrameCount = frameCount; } else { if (_stallDetectionGuard != Time.frameCount) { _stallDetectionTimer += Time.deltaTime; } } _stallDetectionGuard = Time.frameCount;
float thresholdDuration = STALL_DETECTION_DURATION; thresholdDuration = Mathf.Max(thresholdDuration / Mathf.Abs(mediaPlayer.Control.GetPlaybackRate()), STALL_DETECTION_DURATION); float fps = mediaPlayer.Info.GetVideoFrameRate(); if (fps > 0f && !float.IsNaN(fps)) { thresholdDuration = Mathf.Max(thresholdDuration, 2f / fps); } if (_stallDetectionTimer > thresholdDuration) { mediaPlayer.Events.Invoke(mediaPlayer, MediaPlayerEvent.EventType.Stalled, ErrorCode.None); _stallDetectionTimer = 0; } }
I implemented this suggestion but it does not help. The stalled event needs to be triggered before the error event is triggered, and the error event is triggered directly when the next frame is not available. So such a function needs to trigger the stalled event while new frames are still available. Any other suggestions?