SoundCloud Widget setVolume API not working?

I successfully use the Soundcloud widget API, except that the setVolume () method is violated :(

Firstly, I like the widget, but I exploded that after all this amazing work there is no volume control! People will immediately “return the button” from my site when they hear 100% audio, and I cannot change it using setVolume () ... I need to get it to work or pull it out: (

Here's what happens, I have an instance called "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 did not receive a satisfactory answer. What is the deal here? What I do not see?

Thanks for taking the time:)

+4
source share
2 answers

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

0.25 = 25% volume

+5
source

I also encounter the same problem, and I found that the volume does not matter reset when the setVolume method is called outside the READY event. This is why the setVolume button on the SC api playground works, as it is called externally. But there is another problem: when the next track in the playlist is loaded into the widget, it resets the volume to full and, as a result, stuns the user.

I used a hacky workaround until it is fixed.

Set a new PLAY_PROGRESS event and call the method inside it.

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

The setVolume method will be constantly called when playing a track. Not perfect, but it works.

If you have a slider for the volume, you can use it instead:

 widget.bind(SC.Widget.Events.PLAY_PROGRESS, function() { var vol = jQuery('.slider').val(); widget.setVolume(vol); }); 
+3
source

Source: https://habr.com/ru/post/1497933/


All Articles