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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Mp3 player


Go to End
Reply


19 Posts   3303 Views

Avatar
Maariak

Community Member, 20 Posts

14 March 2011 at 1:47am

I'm new with SS and trying to figure out things with the system, and what things are related to each other. I've already had a huge amount of help when reading old topics and reading tutorials, but the problem is with the language, though I can quite well read English, there are so many special terms that makes it's difficult with the tutorials, understanding all with different modules and extensions.

So, when I want e.g. to make it possible to upload a audiofile (mp3-file) to the site to play, I need DOM-module to manage the objects? But don't need FFmpeg to work in the server, if I'm not working with videos, converting them to other form? Do I need uploadify? (Well, I need it maybe to make it possible uploading other files, but with these mp3's?) In which tutorial or thread I find it explained what I need to add to the code to make upload-fields to appear in cms and how to make the player play the audiofile in the site when uploaded and saved? I'm working with site, where I need possibility to add audiofiles to play in different pages with the text and sometimes images aswell. I found many topics related to this audiofile-issue, but sometimes the difficulties with the language is making me just more confused..

Avatar
UncleCheese

Forum Moderator, 4094 Posts

14 March 2011 at 9:45am

Edited: 14/03/2011 9:46am

Hi, Maariak,

Setting up an MP3 page is pretty simple. You don't need FFMPEG, as long as you upload mp3 files. FFMPEG would allow you to upload other types of files and convert them to mp3, but as long as you're uploading in mp3 format, you'll be fine.

Try this code.. You'll need DataObjectManager and Uploadify.

MP3Page.php

class MP3Page extends Page {

static $has_many = array (
'MP3Files' => 'MP3File'
);

public function getCMSFields() {
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.MP3s", $dom = new FileDataObjectManager($this,'MP3Files','MP3File'));
$dom->setAllowedFileTypes(array('mp3'));
return $f;
}

}

MP3File.php

class MP3File extends DataObject {

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

static $has_one = array (
'MP3Page' => 'MP3'
);

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

MP3Page.ss

<% control MP3Files %>
$Player
<% end_control %>

Avatar
Maariak

Community Member, 20 Posts

14 March 2011 at 11:27am

Thanks! Just want to make sure do I put these in the folders where the other stuff are, mysite, templates etc. or under those folders in DOM or Uploadify folders? Well, I can of course try and test tomorrow in which way does it work :)

Avatar
UncleCheese

Forum Moderator, 4094 Posts

14 March 2011 at 2:08pm

The .php files should go in your_project/code and the .ss files should go in your_theme/Layout. Good luck!

Avatar
Maariak

Community Member, 20 Posts

14 March 2011 at 9:14pm

Thanks again, your answers are understandable even in my english :) There's still some thing I didn't get right, because the upload field doesn't appear in cms. I've got the .ss file under themes/(mytheme)/templates/Layout and and .php files under mysite/code, that should be the right place? And DOM (in dataobject_manager folder) and uploadify (in uploadify folder) are in the root. Is there some update needed, or do I need to modify other codes somehow?

Avatar
UncleCheese

Forum Moderator, 4094 Posts

15 March 2011 at 4:05am

When you create an MP3Page, you don't have a tab for "MP3s?"

Avatar
Maariak

Community Member, 20 Posts

15 March 2011 at 8:30am

When I'm creating a new page, there's no such option than MP3Page..

Avatar
UncleCheese

Forum Moderator, 4094 Posts

15 March 2011 at 2:45pm

You ran a /dev/build?

Go to Top