Heathen wrote:Alternatively, I think there might be a better way to do this that only uses one bbcode for every case while making it much easier/intuitive for the user. I don't have the time to go into details right now but basically instead of using the bandcamp iframe directly, we'd use an iframe that points to a script hosted on tsis.com.
So I made a quick example of how this would work:
http://tsisbctest.byethost33.com/bc_player.php
Go to any bandcamp page, doesn't matter if it's an album, a specific track off an album or an standalone track, click on embed/share, pick any player, select either the wordpress or html code and paste it into the form field. It will display a medium-sized player regardless of which size you chose, thought it was easier that way. It also works if you just use the album ID.
So what the TSIS admins would have to do is upload that kind of script on the server (I've put the code source below, feel free to use it or to make your own version) and then have a new custom BBcode that would look like this:
BBCODE
HTML REPLACEMENT
Code: Select all
<iframe style="border: 0; width: 100%; height: 120px;" src="_PATH_TO_THE_SCRIPT_ON_THESKYISCRAPE?bc_string={TEXT}" seamless></iframe>
Script source:
- Spoiler: show
Code: Select all
<?php
if (preg_match('#^[0-9]+$#', $_GET['bc_string'])) { // if parameter is just a number, use it as album ID
echo '<iframe style="border: 0; width: 100%; height: 120px;" src="http://bandcamp.com/EmbeddedPlayer/album='.$_GET['bc_string'].'/size=medium/bgcol=ffffff/linkcol=0687f5/transparent=true/" seamless></iframe>';
}
elseif (preg_match('#track=([0-9]+)\D#', $_GET['bc_string'], $track)) { // if a track ID is included, use the standalone track player
echo '<iframe style="border: 0; width: 100%; height: 120px;" src="http://bandcamp.com/EmbeddedPlayer/track='.$track[1].'/size=medium/bgcol=ffffff/linkcol=0687f5/transparent=true/" seamless></iframe>';
}
elseif (preg_match('#album=([0-9]+)\D#', $_GET['bc_string'], $album)) { // if album ID is included
if(preg_match('#[ /]t=([0-9]+)\D#', $_GET['bc_string'], $track)) { // if a track number is included, play that track
echo '<iframe style="border: 0; width: 100%; height: 120px;" src="http://bandcamp.com/EmbeddedPlayer/album='.$album[1].'/size=medium/bgcol=ffffff/linkcol=0687f5/t='.$track[1].'/transparent=true/" seamless></iframe>';
}
else { // otherwise use the standard full album player
echo '<iframe style="border: 0; width: 100%; height: 120px;" src="http://bandcamp.com/EmbeddedPlayer/album='.$album[1].'/size=medium/bgcol=ffffff/linkcol=0687f5/transparent=true/" seamless></iframe>';
}
}
?>
That *should* work
The
evenbetterest way though would be to just use the URL of the track/album you want to embed and have the script make a request via the Bandcamp API and get the corresponding album/track ID. But they're not handing out any more developer keys for now and you can't use the API without one.