我正在开发 CMS,希望让用户嵌入 Soundcloud 音乐和播放列表。
我想避免摆弄 API - 因为它似乎没有必要:)
相反,我只是将 iframe-src-url 与适当的参数拼凑在一起。
我无法在任何地方找到官方列表,所以我从这里和其他地方的各种帖子中收集了自己的列表:
&color=FF4444 // play-button and equalizer graphic (if not &visual=true)
&auto_play=false // shouls be obvious
&show_artwork=true // show the artist-graphic on the left
&show_comments=true // show fans commenst under equalizer
&show_playcount=true // number of times played @ bottom right
&hide_related=true // don't force user over to Soundcloud after play
&show_user=false // don't show uploaders name @ top left
&show_reposts=false // ?
&liking=false // dont show [Like] button
&visual=true // use artist-graphic for background (way cooler)
&buying=false // no Buy (iTunes) button
&sharing=false // no [Share] button
&download=false // no download button
&start_track=4 // start at specific track (for lists)
And guesed : )
&following=false (removes [Follow] when mouseover artwork)
我缺少哪些参数?
我真正想要的是列表的 Next 和 Previous 按钮。它们真的存在吗?
你失踪了:
download=true // Show/hide download buttons
sharing=true // Show/hide share buttons/dialogues
start_track=0 // Preselects a track in the playlist, given a number between 0 and the length of the playlist.
在文档中找到。
看起来
next()
和prev()
和skip(index)
都是小部件上的方法而不是参数。您可以通过保留当前曲目的索引并将值传递给 start_track
参数来解决此问题,作为获取下一个和上一个曲目的方法。
要添加随机播放或下一首曲目,您还可以结合嵌入式播放器,并添加触发以下 soundcloud 小部件功能的按钮
<script>
// Function to shuffle the SoundCloud playlist
function shufflePlaylist() {
// Use the SoundCloud widget API to control the player
var widget = SC.Widget(document.getElementById('soundcloud-player'));
// Get the total number of tracks in the playlist
widget.getSounds(function (sounds) {
// Generate a random index
var randomIndex = Math.floor(Math.random() * sounds.length);
// Play the track at the random index
widget.skip(randomIndex);
});
}
// Function to play the next track in the SoundCloud playlist
function nextTrack() {
// Use the SoundCloud widget API to control the player
var widget = SC.Widget(document.getElementById('soundcloud-player'));
// Play the next track
widget.next();
}