我正在尝试创建一个应用程序,您可以在其中选择一种类型和BPM(每分钟节拍),它将加载到SoundCloud的嵌入式播放列表中。我被卡住了。
function playSomeSound(bpm, genre) {
SC.get('/tracks', {
genres: genre,
bpm: {
from: bpm
}
}, function(tracks) {
var random = Math.floor(Math.random() * 49);
SC.oEmbed(tracks[random].uri, {auto_play: false}, document.getElementById('target'));
});
}
window.onload = function() {
SC.initialize({
client_id: '5805346946bfb91c8b6efb6023cae463'
});
};
$('#generate').on('click', function(){
var genreSelect = document.getElementById("sel1");
var genre = genreSelect.options[genreSelect.selectedIndex].text;
var bpmSelect = document.getElementById("sel2");
var bpm = bpmSelect.options[bpmSelect.selectedIndex].text;
console.log(bpm);
console.log(genre);
playSomeSound(bpm, genre);
});
我一直收到错误:
并且:
未捕获的TypeError:无法读取null
的属性“33”
我想第二个错误是关于随机数,但我似乎无法弄清楚出了什么问题。