Post

Replies

Boosts

Views

Activity

Reply to NSURLProtocol and AVPlayer
I found this old thread when looking into a similar problem. We're trying to use a third-party network stack (Cronet) which uses [NSURLProtocol registerClass] to handle the URL loading. And we wanted to use it with AVPlayer.It's interesting that when we test it in Xcode with iOS simulator, it works, i.e. able to catch the network calls of AVPlayer into registered class. But when we run the same code on actual iPhone, it did not work, and debugging showing the registered class not called at all.Is it still true with the iOS 13 that AVPlayer won't see registered protocol class? If yes, why the iOS simulator works? Thanks!
Feb ’20
Reply to AVAssetResourceLoadingRequest dataRequest issue
I compared the sequence of requests with a regular case when AVPlayer is created with a http URL without using delegate. I have two observations:1. In both cases, AVPlayer has first request asking for ContentInfo and range 0-1 (2 bytes) and 2nd request asking for the whole range (full length) of the video asset.2. In regular case, AVPlayer seems to "cancel" / "stop" the 2nd request as well, after receiving some (around 100k bytes) data.3. In regular caes, AVPlayer will continue to send 3rd request with requested offset following the 2nd request data received. But in the problematic delegate case, there was not 3rd request. So, now the question is, why didn't the delegate get a 3rd request from AVPlayer?
Feb ’20
Reply to AVAssetResourceLoadingRequest dataRequest issue
I found the problem. The reason is that AVPlayerItem (and AVAsset) cannot handle a URL for video if there is no known file extension, e.g. something like ".mp4".By observing the "status" key of AVPlayerItem, I found the error reason is "This media format is not supported" even though I have already set the content-type as "video/mp4" in ContentInformationRequest.Anyway, after manually adding ".mp4" in the URL, I was able to get additional loading requests after the 2nd request was cancelled. And the video playback works now 🙂 .Btw, this bug / behavior was reported on 2012, but it seems still not fixed. http://openradar.appspot.com/radar?id=1516408
Feb ’20
Reply to Cannot set constraints for an image view inside a scroll view
@Claude31 thanks for your response! My main problem is that XCode does not allow me to do the step in your "Create a UIView": "Define the constraints with respect to the scrollView (Superview)" . I.e. I am able to set constraints for the scroll view, but cannot set any constraints for the image view inside the scroll view. Please see attached screen shot of my current constraints list of the scroll view.
Feb ’22
Reply to AVPlayer video track freeze after 1 second while audio continues
I tried something different: instead of wrapping UIView using UIViewRepresentable, I changed to wrap AVPlayerViewController using UIViewControllerRepresentable, and then don't use my own video controls anymore. It seems like: If I share the same AVPlayer for each video item (i.e. each AVPlayerViewController), then I still have the video track freezing problem when scrolling between video items. If I create a new AVPlayer for each video item, then the video track freezing problem is gone. (I'm yet to find the best way to dismiss / stop AVPlayerViewController in wrapping swiftUI when it's scrolling off screen, any suggestions?)
May ’23