2016-04-05 4 views
1

私のページには2つのサウンドクラウドウィジェットが隠されています。私はそれらをプレイボタンとして機能するdivにリンクしています。現在、最初のdivをクリックすると、最初のサウンドが開始されます。 2番目のdivをクリックすると、2番目のサウンドが開始され、1番目のサウンドが自動的に一時停止します。私は同時に音を再生したい。複数の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