问题
We've been having problems with the setVolume function while using the SoundCloud Javascript API.
The trace:
Uncaught IndexSizeError: Index or size was negative, or greater than the allowed value. audiomanager.js:2 HTML5AudioPlayer.setVolume
We are calling that function on the sound object, as usual, and the values we're passing to are between 0 and 100, which are the ones that are specified as correct.
The problem started a few hours ago and we haven't made any changes in our code, so it seems that the version of audiomanager we're retrieving from soundcloud has changed today.
Any idea?
Thanks
回答1:
It seems like the SoundCloud JavaScript SDK has changed over night. I'm facing similar issues. The SDK is using the HTML5AudioPlayer object now to stream tracks. As for you question, I've noticed that the volume value needs to be between 0 and 1 opposed to 0 and 100 in the "old" version. So be sure to call sound.setVolume(0.5)
instead of sound.setVolume(50)
. Also, the "whileplaying" event is not firing anymore.
It would be nice of SoundCloud to update their docs / inform devs about SDK changes in the future. In the mean time, I'm looking at https://connect.soundcloud.com/audiomanager/audiomanager.js to find answers to my questions.
来源:https://stackoverflow.com/questions/20206274/soundcloud-api-setvolume-on-audiomanager-js