Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

MP3 files in single audio player (xml/ playlist)

Go to End



Community Member, 219 Posts

11 September 2010 at 1:01am

So i've got audio files playing fine on my site ( but i want to install a single player now with the ability of adding a playlist. but im a bit rubbish with the real technical side of this stuff!

here's what i have so far (thanks to Uncle Cheese)


class AudioFile extends DataObject {

static $db = array (
'AudioTitle' => 'Text',
'Description' => 'Text'

static $has_one = array (
'AudioPage' => 'AudioPage',
'File' => 'MP3'

public function getCMSFields() {
$f = new FieldSet (
new Textfield('AudioTitle'),
new TextareaField('Description'),
$u = new FileUploadField('File')
return $f;


class AudioPage extends Page {

static $has_many = array (
'AudioFiles' => 'AudioFile'

public function getCMSFields() {
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.Audio", new FileDataObjectManager($this));
return $f;
class AudioPage_Controller extends Page_Controller {}



class MP3 extends File 
	static $allowed_file_types = array (

	private static $player_count = 0;
	public function Player()
		return $this->customise(array(
			'SWFLink' => Director::absoluteURL('dataobject_manager/code/mp3/player.swf'),
			'MP3Link' => Director::absoluteURL($this->URL),
			'Count' => self::$player_count
	public function forTemplate()
		return $this->Player();


<% require javascript(dataobject_manager/code/mp3/audio-player.js) %>

<object type="application/x-shockwave-flash" data="$SWFLink" id="audioplayer1" height="24" width="290">
	<param name="movie" value="$SWFLink">
	<param name="FlashVars" value="playerID={$Count}&amp;soundFile={$MP3Link}">
	<param name="quality" value="high">
	<param name="menu" value="false">
	<param name="wmode" value="transparent">

<div id="ColumnLeft" class="typography">
<% control AudioFiles %>
<% end_control %>

now can anybody please hep me turn this into a playlisted audio player somehow?
i imagine it will need to be turned into an xml somehow? i think i can figure out how to change the mp3 file location to an xml location, but then how do i auto generate the xml feed using dataobjectmanager on uploads??

hope this makes sense!

thanks so much for any help in advance :)