Difference between revisions of "Flash Player"

From TMM Wiki
Jump to navigationJump to search
Line 14: Line 14:
 
</pre>
 
</pre>
  
To use a Flash player on a page that is not <tt>view_clip.php</tt>, such as <tt>index.php</tt>, your video source must be entered manualy.  Most flash players will want the path url encoded.  For more information about URL encoding, please see the [http://en.wikipedia.org/wiki/Percent-encoding Percent Encoding] article on Wikipedia.
 
  
 
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
 
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
Line 23: Line 22:
  
  
 +
=== JW Player ===
 +
The JW Player[http://www.longtailvideo.com/players/] 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.
  
== Using a Flash Player on a different template ==
+
==== 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.
  
There are two different formats to call up the flash player. The default way, by using view_clip.php, and by using $carma_video on another page.
+
==== Modifying the Template ====
[edit] view_clip.php
 
  
 
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:
 
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:
 
+
<pre>
{elseif $mime == 'video/x-flv'}
+
{elseif $mime == 'video/x-flv'}
{* Video type flv *}
+
{* Video type flv *}
 +
</pre>
  
 
and before
 
and before
  
{elseif $mime == 'video/mpeg'}
+
<pre>
{* Video type mpg, mpeg, mpe *}
+
{elseif $mime == 'video/mpeg'}
 +
{* Video type mpg, mpeg, mpe *}
 +
</pre>
  
 
Replace the flash code that is already there with the following code:
 
Replace the flash code that is already there with the following code:
 +
 +
<pre>
  
 
<script type="text/javascript" src="swfobject.js"></script>
 
<script type="text/javascript" src="swfobject.js"></script>
+
 
 
<div id="player">This text will be replaced</div>
 
<div id="player">This text will be replaced</div>
+
 
 
<script type="text/javascript">
 
<script type="text/javascript">
var so = new SWFObject('player.swf','mpl','470','320','9');
+
var so = new SWFObject('jw_player.swf','mpl','640','480','9');
 
so.addParam('allowscriptaccess','always');
 
so.addParam('allowscriptaccess','always');
 
so.addParam('allowfullscreen','true');
 
so.addParam('allowfullscreen','true');
so.addParam('flashvars','&file={$path}/{$filename}&streamer=xmoov.php');
+
so.addParam('flashvars','&file={rebuild_link without="style" using="GET" encode=1}%26ext%3Dfile.flv');
 
so.write('player');
 
so.write('player');
</script>
+
</script>  
  
You should replace 470 and 320 with your desired width and height.
 
[edit] $carma_video
 
  
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. You can do this with a call to {carma_show_video galid='<galid>' data_only=1} (unless you are on show_video.php, in which case this is done automatically for you).
+
</pre>  
  
Once you have the {$carma_video} variable you can then show the video with code like this
+
You should replace 640 and 480 with your desired width and height.
  
{if $smarty.request.type == 'flv_high'}
 
{assign var=type value=$smarty.get.type}
 
  
<script type="text/javascript" src="swfobject.js"></script>
+
 
+
== Using a Flash Player on a different template ==
<div id="player">This text will be replaced</div>
+
 
+
 
<script type="text/javascript">
+
To use a Flash player on a page that is not <tt>view_clip.php</tt>, such as <tt>index.php</tt>, 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 [http://en.wikipedia.org/wiki/Percent-encoding Percent Encoding] article on Wikipedia.
var so = new SWFObject('jw_player.swf','mpl','470','320','9');
+
 
so.addParam('allowscriptaccess','always');
+
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. You can do this with a call to {carma_show_video galid='<galid>' data_only=1} (unless you are on show_video.php, in which case this is done automatically for you).  Below is an example of this.  The code assumes that the video short name is ''flv_high''
so.addParam('allowfullscreen','true');
+
 
so.addParam('flashvars','&file={$carma_video.path}/{$carma_video.files.$type[0]}&streamer=xmoov.php');
+
 
so.write('player');
+
<pre>
</script>
+
 
 +
{carma_show_video galid='1303' data_only=1}
 +
 
 +
  {assign var=type value='flv_high'}
 +
 
 +
  <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=view_clip.php%3Fgalid%3D{$smarty.request.galid}%26num%3D{$smarty.request.num|default:0}%26type%3D{$smarty.request.type}%26ext%3Dfile.flv');
 +
  so.write('player');
 +
  </script>  
 +
 
  
  
{/if}
+
</pre>
  
    * $type is a variable holding the video short name
+
* $type is a variable holding the video short name
          o this can be changed to be $carma_video.files.flv_type if you always know the type of video.  
+
** this can be changed to be $carma_video.files.flv_type if you always know the type of video.  
    * [0] is the clip number you are showing starting at 0.
+
* [0] is the clip number you are showing starting at 0.

Revision as of 10:00, 9 April 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={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. You can do this with a call to {carma_show_video galid='<galid>' data_only=1} (unless you are on show_video.php, in which case this is done automatically for you). Below is an example of this. The code assumes that the video short name is flv_high


 

{carma_show_video galid='1303' data_only=1}

  {assign var=type value='flv_high'}

  <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=view_clip.php%3Fgalid%3D{$smarty.request.galid}%26num%3D{$smarty.request.num|default:0}%26type%3D{$smarty.request.type}%26ext%3Dfile.flv');
  so.write('player');
  </script> 



  • $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.
  • [0] is the clip number you are showing starting at 0.