2016-04-05 42 views
1

我的頁面上隱藏了兩個soundcloud小部件。我已將它們鏈接到充當播放按鈕的div。目前,當第一個div被點擊時,第一個聲音開始。當第二個div被點擊時,第二個聲音開始並且第一個聲音自動暫停。我想讓聲音同時播放。我想讓多個SoundCloud小部件在同一頁面上同時播放

<div id = "bgSound"> 
    <iframe id = 'first' width="0" height="0" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/257485031?secret_token=s-i9opu&color=ff5500&inverse=false&auto_play=false&show_user=true"></iframe> 

    <iframe id = "second" width="0" height="0" scrolling="no" frameborder="no" src="https://api.soundcloud.com/tracks/257498359?secret_token=s-c9D5D&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"></iframe> 
</div> 
var widget1 = SC.Widget('first'); 
var widget2 = SC.Widget('second') 
$('.Top-Left').click(function() { 
    widget1.play(); 
}); 
$('.Top-Center').click(function() { 
    widget2.play(); 
}); 

回答

0

你應該能夠使用single_active=false保證既能在同一時間玩,否則就開始播放時,一個將暫停等。

<div id = "bgSound"> 
    <iframe id="first" width="0" height="0" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/257485031?secret_token=s-i9opu&color=ff5500&inverse=false&auto_play=false&show_user=true&single_active=false"></iframe> 

    <iframe id="second" width="0" height="0" scrolling="no" frameborder="no" src="https://api.soundcloud.com/tracks/257498359?secret_token=s-c9D5D&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true&single_active=false"></iframe> 
</div> 
var widget1 = SC.Widget('first'); 
var widget2 = SC.Widget('second') 
$('.Top-Left').click(function() { 
    widget1.play(); 
}); 
$('.Top-Center').click(function() { 
    widget2.play(); 
}); 

SoundCloud Widget Parameter Documentation

相關問題