iOS 10 AVPlayer will not stream video from URL with no extension and with video/mp4 as content type

假如想象 提交于 2020-01-02 06:13:10

问题


Currently, we are using a standard AVPlayer via AVPlayerViewController to play video. We are streaming video from a url in the format https://ourdomain/media/mediaid?jwt=authTokenHere. The url, as you can see, has no extension; however the headers are being set on the payload to indicate that the response is a video.

Though the links results in the video playing fine in desktop Safari and Chrome, it will not play via iOS's AVPlayer in our application. Is there some particular format that AVPlayer expects?


回答1:


Alright - ended up discovering the answer to this is multifaceted. Here's what I needed to do to get things working.

  1. Files did indeed need to have extensions.
  2. The server was not correctly configured. It need to provide a progressive download response by responding with a range of headers.

By updating our backend to provide this response AND append the correct extension to the video files, we are now streaming to AVPlayer as expected. Thank you to everyone who offered tips!




回答2:


AVURLAsset is require a file extension to work. unfortunately there are already some radars open for the same issue from iOS 5 but it seems even it is not updated on iOS 10.

Radar links:

AVURLAsset should not require a file extension to work

AVURLAsset should not require a file extension to work

WorkAround / Hack:

Cycle through the playable MIME types and create a symbolic links to the actual file with the extension and check if they are playable.

Note:

  • Symbolic Link will be deleted when the app entered into background
  • To Create symbolic link check this SO answers


来源:https://stackoverflow.com/questions/41050575/ios-10-avplayer-will-not-stream-video-from-url-with-no-extension-and-with-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!