Jump to:

7938 Posts in 1541 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » workign with audio files / mp3

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3
Go to End
Author Topic: 3051 Views
  • CHD
    Avatar
    Community Member
    218 Posts

    workign with audio files / mp3 Link to this post

    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!

  • UncleCheese
    Avatar
    4085 Posts

    Re: workign with audio files / mp3 Link to this post

    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

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: workign with audio files / mp3 Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: workign with audio files / mp3 Link to this post

    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

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: workign with audio files / mp3 Link to this post

    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...

  • UncleCheese
    Avatar
    4085 Posts

    Re: workign with audio files / mp3 Link to this post

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

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

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: workign with audio files / mp3 Link to this post

    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?

  • CHD
    Avatar
    Community Member
    218 Posts

    Re: workign with audio files / mp3 Link to this post

    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?

    3051 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.