UnityPlugin-AVProVideo icon indicating copy to clipboard operation
UnityPlugin-AVProVideo copied to clipboard

Stalled/Unstalled events do not fire on Android when playing video off a server and the connection is cut

Open Ste-RH opened this issue 3 years ago • 10 comments

  • 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#.

Ste-RH avatar Jul 23 '21 09:07 Ste-RH

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.

stale[bot] avatar Aug 06 '21 17:08 stale[bot]

same problem occurs. Unusually, no events are received.

NoahHahm avatar Sep 26 '22 12:09 NoahHahm

Same issue here. In fact, when playing on android device Stalled/Unstalled events do not fire at all, like they don't exist.

dr-formalyst avatar Nov 18 '22 15:11 dr-formalyst

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

ct21690801 avatar May 18 '23 08:05 ct21690801

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?

SwenRanj avatar Jun 09 '23 10:06 SwenRanj

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;            
    }
	}

ct21690801 avatar Jun 12 '23 06:06 ct21690801

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!

ReneB avatar Jun 12 '23 07:06 ReneB

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.

GabrielRosenberg avatar Jan 10 '24 13:01 GabrielRosenberg

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?

GabrielRosenberg avatar Jan 22 '24 11:01 GabrielRosenberg