The duration
property of AVPlayer.currentItem
is returning NAN
always with the Twilio audio urls. However, the audio is playing fine.
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))
}
Any help on this is appreciated.
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
Response:
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>