3

I'm successfully using Soundcloud's widget API, except the setVolume() method is broken :(

First, I love the widget, but I'm blown away that after all that amazing work there is no volume control available! People will immediately "back button" out of my site when they hear 100% audio and I can't alter it using setVolume()... I have to get it working or pull it :(

Here is what is happening, I have an instance named "widget" (which loads and plays well on the page).

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 :/
    });
});

Strange results. I found another blogger who asked a similar question and got no satisfactory answer. What's the deal here? What am I not seeing?

Thank you for taking the time :)

1
  • Have the same issue. On top of it, it returns volume sometimes from 0 to 100, or 0 to 1 :) John M solution kinda works.
    – dikirill
    Commented Apr 2, 2014 at 22:17

2 Answers 2

4

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

0.25 = 25% volume

0
3

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);
});
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.