Jump to:

22979 Posts in 11815 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Html 5

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1575 Views
  • studio6
    Avatar
    Community Member
    14 Posts

    Html 5 Link to this post

    hay i want to use html5 to play video in ss. i cant add it in the html edit in the cms and would like to know if there is a way i can use it. i wan to do this coz i cant seem to get a flash player to play flv files something to do with the paths i think but cant work it out and html5 is a far easyer way to play video

    is there anyone out there that can help me here???

  • ryanwachtl
    Avatar
    Community Member
    46 Posts

    Re: Html 5 Link to this post

    You could extend your page model and add some File fields for the video

    static $has_one = array(
    'VideoOgg' => 'File',
    'VideoMp4' => 'File',
    'VideoPlaceholder' => 'Image'
    );

    add the fields to the CMS,

    public function getCMSFields()
    {
    $f = parent::getCMSFields();

    $f->addFieldToTab("Root.Content.Video",
    new FileIFrameField('VideoOgg', 'Upload .ogv Video'));

    $f->addFieldToTab("Root.Content.Video",
    new FileIFrameField('VideoMp4', 'Upload .mp4 Video'));

    $f->addFieldToTab("Root.Content.Video",
    new ImageField('VideoPlaceholder', 'Upload Placeholder Image'));

    return $f;
    }

    and then place the video tag into your template

    <% if VideoOgg %>
    <video controls width="600" height="400" <% if VideoPlaceholder %>poster="$VideoPlaceholder.URL"<% end_if %>>
    <source src="$VideoOgg.URL" type="video/ogg">
    <% if VideoMp4 %>
    <source src="$VideoMp4.URL" type="video/mp4">
    <% end_if %>
    <!-- Flash Fallback -->
    </video>
    <% end_if %>

    You can get a lot fancier, this just a simple example.

    1575 Views
Page: 1
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.