2012-09-04 55 views
5

我一直在尝试使用此Soundcloud博客页面上给出的示例,以便我可以将音量设置得更低。 http://developers.soundcloud.com/blog/html5-widget-api控制Soundcloud HTML5 Widget播放器卷

我只改变了iframe大小和src =我的播放列表和set.Volume为10,所以我可以注意到它的区别,如果它的工作。到目前为止没有变化的数量仍然是100%

我已经尝试过,并没有将以下内容放在我的模板的头部。似乎并不重要。

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 

下面是我从的SoundCloud调整。例如代码:

<iframe id="sc-widget" width="350" height="332" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F1417174&auto_play=true&show_artwork=false&color=37415f"></iframe> 

    <script src="http://w.soundcloud.com/player/api.js" type="text/javascript"></script> 
    <script type="text/javascript"> 
    (function(){ 
    var widgetIframe = document.getElementById('sc-widget'), 
     widget  = SC.Widget(widgetIframe); 

    widget.bind(SC.Widget.Events.READY, function() { 
     widget.bind(SC.Widget.Events.PLAY, function() { 
     // get information about currently playing sound 
     widget.getCurrentSound(function(currentSound) { 
      console.log('sound ' + currentSound.get('') + 'began to play'); 
     }); 
     }); 
     // get current level of volume 
     widget.getVolume(function(volume) { 
     console.log('current volume value is ' + volume); 
     }); 
     // set new volume level 
     widget.setVolume(10); 
    }); 

    }()); 
    </script> 

这里是Joomla的网站,这个代码是活的。 http://mediaservicesnyc.com/

有人可以帮助我了解我缺乏控制音量。

这是一个jQuery的冲突?如果是这样,关于如何解决它的任何想法?

此致 埃里克

回答

6

体积范围实际上是从0到1,这是在文档中错误地说明。因此,如果您想将音量设置为10%,您需要:

var widgetIframe = document.getElementById('sc-widget'), 
widget  = SC.Widget(widgetIframe); 

widget.setVolume(0.1); 
0

上一个答案不再准确。 setVolume()api已被修正/更改为0到100之间的整数。

我偶然发现了这个问题,试图使用chrome控制台快速更改嵌入式SoundCloud iframe的音量。我为自己创造了一个快速要点。 https://gist.github.com/propagated/78aaedfbc0c23add7691bb975b51a3ff

//load soundcloud js api if needed 
var script = document.createElement('script'); 
script.type = 'text/javascript'; 
script.src = 'http://w.soundcloud.com/player/api.js'; 
document.head.appendChild(script); 

//get the id of the player iframe or inject it using chrome 
var id = 'scplayer', 
    widgetIframe = document.getElementById(id), 
    fixWidget = SC.Widget(widgetIframe); 
fixWidget.setVolume(50); //% between 1 and 100 
相关问题