2013-08-20 45 views
4

我成功地使用的SoundCloud的插件API,除了setVolume()則會方法被打破:(SoundCloud Widget API setVolume方法破壞?

首先,我愛小部件,但我吹走,經過所有的驚人的工作沒有音量控制可用!當他們聽到100%的音頻,我不能用setVolume()改變它時,人們會立即「退出」我的網站。我必須讓它工作或拉動它:(

這是什麼正在發生,我有一個名爲「Widget」的實例(它在頁面上加載並播放)

widget.bind(SC.Widget.Events.READY, function() { 
    $('#audioIndictments').removeClass('remove'); // This disables a CSS rule, making the soundCloud iframe visible 

    widget.setVolume(10); // This should set the volume to 10% but doesn't :(
    widget.getVolume(function(vol){ 
     console.log(vol); // This outputs 0.1 in the console :/ 
     console.log(widget); // This outputs the object in the console and I don't see anything out of whack :| 
    }); 

    widget.play(); // This successfully fires up the widget and the audio begins playing :) 
    widget.setVolume(10); // Just to see if it makes a difference, after the play() method, I ran setVolume again after the play() method and still no change :(

    widget.getVolume(function(vol){ 
     console.log(vol); // This still outputs 0.1 in the console :/ 
    }); 
}); 

奇怪的結果。發現另一位博客提出了類似的問題,但沒有得到滿意的答覆。這裏的交易是什麼?我沒有看到什麼?

感謝您抽出寶貴的時間:)

+0

有同樣的問題。最重要的是,它有時從0回到100,或0到1 :)約翰M解決方案有點奏效。 – dikirill

回答

3

我也是面臨着同樣的問題,我發現該卷沒有重置全時setVolume方法被稱爲ready事件之外。這就是爲什麼SC api操場上的setVolume按鈕可以工作,因爲它被稱爲外部。但還有另外一個問題 - 當播放列表中的下一個曲目加載到小部件中時,它會將音量重新設置爲完全,並因此導致用戶眩暈。

我已經使用了一個hacky的解決方法,直到它被修復。

設置一個新的PLAY_PROGRESS事件並調用裏面的方法。

widget.bind(SC.Widget.Events.PLAY_PROGRESS, function() { 
widget.setVolume(10); 
}); 

播放曲目時setVolume方法將不斷被調用。不理想,但它的作品。

如果您有音量到位滑塊,那麼你可以使用它代替:

widget.bind(SC.Widget.Events.PLAY_PROGRESS, function() { 
var vol = jQuery('.slider').val(); 
widget.setVolume(vol); 
}); 
+1

其實看起來像這個黑客無法正常工作。 – IPv6

5

嘗試使用0和1之間。這個固定爲我的容積。

0.25 = 25%量

+0

這是正確的答案。謝謝! – labago