2013-10-29 31 views
4

我使用SoundManager2通過RTMP傳輸MP3音頻。問題是持續時間沒有生成,並且始終爲0SoundManager2 - 使用RTMP不顯示持續時間

var sound = soundManager.createSound({ 
      id: 'soundid', 
      serverURL: 'rtmp://server/', 
      url: 'file.mp3', 
      autoLoad: true, 
      autoPlay: false, 
      onload: function() { 
       console.log("DURATION: ", this.duration); 
      }, 
      whileplaying: function() { 
       console.log(this.duration); 
      }, 
      volume: 100 
     }).play(); 

是否正在使用RTMP獲取持續時間?我試過durationEstimate以及這也顯示0.

回答

0

默認情況下Soundmanager2,RTMP,不計算持續時間,相反,你應該提供它(微秒)作爲參數,否則,你會不能夠尋求(SETPOSITION(值)):

var sound = soundManager.createSound({ 
      id: 'soundid', 
      serverURL: 'rtmp://server/', 
      url: 'file.mp3', 
      duration: 300000,//example for a 5 minutes song 
      autoLoad: true, 
      autoPlay: false, 
      onload: function() { 
       console.log("DURATION: ", this.duration); 
      }, 
      whileplaying: function() { 
       console.log(this.duration); 
      }, 
      volume: 100 
     }).play(); 

如果你沒有你的MP3音樂的持續時間,嘗試用MP3的ID3元數據來獲取它(你可以用JavaScript讓他們) 。

相關問題