iPhone, iPad and Flash Video with SWF Tools and Drupal 6

Drupal

When updating my website recently, I decided to add iPhone and iPad video playback to my video player in case a visitor to my site did not have Flash installed. I more or less followed the tutorial here, from gotoAndLearn, but updated it to be able to use the SWF Tools module for Drupal.

 

1.

If you have SWF Tools installed on your Drupal site and have your video encoded into files that are playable by the Flash Player and Apple devices, you can use this PHP code to embed the Flash video with HTML 5 video as back-up. The settings I used for encoding an mp4 would not play when I tested this, so I converted the video to an iPhone version by using the "Create iPod/iPhone Version" from iTunes.

2.

Using this code, you can define the alternative content that shows up on a per swf basis. One could also specify a .ogg video to be used if a Firefox user does not have Flash installed, using similar HTML 5 tags.

Note - must have the PHP input filter enabled to be able to use this PHP code.

<?php
print swf('http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf',
    array
    (
       
'params' => array
        (
           
'width' => '720',
           
'height' => '406',
           
'wmode' => 'transparent',
        ),
       
'flashvars' => array
        (
            
'src' => 'http://www.samwirch.com/files/demo-reel-2010.mp4',
            
'controlBarMode' => 'docked',
            
'poster' => 'http://www.samwirch.com/files/demo-reel-2010.jpg',
        ),
       
'othervars' => array
        (
            
'html_alt' => '&lt;video controls="controls" poster="http://www.samwirch.com/files/demo-reel-2010.jpg" width="720" height="406">
        &lt;source src="http://www.samwirch.com/files/demo-reel-2010.m4v" type="video/mp4" />
&lt;/video>'
,
        ),
    )
);
?>
Posted on Fri, 09/03/2010
Posted in

Comments

Hi this looks great. I got it all installed and working but in my case on iphone it doesn't work. instead of actually interpreting the tag it just shows the whole tag as plain text instead of embedding the video . I am using panels as well so maybe that breaks something. The flash embed works correctly but the iOS (4.1) isn't working instead of the video embed it shows the actual embed text for me. PHP code is set as input. Not sure what else to try. Any ideas? thanks

I would double check the values you have for the html_alt attribute. You might need to change the &lt; to the symbol <. Or change both the > to their ampersand escaped equivalents. Or maybe their is a different input format rule for panels that you may need to change. For example it may not let you post HTML tags (check to see if HTML filter or HTML corrector is turned on). If you can see the Flash embed it is most likely not with the PHP syntax, but rather the HTML syntax.

I'm trying to do exactly this but I'm not following what exactly you do with this code. Are you putting it in a block? Is there a way to get this to work with a CCK filefield? I tried using it with a custom formatter but I didn't have any luck that way.

Yes, you can put it in a block, or in the body of a page. Basically, this code just just replaces the < object> and <embed> code that you would usually use to embed a flash video player. Not sure about how it would work with a CCK filefield.

The above code is not executing in iPhone.....can u help...me for that

If you can see the video trying to be loaded on the iPhone, but when you press play and it won't load, that is most likely due to the video being in the wrong format. The easiest way to get the video in the correct format is to use iTunes and select the menu option to create iPhone/iPod version. Then upload and link that video file to the <video> tag.

Post new comment

The content of this field is kept private and will not be shown publicly.