Flash Player

From TMM Wiki
Jump to navigationJump to search
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

Although CARMA provides a default flash player that clients can use, you are not limited only to the flash player that is provided with CARMA.

If you wish to use a custom flash player, you must first copy the relevant files into your carma/site_scripts/ directory and set up any sym-links if your files are individually linked.

Once that is done, you will need to adjust any of your site's templates to use your custom player instead of the default CARMA player. Most third party players will provide appropriate documentation for you to configure them.

The only other thing that is required 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 third party flash players require that the file path ends in a .flv extension in order to identify the video as a flash file. If this is the case, simply add .flv to the end of the file's URL to the view_clip.php file.


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 considerable amount of advanced features that make the player stand out.

It is now possible to seek through flash videos when using JW Player. However, this is only possible on JW Player version 5.0 or higher.

Get the Player

You can get the JW Player from http://www.longtailvideo.com/players/jw-flv-player/.

Once you've downloaded the 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, then 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','960','540','9');
  so.addVariable('file','{rebuild_link without="style" using="GET" encode=1 start=$smarty.server.HTTP_HOST}');

If you wish to use JW Player as the swfobject when playing back flash videos in CARMA, make sure that you set the name to jwplayer.swf when setting up the symbolic link.

Using a Flash Player on a different template

CARMA also allows you to use a Flash player on a page that is not view_clip.php, such as index.php. If you wish to do this, your video source must be manually encoded, as most flash players will want an encoded path URL. 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; this code assumes that the video short name is flv_high

Default Player

This code allows you to use our default CARMA flash player anywhere:

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

  <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';

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

<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");


JW Player

To use JW Player on a page that is not view_clip.php, simply follow the same instructions above to get the flash player, and add the following template code where 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');
  • $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.