How to play movie files with no file extension on iOS with MPMoviePlayerController or AVPlayer?

后端 未结 8 1572
长发绾君心
长发绾君心 2020-12-05 13:58

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 exte

相关标签:
8条回答
  • 2020-12-05 14:23

    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.

    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.

    0 讨论(0)
  • 2020-12-05 14:24

    Finally, I found the answer.

    You should use AVURLAsset (the subclass of AVAsset) and set the MIMEType in the options input :

    let mimeType = "video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\""
    let urlAsset = AVURLAsset(url: url, options["AVURLAssetOutOfBandMIMETypeKey": mimeType])
    

    Source -> https://stackoverflow.com/a/54087143/6736184

    0 讨论(0)
提交回复
热议问题