7912 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Mp3 player
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 2563 Views |
-
Mp3 player

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..
-
Re: Mp3 player

14 March 2011 at 9:45am Last edited: 14 March 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 %> -
Re: Mp3 player

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
-
Re: Mp3 player

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!
-
Re: Mp3 player

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? -
Re: Mp3 player

15 March 2011 at 8:30am
When I'm creating a new page, there's no such option than MP3Page..
| 2563 Views | ||
| Go to Top | Next > |

