如何在iOS上使用MPMoviePlayerController或AVPlayer播放没有文件扩展名的电影文件? [英] How to play movie files with no file extension on iOS with MPMoviePlayerController or AVPlayer?

查看:1093
本文介绍了如何在iOS上使用MPMoviePlayerController或AVPlayer播放没有文件扩展名的电影文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在iPad上播放iOS 4.3中的电影。当文件名具有文件扩展名时,我已成功使用MPMoviePlayerController和AVPlayer从远程URL加载文件。但是,当我使用不返回文件名的CDN(只是一个不可猜测的随机名称)时,MPMoviePlayerController或AVPlayer似乎都无法应对。

I want to play a movie in iOS 4.3 on the iPad. I've successfully used MPMoviePlayerController and AVPlayer to load files from a remote URL when the filename has a file extension. However, when I use a CDN that doesn't return the filename (just an un-guessable random name), neither MPMoviePlayerController or AVPlayer seem to be able to cope.

有没有办法告诉任何一个玩家它真的是一个类型为x的电影,它应该继续播放它?

Is there a way to tell either player that it really is a movie of type x and it should just get on playing it?

MPMoviePlayerController将从它的更改中返回以下错误州通知:

MPMoviePlayerController will return the following error from it's changed state notification:

{
    MPMoviePlayerPlaybackDidFinishReasonUserInfoKey = 1;
    error = "Error Domain=MediaPlayerErrorDomain Code=-12847 \"This movie format is not supported.\" UserInfo=0x5b60030 {NSLocalizedDescription=This movie format is not supported.}";
}

我知道该文件是一个有效的m4v文件,就像我重命名它一样很好。

I know that file is a valid m4v file, as when I rename it all is fine.

推荐答案

如果玩家无法猜测文件格式,则需要检查CDN是否发送了正确的mime类型背部。我的猜测是你的CDN无法正确猜测mimetype,也无法猜测播放器。

If the player can't guess the file format you need to check that the CDN sends the right mime type back. My guess is that your CDN can't guess the mimetype correctly nor can the player.

在大多数情况下,这是由于CDN如何呈现HTTP标头。 检查内容类型标题是否设置为与您的内容匹配的视频格式。

In most cases this is due to how the CDN presents the HTTP header. Check that the "Content-Type" header is set to a video format matching your content.

这篇关于如何在iOS上使用MPMoviePlayerController或AVPlayer播放没有文件扩展名的电影文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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