我有一个嵌入式的SoundCloud播放器,可以从白天到晚上动态更改歌曲。目前,我只有一首歌,但我希望能够在白天加载一系列歌曲,而在夜间加载其他系列的歌曲。理想情况下,歌曲将以随机顺序播放。任何帮助,将不胜感激。
HTML:
<div id="iframe-wrapper">
<iframe id="song" width="100%" height="20" scrolling="no" frameborder="no" allow="autoplay"></iframe>
</div>
JS:
var currentTime = new Date().getHours();
var song = document.getElementById('song');
if (currentTime >= 6 && currentTime <= 19) {
song.setAttribute('src', 'https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/482221002%3Fsecret_token%3Ds-ahwqc&color=%23577c5d&inverse=false&auto_play=true&show_user=true');
}
else {
song.setAttribute('src', 'https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/482220954%3Fsecret_token%3Ds-h2Pnx&color=%23577c5d&inverse=true&auto_play=true&show_user=true');
}