【问题标题】:SoundCloud Widget API setVolume Method broken?SoundCloud Widget API setVolume 方法损坏?
【发布时间】:2013-08-20 07:12:59
【问题描述】:

我成功使用了 Soundcloud 的小部件 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 到 100 或 0 到 1 的音量 :) John M 解决方案有点工作。

标签: api methods widget soundcloud


【解决方案1】:

尝试使用介于 0 和 1 之间的音量。这为我解决了问题。

0.25 = 25% 音量

【讨论】:

    【解决方案2】:

    我也面临同样的问题,我发现在 READY 事件之外调用 setVolume 方法时,卷不会重置为满。这就是 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);
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多