gpt4 book ai didi

javascript - 使用 Soundcloud 和 wordpress iram 播放下一首歌曲

转载 作者:行者123 更新时间:2023-11-28 07:26:39 25 4
gpt4 key购买 nike

我有一个由各个 Soundcloud 轨道的帖子组成的 WordPress 网站,当上一首轨道播放完毕时,我需要播放下一首轨道(在下一篇文章中),因为我的主页是用最新帖子制作的。

我尝试了很多js函数,但仍然无法使其工作。

这是我的网站:invisibleradio

最佳答案

我为面临同样问题的人找到了解决方案:

<script type='text/javascript'>

var next_widget ;
var iframes =[];
var its_the_last = false;

(function() {
iframes = document.querySelectorAll('iframe');
//iframe.src = 'http://w.soundcloud.com/player/?url=http://api.soundcloud.com/tracks/43315398&auto_play=true';
for (var i = 0; i < iframes.length; i++) {
//var widget_+i = SC.Widget(iframes[i]);
window['widget_'+i] = SC.Widget(iframes[i]);
var widget = SC.Widget(iframes[i]);



widget.bind(SC.Widget.Events.PLAY, function(eventData) {
//var j = this.name;
// next_widget = window['widget_'+i];
var widget_i = this;
for (var i = 0; i < iframes.length; i++) {
if(SC.Widget(iframes[i]) === widget_i){
if (i+1 >= iframes.length) {
its_the_last = true;
}else{
next_widget = SC.Widget(iframes[i+1]);
}


}else{

console.log('error');
}
};
});

widget.bind(SC.Widget.Events.FINISH, function(eventData) {
if (its_the_last == false) {
next_widget.play();
}

});


};

}());
</script>

关于javascript - 使用 Soundcloud 和 wordpress iram 播放下一首歌曲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29582577/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com