Difference between revisions of "Flash Player"

From TMM Wiki
Jump to navigationJump to search
Line 55: Line 55:
 
so.addParam('allowscriptaccess','always');
 
so.addParam('allowscriptaccess','always');
 
so.addParam('allowfullscreen','true');
 
so.addParam('allowfullscreen','true');
so.addParam('flashvars','&file={rebuild_link without="style" using="GET" encode=1}%26ext%3Dfile.flv');
+
so.addParam('flashvars','&file=http%3A%2F%2F{$smarty.server.HTTP_HOST}%2F{rebuild_link without="style" using="GET" encode=1}%26ext%3Dfile.flv');
 
so.write('player');
 
so.write('player');
 
</script>  
 
</script>  
Line 63: Line 63:
  
 
You should replace 640 and 480 with your desired width and height.
 
You should replace 640 and 480 with your desired width and height.
 
 
  
 
== Using a Flash Player on a different template ==
 
== Using a Flash Player on a different template ==

Revision as of 15:54, 16 October 2009

CARMA
Video Content Admin
The Video Content Admin
Adding Content
Video Clips
Out of Order Video Thumbnails
Content Set Locations
Content Set Categories
Video Format
Flash Player
Generate Flash Videos
Using mp4 Videos
Video Content Names

Using a Custom Flash Player

You are not limited to use the flash player that is provided with Carma. To use a custom flash player you need to copy the files into the carma/site_scripts/ directory and set up any sym-links if your files are linked individually. After that is done you have to adjust the templates to use your player instead of ours. Most 3rd party players provide documentation in order to configure them. The only thing you will need for use is the URL to the flash file. If the flash player is being used on view_clip.php, you can simply use the {rebuild_link} template function:

{rebuild_link without="style" using="GET" encode=1 start=$smarty.server.HTTP_HOST}


Some flash players may need the path to end in a .flv extension so it knows it is a flash file. If this is the case then add then to the end of the URL to view_clip.php

&ext=file.flv

This will assist in helping the flash player identifying the file as flash.


JW Player

The JW Player[1] is a popular and freely available flash player. It is fairly simple to set up and has a lot of advance features that make the player stand out.

Get the Player

You can get the JW Player from http://www.longtailvideo.com/players/jw-flv-player/. Once you've download file, unzip its contents and upload the following files to the site_script directory in carma/site_scripts.

  • player.sqf
  • swfobject.js

If you have your member site set up with symbolic links to the individual files in site_scripts, instead of the folder, the you will also need to set up a symbolic link for these files as well.

Modifying the Template

On the view_clip template you will need to change the code for the flash mime type. You only need to edit the code after:

 
 {elseif $mime == 'video/x-flv'}
 {* Video type flv *}

and before

 
 {elseif $mime == 'video/mpeg'}
 {* Video type mpg, mpeg, mpe *}

Replace the flash code that is already there with the following code:

 

<script type="text/javascript" src="swfobject.js"></script>

<div id="player">This text will be replaced</div>

<script type="text/javascript">
var so = new SWFObject('jw_player.swf','mpl','640','480','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('flashvars','&file=http%3A%2F%2F{$smarty.server.HTTP_HOST}%2F{rebuild_link without="style" using="GET" encode=1}%26ext%3Dfile.flv');
so.write('player');
</script> 


You should replace 640 and 480 with your desired width and height.

Using a Flash Player on a different template

To use a Flash player on a page that is not view_clip.php, such as index.php, your video source must be entered manually. Most flash players will want the path url encoded. For more information about URL encoding, please see the Percent Encoding article on Wikipedia.

If you are calling the flash player from another page you will first have to get the video data for the galid belonging to your video. Below is an example of this. The code assumes that the video short name is flv_high

Default Player

This code is how you could use our default player anywhere

{assign var=type value='flv_high'}
{assign var=galid value='1303'}
{assign var=num value='0'}

{literal}
  <script type="text/javascript" src="swfobject.js"></script>
  
  <script language="JavaScript" type="text/JavaScript">
      function en_flash_thisMovie(en_flash_movieName) {
      if(window.document[en_flash_movieName]) {
        return window.document[en_flash_movieName];
      }
      if(navigator.appName.indexOf("Microsoft Internet")==-1) {
        if(document.embeds && document.embeds[en_flash_movieName])
          return document.embeds[en_flash_movieName]; 
      }
      else {
        return document.getElementById(en_flash_movieName);
      }
    }
  
    function en_flash_resize(en_flash_args) {
      var en_flash_arr = en_flash_args.split('_');
      document.getElementById('videoholder').style.width = en_flash_arr[0] + 'px';
      document.getElementById('videoholder').style.height = en_flash_arr[1]+ 'px';
    }
  </script>
{/literal}

<div id="videoholder" style="width:100%;height:100%;"> 
</div>

<script type="text/javascript">
  var so = new SWFObject("flash_player.swf?{$time}", "flash", "100%", "100%", "8");
  so.addParam("quality", "high");
  so.addParam("scale", "noscale");
  so.addParam("swLiveConnect", "true");
  so.addParam("allowFullScreen", "true");

  so.addVariable("en_flash_movie_width", "auto");
  so.addVariable("en_flash_movie_height", "auto");
  so.addVariable("en_flash_movie_name", "http%3A%2F%2F{$smarty.server.HTTP_HOST}%2Fview_clip.php%3Fgalid%3D{$galid}%26num%3D{$num|default:0}%26type%3D{$type}%26ext%3Dfile.flv");
  so.addVariable("en_flash_jump_value", "6");

  so.write("videoholder");
</script>

JW Player

After following the same instructions above to get the flash player you would just need to add this template code were you want the flash player.

 
{assign var=type value='flv_high'}
{assign var=galid value='1303'}
{assign var=num value='0'}

<script type="text/javascript" src="swfobject.js"></script>
<div id="player">This text will be replaced</div>
<script type="text/javascript">
var so = new SWFObject('player.swf','mpl','640','480','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('flashvars','&file=http%3A%2F%2F{$smarty.server.HTTP_HOST}%2Fview_clip.php%3Fgalid%3D{$galid}%26num%3D{$num|default:0}%26type%3D{$type}%26ext%3Dfile.flv');
so.write('player');
</script> 
  • $galid is the id of the video set
  • $type is a variable holding the video short name
    • this can be changed to be $carma_video.files.flv_type if you always know the type of video.
  • $num is the clip number you are showing, starting at 0.