SoundCloud Widget API setVolume Method broken?

空扰寡人 提交于 2019-12-05 22:39:29

Try using the a volume between 0 and 1. This fixed it for me.

0.25 = 25% volume

I too am facing the same issue and I discovered that the volume does not reset to full when setVolume method is called outside of the READY event. This is why the setVolume button on the SC api playground works since it's called externally. But there is another problem - when the next track in the playlist is loaded into the widget, it resets the volume back to full and as a result, deafens the user.

I've used a hacky workaround until this is fixed.

Setup a new PLAY_PROGRESS event and call the method inside there.

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

The setVolume method will continuously be called when the track is played. Not ideal but it works.

If you have a slider in place for volume then you may use this instead:

widget.bind(SC.Widget.Events.PLAY_PROGRESS, function() {
var vol = jQuery('.slider').val();
widget.setVolume(vol);
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!