小编sub*_*mit的帖子

ios9/swift2/xcode7 + AVplayer icecast不会在没有文件扩展名的情况下处理流媒体

你将如何播放来自没有文件扩展名的icecast2的流

示例流网址:http:// icecast:8044/channel-123?a = hash

格式:mp4a

代码似乎正在处理具有扩展名的文件,但没有处理文件.

    var player = AVPlayer();
    let playerItem = AVPlayerItem(URL:NSURL(string:"http://host/file.mp4a")!);
    player = AVPlayer(playerItem:playerItem)
    let playerController = AVPlayerViewController()
    playerController.view.frame = self.view.frame
    playerController.player = player
    self.addChildViewController(playerController)
    self.view.addSubview(playerController.view)
    player.play()
Run Code Online (Sandbox Code Playgroud)

编辑:基本上当流地址结束没有文件扩展名(服务器上的文件存储没有任何文件扩展名,如.mp3,.mp4,..)时,AVPlayer将不会播放任何内容(http://example.com/file) ...但如果文件名包含文件扩展名,则它可以正常工作(http://example.com/file.mp3)

avplayer swift ios9 xcode7

6
推荐指数
1
解决办法
468
查看次数

标签 统计

avplayer ×1

ios9 ×1

swift ×1

xcode7 ×1