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

New Feature: Audio and Video


Reply

150 Posts   24919 Views

Avatar
UncleCheese

3 June 2009 at 9:37am (Last edited: 3 June 2009 9:38am), 4085 Posts

New Feature

Thumbnails are now returned as Image objects rather than generated HTML. This means you now have much more control over the way your video thumbnails display. Use the function $VideoThumbnail to get your thumbnail object, then run whatever formatting you want on it. Examples:

<% control MyVideo %>
$VideoThumbnail.SetWidth(500)
$VideoThumbnail.CroppedImage(100,100)
<img src="$VideoThumbnail.URL" class="my-class" />
<% end_control %>

Thumbnail is now cut during the "processing" phase of the upload. No more template lag! FLV will cut a fairly large thumbnail to give you the most options for resizing. By default the values are 640x480, but if you want to make them bigger, just reset the class vars in your _config.php

FLV::$default_thumbnail_width = 800;
FLV::$default_thumbnail_height = 600;

Enjoy!

Avatar
Shawn Parr

4 June 2009 at 6:23am Community Member, 60 Posts

"Try it with the latest build, Shawn. Added AAC and AIFF to the list."

I can upload files if they have those extensions (i.e. .aac, .aiff), but the flash player doesn't play them. It is probably a limitation in the flash player. No big deal. Although I should mention that the extension for AAC usually is .m4a, and many programs spit out aiff with .aif

Although I wouldn't spend much time tweaking that since I think the player will still not work anyway... :)

Basically the player loads, then when you click the play icon, it says it is buffering, and the bar fills up. But no audio actually plays. It just sits there. The MP3s load up and play right away (I've got Gigabit between me and the server, no VPN's).

I think most of my users who would be interested in the functionality are going to be totally fine with mp3. I only tested other formats just to know what would happen. Since I can set the allowed type I can make it end user proof.

Avatar
DanStephenson

10 June 2009 at 5:59am Community Member, 115 Posts

Hi UncleCheese,

What are you using to do video conversion, and grabbing dynamic thumbnails?

Avatar
Lamin Barrow

10 June 2009 at 6:17am (Last edited: 10 June 2009 6:25am), Community Member, 21 Posts

@ DanStephenson.

I think he's using the PHP version of the open-source FFMPEG (http://ffmpeg-php.sourceforge.net/) video conversion library to do all of that. Note that to have video and dynamic thumbnail grabbing features available to your site, you must FFMPEG-PHP extension already installed on your dev machine or server.

Hope this helps.

Avatar
UncleCheese

10 June 2009 at 6:54am 4085 Posts

No, it's not the PHP extension. That isn't full-featured, as it turns out. I'm using the Linux package. You can just yum it down. Super easy install.

Most users of the video features have just asked their sys admin to install it and haven't had any problems, other than setting FLV::set_ffmpeg_root('/usr/bin... etc') to properly configure it.

Some hosts come with it pre-installed, like Site5. You can test whether you have FFMPEG installed on your server by putting:

FLV::echo_ffmpeg_test();

in your _config.php.

Avatar
Lamin Barrow

10 June 2009 at 7:01am Community Member, 21 Posts

@UncleCheese.

Thanx for the clarifications. (o:)

Avatar
NickJacobs

10 June 2009 at 11:28am Community Member, 144 Posts

Hi, I'm having the same problem as others in this thread.....I'm getting the following error "Method 'forTemplate' not found in class 'File'"

code as follows:

class Resource extends DataObject
{
   static $db = array (
      'Name' => 'Text',
      'Description' => 'Text'
   );
   
   static $has_one = array (
      'Attachment' => 'File',
      'Page' => 'Page'
   );
   
   public function getCMSFields_forPopup()
   {
      return new FieldSet(
         new TextField('Name','Name'),
         new TextareaField('Description','Description'),
         new FileIFrameField('Attachment','Attachment')
      );
   }
}

******************************

class Page extends SiteTree {
   
   public static $db = array(   );   
   public static $has_one = array();   
   static $has_many = array ('Resources' => 'Resource');
      
   public function getCMSFields()
   {
      $f = parent::getCMSFields();
      
      //setup resources tab
      $manager = new FileDataObjectManager(
         $this,
         'Resources',
         'Resource',
         'Attachment',
         array(
            'Name' => 'Name',
            'Description' => 'Description'
         ),
         'getCMSFields_forPopup'
         
      );
      
      $manager->setAllowedFileTypes(array('pdf','doc','docx','flv','mp3'));       
      $manager->setBrowseButtonText("Upload File");       
      $manager->setUploadFolder('resources-'.$this->URLSegment);      
      $manager->setGridLabelField('Name');       
      $manager->setPluralTitle('Resources');      
      $manager->setParentClass('Page');      
      
      $f->addFieldToTab("Root.Content.ResourceFiles", $manager);
      
      return $f;
      }   
}

If I upload flv's it works fine, but if I upload pdfs or docs it breaks. Any ideas?

Avatar
UncleCheese

10 June 2009 at 2:02pm 4085 Posts

PDFs and DOCs don't have a forTemplate method because they fall in to the generic File class. You're going to have to sniff out on your template whether the file is and FLV/MP3 or not. FileDataObjectManager detects the FLV or MP3 extension and "upgrades" those files to the FLV or MP3 class, which have their own forTemplate methods that render Flash players.

Standard file objects don't have a forTemplate method, though, so you'll have to do something like a link to $File.URL or however you want to handle it.