RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
237 stars 28 forks source link

EventType.FinishedBuffering is not being called #1406

Closed Jumpydh closed 1 year ago

Jumpydh commented 1 year ago

While receiving a HLS stream on IOS or Editor the EventType.FinishedBuffering Event is not being called, neither is Control.IsBuffering() set to false. Although, android calls the Event and sets the bool to false, in the same exact build.

Chris-RH commented 1 year ago

Can you fill in the full report template please. Have you tried different streams? Could you provide a link for the streams used please

Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE

Describe the issue A clear and concise description of what the issue is.

Your Setup (please complete the following information):

To Reproduce

Logs If applicable, add error logs to help explain your problem.

Screenshots If applicable, add screenshots to help explain your problem.

Videos If applicable, add a copy of your video or the URL

Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE

Instead email the link to us unitysupport@renderheads.com

Jumpydh commented 1 year ago

Describe the issue Trying to add a Buffer Icon, that only showsa while IsBuffering() is true. The FinishedBuffering event is not being called on an non android device, therefore IsBuffering is always returning true and the Icon is always active.

Your Setup:

Unity version: 2020.3.37f1 AVPro Video version: AVPro Video v2.6.6 (native plugin v2.6.3f1-core) Operating system version: Windows 11 Pro 21H2 / IOS 16.2 Device model: Iphone XS, Iphone 14 pro Video specs: 3840x1920 (2:1 360°), hls (.m3u8), varying

To Reproduce 1. private MediaPlayer _mediaPlayer; _mediaPlayer = FindObjectOfType<MediaPlayer>(); var _mediaPath = new MediaPath(PlayerPrefs.GetString("Url"),MediaPathType.AbsolutePathOrURL); _mediaPlayer.OpenMedia(_mediaPath);

Debug.Log(_mediaPlayer.Control.IsBuffering());

IsBuffering() returning true, while the video is running; On Android it is returning false

2. _mediaPlayer.Events.AddListener(HandleEvent);

void HandleEvent(MediaPlayer mp, MediaPlayerEvent.EventType eventType, ErrorCode code) { if (eventType == MediaPlayerEvent.EventType.StartedBuffering) { Debug.Log("AHAHAHAHAH"); } if (eventType == MediaPlayerEvent.EventType.FinishedBuffering) { Debug.Log("MUHAHAAHAHAHAHAH"); } }

FinishedBuffering event only ever called on an Android device

Videos

MorrisRH commented 1 year ago

Hey @Jumpydh, I'm afraid I cannot reproduce this on iOS using the latest version of AVPro Video (2.6.7).

Using the example stream you provided (and also this one), both the StartedBuffering and FinishedBuffering events fired as expected.

On iOS (and macOS) finished buffering is triggered when the player's buffer is full, it may be that due to network conditions it is never reaching full for you, but has buffered enough such that playback can begin.

Because we build on top of each platforms native video APIs, there are a few cases where behaviour between platforms is slightly different, this being one of them.

If you're trying to implement a buffer icon that shows when playback has stopped due to not having enough data buffered, the Stalled and Unstalled events would be a better choice.

Jumpydh commented 1 year ago

Hey, like you said, it is working in the intended way ^^ As a stream got no end it never finished buffering, but as the video sent above could, it does fire the event. The way it worked (or didn't) on Android fooled me. Anyways, Stalled/Unstalled works like a charm and is way better for my usecase (: Thank you very much! Jumpy