我一直在尝试使用a Soundcloud Blog page上给出的示例,以便我可以将音量设置得更低。
我只更改了播放列表的iframe大小和音量,并将音量设置为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>This code is live on a Joomla site.
有没有人能帮我理解一下我缺少什么来控制音量?
这是一个jquery冲突吗?如果是这样,你有什么想法来解决这个问题吗?
发布于 2014-08-10 19:10:13
音量范围实际上是从0到1,文档中错误地说明了这一点。因此,如果您希望将音量设置为10%,则需要执行以下操作:
var widgetIframe = document.getElementById('sc-widget'),
widget = SC.Widget(widgetIframe);
widget.setVolume(0.1);发布于 2018-01-24 04:27:28
以前的答案不再准确。setVolume()接口已修复/更改为接受介于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 100https://stackoverflow.com/questions/12272441
复制相似问题