Jump to:

7938 Posts in 1541 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » New Feature: Audio and Video

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Go to End
Author Topic: 24660 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: New Feature: Audio and Video Link to this post

    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!

  • Shawn Parr
    Avatar
    Community Member
    60 Posts

    Re: New Feature: Audio and Video Link to this post

    "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.

  • DanStephenson
    Avatar
    Community Member
    115 Posts

    Re: New Feature: Audio and Video Link to this post

    Hi UncleCheese,

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

  • Lamin Barrow
    Avatar
    Community Member
    21 Posts

    Re: New Feature: Audio and Video Link to this post

    @ 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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: New Feature: Audio and Video Link to this post

    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.

  • Lamin Barrow
    Avatar
    Community Member
    21 Posts

    Re: New Feature: Audio and Video Link to this post

    @UncleCheese.

    Thanx for the clarifications. (o:)

  • NickJacobs
    Avatar
    Community Member
    144 Posts

    Re: New Feature: Audio and Video Link to this post

    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?

  • UncleCheese
    Avatar
    4085 Posts

    Re: New Feature: Audio and Video Link to this post

    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.

    24660 Views
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.