我正在开发一个来自第三方API提供商(www.mndigital.com)的音乐应用程序。API提供程序为每首歌提供了30秒的演示。演示应用程序的位置以这种格式提供。
"SampleLocations": [
{
"Location": "rtmp://mn-ecn-prd-rtmp.mndigital.com",
"Resource": "mp3:/spl/382/071/327/spl_024?48d882e51ff49ca3806e4b63d90b926556349db16cecf61947a8eb9a44f9bee3bf7d",
"Type": "s_mp3"
},
{
"Location": "rtmp://mn-ecn-prd-rtmp.mndigital.com",
"Resource": "mp4:/spl/382/071/327/spl_029.mp4?48d882e51ff49ca3806e4b63d90b926556349db16cecf61947a8eb9a44f9bee3bf7d",
"Type": "s_mp4"
}
],
此外,API提供程序还说,在条款和条件上,示例必须是来自服务器和streamed live
的should not be saved locally
。
经过几个小时的搜索,我发现这种格式是用于在flash播放器中播放音频。但在IOS中,闪存播放器不受支持。
即使要使AVPlayer
工作,我们也只需要更新的快速语法中的一个url。
do {
let url = "http://yourdomain.com/file.mp3"
let fileURL = NSURL(string:url)
let soundData = NSData(contentsOfURL:fileURL!)
self.audioPlayer = try AVAudioPlayer(data: soundData!)
audioPlayer.prepareToPlay()
audioPlayer.volume = 1.0
audioPlayer.delegate = self
audioPlayer.play()
} catch {
print("Error getting the audio file")
}
所以我不知道如何快速地流这种url。有人能提出解决办法吗。
我使用的是快速2.0 xcode 7.1.1。我的部署目标是IOS 8.0及以上版本
发布于 2016-05-02 04:52:05
经过长时间的搜索,我发现rtmp文件不能在苹果设备上播放,因为苹果不支持闪存支付程序。无法播放这些格式的URL提供的任何数据。
https://stackoverflow.com/questions/35506380
复制相似问题