如何在JavaScript SDK 3.0.0中同时播放多首曲目?
SC.stream('/tracks/' + trackID1)
.then(function(player) {
player.play();
});
setTimeout(function() {
SC.stream('/tracks/' + trackID2)
.then(function(player) {
/*** track2 is played after stopping track1 ***/
player.play();
});
}, 5000);
我可以在JavaScript SDK 2.0.0中完成。
SC.stream('/tracks/' + trackID1, function(player) {
player.play();
});
setTimeout(function() {
SC.stream('/tracks/' + trackID2, function(player) {
/*** track2 is played without stopping track1 ***/
player.play();
});
}, 5000);
答案 0 :(得分:0)
这是:
var scplayers = [];
SC.stream("/tracks/"+sctrack.id, {autoLoad: true}).then(function(player){
player.options.debug = true;
player.options.useSinglePlayer = false;
//this sets a separate id for the same track so it gets handled as a
//separate track
player.options.soundId = 111; //ignore if the tracks are always different
scplayers[0] = player;
});
SC.stream("/tracks/"+sctrack.id, {autoLoad: true}).then(function(player){
player.options.debug = true;
player.options.useSinglePlayer = false;
//this sets a separate id for the same track so it gets handled as a
//separate track
player.options.soundId = 222; //ignore if the tracks are always different
scplayers[1] = player;
});
scplayers[0].play();
scplayers[1].play();
作为额外的我添加了soundId部分。这允许您使用偏移多次播放相同的轨道,而不是。