iOS 10 AVPlayer将无法从没有扩展名且以video/mp4作为内容类型的URL流式传输视频 [英] iOS 10 AVPlayer will not stream video from URL with no extension and with video/mp4 as content type

查看:382
本文介绍了iOS 10 AVPlayer将无法从没有扩展名且以video/mp4作为内容类型的URL流式传输视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我们通过AVPlayerViewController使用标准的AVPlayer播放视频.我们正在以 https://ourdomain/media/mediaid?jwt = authTokenHere .如您所见,该URL没有扩展名.但是,将在有效负载上设置标头以指示响应是视频.

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.

尽管这些链接可以使视频在桌面Safari和Chrome中正常播放,但无法在我们的应用程序中通过iOS的AVPlayer播放. AVPlayer是否需要某些特定格式?

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?

推荐答案

好吧-最终发现答案是多方面的.这是我需要做的事情.

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

  1. 文件确实确实需要扩展名.
  2. 服务器不是 正确配置.它需要提供一个渐进式下载 通过响应一系列标题来做出响应.
  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.

通过更新后端以提供此响应并将正确的扩展名附加到视频文件,我们现在可以按预期的方式将流传输到AVPlayer.谢谢所有提供提示的人!

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!

这篇关于iOS 10 AVPlayer将无法从没有扩展名且以video/mp4作为内容类型的URL流式传输视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆