first of all this is not a cry for a perfectly coded solution but it would be perfect if someone could at least give me some tips on how to solve this problem which is: I have this custom WordPress site for a record label. On this site there is of course a section showing the releases of every of their artist’s tracks.
The client needs to upload all their tracks to Soundcloud. In the WP backend they can enter the name of the album, upload a cover image and add as many tracks as they want using MagicFields for WordPress. After adding the album information and the track names they can enter the URL of the specific track hosted on Soundcloud. WP then lists all of these tracks as following:
(It seems I can not upload images so here is the link)
http://postimage.org/image/22ob8ymys/
On the left side you can see Soundmanager2’s 360 visualization. Right now the MP3s are uploaded to the label’s website (which I need to change) and the link of each list item looks something like this:
<ol>
<a href="#" onclick="if (threeSixtyPlayer.lastSound) { threeSixtyPlayer.lastSound.stop(); } document.getElementById('mp3').href = 'track1.mp3'; threeSixtyPlayer.handleClick({target: document.getElementById('mp3')});"><li>Track 1</li></a>
...
</ol>
As you can see the link leads to specific files, ending with the extension .mp3 to make it playable via SM2. But as you might know you can not easily access an MP3 on Soundcloud. Passing an URL like ‘www.soundcloud.com/artist/track1’ seems not to work.
I’ve made some research about Soundcloud’s API but guess what, it’s too complex for me to understand (that’s why I am here).
The documentation on http://soundcloud-sm2.heroku.com/docs/application.html came quite close to what I was looking for but unfortunately I can not use it because the tracks should not be included on the site via JS but PHP.
I hope someone of you could give me some tips on how to solve this specific problem.
Thanks for reading this far 😉
You need to get the stream URI using Soundcloud’s API. You can get the stream URI by making a request like:
where
5677638
is the id of the track you want to get the info of.But you do need an API key which you can request for free at: Soundcloud Developers
So after that you can make a request like:
That request will get you an json encoded string which contains all the info about the track, e.g.:
As you can see there is an
stream_url
item which contains the URL you can use to ’embed’ the track using SoundManager just like you would with a local mp3.