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

MP3 player just sits at buffering.


Go to End


7 Posts   3758 Views

Avatar
Norris1976

Community Member, 9 Posts

30 September 2010 at 12:51am

Hi Uncle Cheese,

I have used all your useful replies on this forum to get up and running with my site.
I have a MessagePage, which has text content. But the MEssagePage also has:

static $has_one = array(
'MP3File' => 'AudioFile'
);

The Audio file is simply what I found on one of your forums threads:

class AudioFile extends DataObject {

static $db = array (
);

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

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

For uploading, I create the FileDataObjectManager like this:

$manager = new FileDataObjectManager(
$this, // Controller
'MP3File', // Source name
'AudioFile', // Source class
'File', // File name on DataObject
array(), // Headings
'getCMSFields' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);

Uploading the file works to a certain extent. The file is put into assets->uploads, and when I view the MEssagePage in the CMS, it has the MP3 associated with it.

In the MessagePage template I simply use $MP3File.File to render the player. The player renders ok, but when I try to play the audio, it just sits and displays the buffering message.

When I view the source of the page, the player is:

<object type="application/x-shockwave-flash" data="http://localhost/index.php/dataobject_manager/code/mp3/player.swf" id="audioplayer1" width="290" height="24">
<param name="movie" value="http://localhost/index.php/dataobject_manager/code/mp3/player.swf">
<param name="FlashVars" value="playerID=1&amp;soundFile=http://localhost/index.php/assets/">
<param name="quality" value="high">
<param name="menu" value="false">
<param name="wmode" value="transparent">
</object>

Is the sound file correct here? Should it not point to the assets/downloads folder and reference the actual mp3 file?

I'm not sure where the missing link is in the whole process. If I look at the database the tables are as follows:

MessagePage table:
+----+--------------+---------------+-----------+
| ID | Message_Date | Message_Title | MP3FileID |
+----+--------------+---------------+-----------+
| 8 | 2010-09-28 | NULL | 0 |
+----+--------------+---------------+-----------+

AudioFile table:
+----+-----------+---------------------+---------------------+---------------+--------+
| ID | ClassName | Created | LastEdited | MessagePageID | FileID |
+----+-----------+---------------------+---------------------+---------------+--------+
| 1 | AudioFile | 2010-09-29 12:23:53 | 2010-09-29 12:23:56 | 8 | 26 |
+----+-----------+---------------------+---------------------+---------------+--------+

Some of the File table columns:
+----+-----------+---------------------+---------------------+--------------+----------+-----------------------------------+---------+------+----------+---------+-----------+
| ID | ClassName | Created | LastEdited | Name | Title | Filename | Content |
+----+-----------+---------------------+---------------------+--------------+----------+-----------------------------------+---------+------+----------+---------+-----------+
| 1 | Folder | 2010-09-29 00:44:38 | 2010-09-29 00:44:38 | Uploads | Uploads | assets/Uploads/ | NULL |
| 4 | Folder | 2010-09-29 01:18:33 | 2010-09-29 01:18:33 | assets | assets | assets/Uploads/assets/ | NULL |
| 5 | Folder | 2010-09-29 01:18:37 | 2010-09-29 01:18:37 | new-folder | .. | assets/Uploads/assets/new-folder/ | NULL |
| 24 | MP3 | 2010-09-29 11:23:50 | 2010-09-29 11:23:50 | 29092010.mp3 | 29092010 | assets/Uploads/29092010.mp3 | NULL
| 25 | MP3 | 2010-09-29 11:49:31 | 2010-09-29 11:49:31 | 2.mp3 | 2 | assets/Uploads/2.mp3 | NULL |
| 26 | MP3 | 2010-09-29 12:23:50 | 2010-09-29 12:23:50 | 3.mp3 | 3 | assets/Uploads/3.mp3 | NULL |
| 23 | MP3 | 2010-09-29 11:19:30 | 2010-09-29 11:19:30 | 29092010.mp3 | 29092010 | assets/Uploads/29092010.mp3 | NULL |
+----+-----------+---------------------+---------------------+--------------+----------+------------------------------

In the MessagePage table, should the MP3FileID be set to the ID of the AudioFile?

Sorry for such a long post!! But I hope I have given you enough info so that yo can help me. I've seen you helping so many other people - I hope I can be added to that list!! :)

Thanks UC,
Tim

Avatar
UncleCheese

Forum Moderator, 4102 Posts

30 September 2010 at 3:09am

Your model looks weird to me. Why does MessagesPage have a $has_one MP3File? Shouldn't that be a $has_many?

And you should therefore, instead of $MP3File.File, you should be doing:

<% control MP3Files %>
$File
<% end_control %>

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

Avatar
Norris1976

Community Member, 9 Posts

30 September 2010 at 3:26am

Hey UC,

Thanks for replying. Each MessagePage has only one audio file associated with it.
If you think of a MessagePage as a blog page...each new Message will have one audio file.

Does that make sense or have I got it all mixed up?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

30 September 2010 at 3:41am

Well in that case, you don't need a FileDOM.. you just need a FileUploadField, right?

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

Avatar
Norris1976

Community Member, 9 Posts

30 September 2010 at 3:59am

Ok - thanks. I wasn't aware that DOM was only for multiple file scenarios.

I'm just a newbie at SS - would it be possible for you to give me a little sample or point me towards an existing one?

I really appreciate you taking the time to help me out.
T.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

30 September 2010 at 4:13am

I would start with my tutorials and docs on Uploadify here: http://www.leftandmain.com/silverstripe-modules/2010/08/26/uploadify/

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

Avatar
Norris1976

Community Member, 9 Posts

30 September 2010 at 9:43pm

Brilliant - that worked. I was over-complicating things.
I just needed to reference an MP3 from my MessagePage - rather than adding an extra layer of an AudioFile.
Again, thanks again for helping me out. Very much appreciated.

Tim