错误-AVPlayer无法播放远程URL的音频-Swift

时间:2019-01-13 04:08:03

标签: ios swift audio avplayer

我正在尝试使用AVPlayer播放URL音频。当我输入带有.mp3扩展名的URL时,它工作正常。但是当我使用没有扩展名的URL时。它没有用。这是URL

这里是代码。

 let url = URL(string: "https://redirector.googlevideo.com/videoplayback?ipbits=0&mn=sn-xcvoxoxu-aixe%2Csn-npoeen7k&ip=117.53.42.8&mm=31%2C29&ms=au%2Crdu&mv=m&mt=1547352278&id=o-AIUfw7X-7-vO4ebqBskvYlVvVmhmgp9WJBItzTwZ7c51&keepalive=yes&pl=24&source=youtube&fvip=6&requiressl=yes&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&itag=250&gir=yes&clen=4252061&txp=5511222&dur=490.541&lmt=1540081943361780&ei=G7k6XNuzA9TNVv6RjvgI&expire=1547373947&c=WEB&key=yt6&mime=audio%2Fwebm&initcwndbps=143750&signature=774AA79C717B4D9AC6A68743C5730CCBF6A8B9B4.0D91F9D2F80CF12A6623D260B9FC5BB3E69BBAE1&title=Coke-Studio-Season-10-Latthay-Di-Chaadar-Quratulain-Balouch-Farhan-Saeed")
    let playerItem:AVPlayerItem = AVPlayerItem(url: url!)
    player = AVPlayer(playerItem: playerItem)

    if player?.rate == 0
    {
        player.play()
    } else {
        player.pause()
    }

还有其他方法可以在iOS中以不包含.mp3或任何其他扩展名的URL播放音频。我不知道为什么播放器不播放音频文件,设备上没有声音输出,也没有显示错误。

0 个答案:

没有答案