https://soundcloud.com/alo-wala/the-coconut-song
IFRAME
代码在任何网站上嵌入SoundCloud小部件。<iframe width="100%" height="300" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/203809866&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe>
https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/203809866
我的要求: 我想使用“共享”URL作为输入来生成Track ID,与WordPress使用oEmbed功能的方式完全相同,用于我自己的自定义字段。
请注意,我没有使用ACF。
提前致谢:)
答案 0 :(得分:2)
您可以通过SoundCloud的JS API获取任何歌曲的曲目ID:
<script src="https://connect.soundcloud.com/sdk/sdk-3.3.0.js"></script>
<script>
SC.initialize({
client_id: 'YOUR_CLIENT_ID'
});
// permalink to a track
var track_url = 'https://soundcloud.com/alo-wala/the-coconut-song';
var myCustomFunction = function (track) {
console.log( track ); // track.id gives you the ID of the song
// @TODO
// Do something with the song ID
};
SC.resolve(track_url).then(myCustomFunction);
</script>
将YOUR_CLIENT_ID
替换为SoundCloud App的ID。