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