Flow Player Video Helper

By Stanislav Sokolov (Ratso)
This helper will add Flowplayer flash video player to your page. Note: With this helper you can add only one player. Though, this helper is very simple, but maybe someone can enhance it.

Installation

First, you need to download flowplayer. You can get it here: http://flowplayer.org/
Now extract downloaded file to any folder and:

  1. Copy examples/js/flashembed.min.js to app/webroot/js
  2. Copy examples/js/css/common.css to app/webroot/css/flash.css

This is video.php. Copy it to app/view/helpers. You need to change some urls to meet your needs.

Helper Class:

Download code <?php 
<?php
/*
        Flow Player Helper (free video player)
        Requed helpers HTML, Javascript
*/
Class VideoHelper extends AppHelper {

var 
$helpers = array('Html''Javascript');
    
    function 
loader($loadcss=false) {
        
$out=$this->Javascript->link('flashembed.min');
        if (
$loadcss=true$out.=$this->Html->css('flash');
        return 
$this->output($out);
        
    }    
    
    function 
player ($file$div$autoplay=false$width=400$height=290 ) {
        
        if (
$autoplay=True) {$autoplay="true";} else $autoplay="false";
        
$out='
        <script>
    window.onload = function() {  
         flashembed("'
.$div.'",             
            {
                src:"http://www.example.com/files/FlowPlayerDark.swf",
                width: '
.$width.', 
                height: '
.$height.'
            },
            
            {config: {   
                autoPlay:'
.$autoplay.',
                controlBarBackgroundColor:"0x2e8860",
                initialScale: "scale",
                videoFile: "'
.$file.'"
            }} 
        );
    }
    </script>    
        '
;
        return 
$this->output($out);
    }
}

?>
?>

How to use

You need to load Html and Javascript helpers in app_controller or any over controller. Next we need to initialize player in your template.

View Template:

Download code
...
<head>
<?php
echo $video->loader(true);
echo 
$video->player("http://www.example.com/files/godfother.flv""example"false720576);
?>
</head>
...

And now we need to add this example div to our view page there video will be played

View Template:

Download code
<?php foreach($movies as $movie): ?>
    <h3><?php e($movie['Movie']['title']); ?></h3>
<div id="example"></div>
<?php endforeach; ?>

Thats all, falks!

 

Comments 702

CakePHP Team Comments Author Comments
 

Comment

1 Re: Enhancement

Hi. As you suggested, I tried to write someenhancements for your Helper. I'd like to show you and discuss with you, before submitting it to Bakery or the some other site. You may contact me to arialdomartini@bebox.it

Bye!

--
Arialdo Martini
Did you publish it yet? Sorry for so long... Just noticed your comment. You can contact me by icq 343409203.
Posted Jun 17, 2009 by Stanislav Sokolov