Post

Replies

Boosts

Views

Activity

AVPlayer URL custom loading
Hi,I'm trying to use AVPlayer with custom URL loading. We have a custom NSURLProtocol subclass. But it seems [NSURLProtocol registerClass] does not work directly with AVPlayer in real device (see this thread).Now I'm trying to use AVAssetResourceLoaderDelegate to do the custom URL loading. However it is a bit confusing to me how the delegate will be triggered. The URL looks like this "https://<some_ip_address>:<port>/resource/", however the protocol is not standard HTTP/1.1 (it's QUIC based instead). I did something like following, but does not work:(delegate is implemented in a different file) AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil]; AVAssetResourceLoader *resourceLoader = asset.resourceLoader; [resourceLoader setDelegate:delegate queue:dispatch_queue_create("MyURLDelegate loader", nil)]; AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset]; AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem]; AVPlayerViewController *controller = [[AVPlayerViewController alloc] init]; controller.player = player; [player play]; [self presentViewController:controller animated:false completion:^{}];With the above, I cannot see any methods are triggered in the delegate. What am I missing to allow the delegate to do custom URL loading for "https" URLs ? ThanksHan
1
0
2.0k
Feb ’20
NSURLProtocol registerClass works in simulator but not device for AVPlayer
Hi,I was posting a follow-up question to an old thread at here. But I am not sure if anyone would see it. Hence I took the liberty to post a separate thread. Thanks for understanding.I am using a custom protocol (Cronet network stack from Chromium) to play back video using AVPlayer. The code called [NSURLProtocol registerClass] to register its custom protocol and it works well in Xcode 11.3 iOS simulator testing. But the same code does not work on real device (iPhone, iOS 13). The old thread I referred above seems to suggest that AVPlayer would never "see" the registered custom protocol, but I am wondering why it worked in simulator. And is it still true in recent iOS versions that AVPlayer would use a separate process (mediaserverd ?) to play back the video hence ignoring the custom protocol? btw, I also tried to use AVAssetResourceLoaderDelegate to hijack the URL loading for AVPlayer, but did not work either in real device.Thanks.Han
3
0
1.2k
Feb ’20
why AVPlayer sends range
Hi,I am writing my own HTTP web service server that supports iOS devices to view video files. On iOS I am using `AVPlayer` and on the server side it is simply `.mp4` files. But it seems like AVPlayer buffers for a long time (10+ seconds) before starting playing a video.After a bit debugging, it seems that AVPlayer send weird range values in its HTTP request for the video, for example:1st request headers send range 0-1: (this is OK)X-Playback-Session-Id: B1F3B5AE-B49A-40B1-8F2E-A501E1BC24AF Range: bytes=0-1 Accept: */* User-Agent: AppleCoreMedia/1.0.0.17A860 (iPhone; U; CPU OS 13_1_2 like Mac OS X; en_us) Accept-Language: en-us Accept-Encoding: identity Connection: keep-alive2nd request headers send range 0-37724087, which is full length of the video.This is weird, why doesn't AVPlayer take advantage of range header and ask for only a small range?X-Playback-Session-Id: B1F3B5AE-B49A-40B1-8F2E-A501E1BC24AF Range: bytes=0-37724087 Accept: */* User-Agent: AppleCoreMedia/1.0.0.17A860 (iPhone; U; CPU OS 13_1_2 like Mac OS X; en_us) Accept-Language: en-us Accept-Encoding: identity Connection: keep-alive3rd request headers send range of 37683200-37724087, which is the last chunk of the video.Again very weird, why does AVPlayer ask for the range that was already covered by the previous request?X-Playback-Session-Id: B1F3B5AE-B49A-40B1-8F2E-A501E1BC24AF Range: bytes=37683200-37724087 Accept: */* User-Agent: AppleCoreMedia/1.0.0.17A860 (iPhone; U; CPU OS 13_1_2 like Mac OS X; en_us) Accept-Language: en-us Accept-Encoding: identity Connection: keep-aliveAny ideas? Any comments or pointers are appreciated.
3
2
2.8k
Nov ’19