Open hipwelljo opened 4 years ago
Hi hipwelljo, This problem is due to an issue with live streaming on Apple devices. This impacts the underlying iFrame API library and is not a direct problem with the ios-player-helper library. As you correctly noted, the issue does not effect Android devices.
Unfortunately this is a long-standing problem and we don't currently have a solution. The only work-around available is a bit heavy, but should get the job done if you really need the functionality: 1) Retrieve "liveStreamingDetails.actualStartTime" from the streaming API https://developers.google.com/youtube/v3/docs/videos#properties 2) Use this value to compute duration by comparing to local system time on the device
Note that we haven't tested this, but in theory it should work.
For more information about "getDuration" with live videos, refer to the second paragraph of text ("If the currently playing video is a live event ...") in the iFrame API docs that you linked.
Thank you for this information, that is insightful. This seems to impact the position as well, is that right? I'm seeing when I start playing a live video playerView:didPlayTime: is called with ~20 for playTime and it increases over time, but that seemingly doesn't indicate where they are in the live stream at all. Is that too a known issue?
For some reason, duration is always returned as 0 when playing a live video, but it works with regular on demand videos.
With https://www.youtube.com/watch?v=BnloneYBBKc for example, the following code always prints
time: 33.052174 duration: 0.0
where time increases over time but duration never changes:This is reproducible in the sample project. Here progress turns out to be +Inf because of divide by 0:
I can see why - evaluating
player.getDuration();
returns a NULL result but also NULL error, thereforecompletionHandler(0, nil);
is always called.I confirmed this behavior with version 1.0.2 (and 0.1.6) using iOS 14.
Interestingly, we are getting a duration with that same video on Android using a custom IFrame API implementation:
youtube_iframe.html.zip
I am wondering if it might be failing to get the metadata? The docs state