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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

workign with audio files / mp3


Go to End


24 Posts   4926 Views

Avatar
CHD

Community Member, 219 Posts

8 September 2010 at 5:57am

Hi,

im working on a website for a small band (www.silentrepublic.com) and i need to integrate a nice audio player.
that shouldnt be too difficult... but i dont know how my client will be able to manage the audio files that it actually plays??

ive tried searching around SS forums for a couple of days now(!) and just get confused... it looks like a lot of things are out of date when it comes to DataObjetcManager and FileObjectManager then swfUpload then Uploadify then gallery and imageGallery then imageGallery pro?! etc etc

im lost!

im using SS 2.4.1 - which i assume comes WITH DataObjectManager, right? so should i already be able to handle audio files??
because when i try and upload one... nothing happens. it says loading for a while, then the page refreshes and the file hasnt gone anywhere. i thought it could be down to my upload limits or somehting, but then i FTPd an mp3 file directly to assets, and when i ticked "audio" on the extension tab of "Gallery" (im using the gallery module 0.3) it just gave me a long error message on the front end about sort limits etc.

can anybody shed any light on this?

thanks in advance!

Avatar
UncleCheese

Forum Moderator, 4102 Posts

8 September 2010 at 6:28am

I suggest checking out the media features of FileDataObjectManager:

http://www.leftandmain.com/silverstripe-screencasts/2010/08/23/filedataobjectmanager-media-features/

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
CHD

Community Member, 219 Posts

8 September 2010 at 6:32am

Thanks UC, i already watched them, they look really interesting!
the problem is, im a little confused about the dataObjectManager part, i thought it came with SS 2.4.1 already.
also, im using gallery 0.3 and im worried about compatibility issues?

would you mind giving me a VERY brief step by step on this? (i know you're busy!)

just something like:

1) download x from here
2) download y from here
3) update page.php code
4) update page.ss template
5) done!

god i wish it were that easy.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

8 September 2010 at 7:07am

Edited: 08/09/2010 7:07am

Sure. You can download the DataObjectManager module and the Uploadify module from my website, and install them into the "dataobject_manager" and "uploadify" directories in your SilverStripe root.

Here's an example for the implementation:

AudioPage.php

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 {}

AudioFile.php

class AudioFile extends DataObject {

static $db = array (
'Title' => 'Text',
'Description' => 'Text'
);

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

public function getCMSFields() {
$f = new FieldSet (
new Textfield('Title'),
new TextareaField('Description'),
$u = new FileUploadField('File')
);
$u->setFileTypes(array('mp3'));
return $f;
}
}

AudioPage.ss

<% control AudioFiles %>
$File.Player
<% end_control %>

Can't promise it's free of parse errors, but that ought to get you started.

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
CHD

Community Member, 219 Posts

8 September 2010 at 7:10am

that was EXACTLY what i needed.
already discovered i needed to install dataobjectmanager afterall...so done that. and uploadify. got them working.
(although i must admit i think the UI for Gallery 0.3 is better? the pop up for Facebox is about 200px wide?? and a lot of the text isnt aligned in buttons correctly?) not to sound ungrateful of course!

going to give your code above a go now and let you know how it turns out.

cheers!

p.s - is this the only way you can currently work with audio in SS? seems a bit odd that there isnt something off the shelf already? rather than writing code etc manually...

Avatar
UncleCheese

Forum Moderator, 4102 Posts

8 September 2010 at 7:33am

That doesn't sound right. Send me a screenshot..

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
CHD

Community Member, 219 Posts

8 September 2010 at 7:38am

ok i'll do it in a minute... i D/L'd from here:
http://carlinowebdesign.svn.beanstalkapp.com/modules/trunk/image_gallery

is that the right version?

Avatar
CHD

Community Member, 219 Posts

8 September 2010 at 7:48am

hmmm i copied your code exactly, and created an audio page fine, but i still cant upload an mp3!
it gets to 100% then the box is just blank. it just says No files attached.

ive put this in my htaccess file in the httpdocs folder:
php_value upload_max_size "20M"
php_value post_max_size "20M"
php_value max_execution_time 300

is that right?

Go to Top