2015-09-08 9 views
5

AVPlayer.currentItem की duration संपत्ति Twilio ऑडियो यूआरएल के साथ हमेशा NAN लौटने के साथ नेन है। हालांकि, ऑडियो ठीक खेल रहा है।AVPlayer अवधि Twilio

मैं duration Twilio की तुलना में अन्य सभी ऑडियो यूआरएल की संपत्ति प्राप्त करने में सक्षम हूं।

नमूना यूआरएल इस मुद्दे का परीक्षण करने के:

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)) 
} 

इस पर कोई मदद की सराहना की है:

http://api.twilio.com/2010-04-01/Accounts/AC1db6911efe574fc890ee332f140f7e8c/Recordings/RE06adfbfd2ad2cfd5d95585ff91cb3b88.mp3 

यहाँ अलग अलग तरीकों से है कि मैं बाहर की कोशिश की है कर रहे हैं।

मैं ब्राउज़र के माध्यम से GET का अनुरोध किया है और यह ऑडियो अवधि सहित सभी विवरण लौटे <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> 
+0

क्या आपको समाधान मिल गया? हमें यहां एक ही समस्या है। –

+0

नहीं .. क्षमा करें ...., –

उत्तर

4

मैं एक ही समस्या थी, लेकिन मैं प्राप्त करने में सक्षम था निम्नलिखित करने की अवधि:

let timeRange = self.avPlayer.currentItem.loadedTimeRanges[0].CMTimeRangeValue 
let duration = CMTimeGetSeconds(timeRange.duration) 

उम्मीद है कि यह मदद करता है!

0

अरे मैं तो बस यह कर रहा हूँ और जब मैं .duration का इस्तेमाल किया है इस तथ्य एमपी 3 विस्तार के साथ twilio से रिकॉर्डिंग में मेरे लिए wokred नहीं था, और के उपयोग के दौरान सुझाव दिया @ingaloadedTimeRanges[0].rangeValue.duration यह गलत समय देता है। लेकिन मैं twilio path without .mp3 extensio एन में बदल गया और यह

if let playerItem = player.currentItem, playerItem.status == AVPlayerItemStatus.readyToPlay { 
    let durationTime = playerItem.duration 
    //playerItem.loadedTimeRanges[0].timeRangeValue.duration 
}