Created
August 30, 2019 04:18
-
-
Save edmeehan/41097d5d070fd33017996cf8b9c253ea to your computer and use it in GitHub Desktop.
Auto play next sound cloud widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function(SC){ | |
| const scIframes = [...document.querySelectorAll('iframe[src*="soundcloud.com/player"]')], | |
| soundFinished = function(sc){ | |
| const index = scIframes.findIndex((item) => item === this); | |
| if(index < scIframes.length) scWidgets[index + 1].play(); | |
| }; | |
| let scWidgets = scIframes.map((item) => { | |
| const widget = SC.Widget(item); | |
| widget.bind(SC.Widget.Events.FINISH, soundFinished.bind(item)); | |
| return widget; | |
| }); | |
| })(SC); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Page requires SoundCloud API script - https://w.soundcloud.com/player/api.js