AVPlayer的持续时间是Twilio的NAN [英] AVPlayer Duration is NAN with Twilio
问题描述
AVPlayer.currentItem
的duration
属性将始终随 Twilio 音频URL返回NAN
.但是,音频可以正常播放.
The duration
property of AVPlayer.currentItem
is returning NAN
always with the Twilio audio urls. However, the audio is playing fine.
我能够获得Twilio以外的所有其他音频URL的duration
属性.
I'm able to get the duration
property of all other audio urls than Twilio.
示例网址以测试此问题:
Sample url to test this issue:
http://api.twilio.com/2010-04-01/Accounts/AC1db6911efe574fc890ee332f140f7e8c/Recordings/RE06adfbfd2ad2cfd5d95585ff91cb3b88.mp3
以下是我尝试过的不同方法:
Here are the different ways that I have tried out:
if (avPlayer.currentItem.status.rawValue == AVPlayerStatus.ReadyToPlay.rawValue) {
var asset = AVURLAsset(URL: sourceURL, options: nil)
var duration: Float64 = CMTimeGetSeconds(asset.duration)
println(duration)
}
if (avPlayer.currentItem.status.rawValue == AVPlayerStatus.ReadyToPlay.rawValue) {
var duration: Float64 = CMTimeGetSeconds(self.avPlayer.currentItem.duration)
println(duration)
}
var thePlayerItem = self.avPlayer.currentItem
if thePlayerItem.status.rawValue == AVPlayerStatus.ReadyToPlay.rawValue{
println(CMTimeGetSeconds(thePlayerItem.duration))
println(CMTimeGetSeconds(thePlayerItem.asset.duration))
}
对此有任何帮助.
我已通过浏览器请求GET
,它返回了所有详细信息,包括音频持续时间<Duration>37</Duration>
I have requested GET
through the browser and it returned all the details including the audio duration <Duration>37</Duration>
GET /2010-04-01/Accounts/ACda6f1.../Recordings/RE557ce644e5ab84fa21cc21112e22c485.xml
响应:
HEADERS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since
Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag
Connection: keep-alive
Content-Length: 550
Content-Type: application/xml
Date: Tue, 08 Sep 2015 06:50:43 GMT
Etag: b1512f..
Last-Modified: Fri, 04 Sep 2015 04:19:20 +0000
Strict-Transport-Security: max-age=15768000
X-Powered-By: AT-5000
X-Shenanigans: none
BODY
view raw
<?xml version='1.0' encoding='UTF-8'?>
<TwilioResponse>
<Recording>
<Sid>RE…</Sid>
<AccountSid>ACda6f1... </AccountSid>
<CallSid>CA3..</CallSid>
<Duration>37</Duration>
<DateCreated>Fri, 04 Sep 2015 04:19:20 +0000</DateCreated>
<ApiVersion>2010-04-01</ApiVersion>
<DateUpdated>Fri, 04 Sep 2015 04:19:20 +0000</DateUpdated>
<Price/>
<Uri>/2010-04-01/Accounts/ACda6f1.../Recordings/RE557ce644e5ab84fa21cc21112e22c485.xml</Uri>
</Recording>
</TwilioResponse>
推荐答案
嘿,我只是在做,实际上,当我使用.duration
并使用建议"时,从twilio录制的带有mp3扩展名的录音并没有为我带来麻烦. @inga loadedTimeRanges[0].rangeValue.duration
它返回错误的时间.但是我改为twilio path without .mp3 extensio
n并开始工作
Hey I am just doing it and in fact recording from twilio with mp3 extension didn't wokred for me when I have used .duration
, and when using suggested @inga loadedTimeRanges[0].rangeValue.duration
it returns wrong time. But I changed to twilio path without .mp3 extensio
n and it start working
if let playerItem = player.currentItem, playerItem.status == AVPlayerItemStatus.readyToPlay {
let durationTime = playerItem.duration
//playerItem.loadedTimeRanges[0].timeRangeValue.duration
}
这篇关于AVPlayer的持续时间是Twilio的NAN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!