Difference between revisions of "Xmoov-php"

From TMM Wiki
Jump to navigationJump to search
Line 1: Line 1:
 +
{{CARMA1 Manual
 +
| show_extras_section = true
 +
}}
 +
 
Xmoov-php  can be used with Carma as a pseudo flash streamer.  This will allow your members to skip ahead in a video with out first having to download the entire file.  This has two great advantages:
 
Xmoov-php  can be used with Carma as a pseudo flash streamer.  This will allow your members to skip ahead in a video with out first having to download the entire file.  This has two great advantages:
 
* You members will be able to skip around the movie instantly
 
* You members will be able to skip around the movie instantly

Revision as of 11:50, 20 March 2009

CARMA
Extras
The Support Admin
Admin Areas
CARMA Home
Pseudo Streaming
Flash Player
Using mp4 Videos
Zipping Content
Third Party Content
X-Sendfile
Xmoov-php
TMMid

Xmoov-php can be used with Carma as a pseudo flash streamer. This will allow your members to skip ahead in a video with out first having to download the entire file. This has two great advantages:

  • You members will be able to skip around the movie instantly
  • When you a member skips a head of a video you will save a lot of bandwidth.

As xmoov-php is not part of CARMA, we can not provide direct support in setting it up for you, however below is a quick setup guide to help you.

In order to set this up you will need to retrieve the xmoov-php streamer and replace the default flash player with a media player that supports streaming. Additionally, you will need to make some minor adjustments to xmoov-php in order for it to work with carma.


XMOOV-PHP

You can get the script from http://xmoov.com/xmoov-php/source/ Save the file as as xmoov.php in side the carma/site_scripts/ directory.

Modifications

In order for xmoov-php to work with carma you need to modify the following code. (Your line number maybe slightly different)

Change 134:

define('XMOOV_GET_POSITION', 'position');

To:

define('XMOOV_GET_POSITION', 'start');


Change line 170:

if(file_exists($file) && strrchr($fileName, '.') == '.flv' && strlen($fileName) > 2 && !eregi(basename($_SERVER['PHP_SELF']), $fileName) && ereg('^[^./][^/]*$', $fileName))

To:

if(file_exists($file) && strrchr($fileName, '.') == '.flv' && strlen($fileName) > 2 && !eregi(basename($_SERVER['PHP_SELF']), $fileName))


Configuration

There are lots of configuration options that you can change in the xmoov-php script to make to behave differently. The only one you to change to get it to work with CARMA is the XMOOV_PATH_FILES configuration.

Change line 36:

define('XMOOV_PATH_FILES', 'library/media/video/');

To:

define('XMOOV_PATH_FILES', '/full/path/to/carma/cms_data/');


Flash Player

The default CARMA flash player does not have support for streaming. There are a few different flash players that have this support. Below is example instructions for JW Player[1]. We chose this player since it has a lot more advance features and is fairly simple to set up.


Get Files

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 site_scripts files the you will also need to set up a symlink for these files as well.

Template Modifications

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.

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:

{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('player.swf','mpl','470','320','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('flashvars','&file={$path}/{$filename}&streamer=xmoov.php');
so.write('player');
</script>

You should replace 470 and 320 with your desired width and height.

$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).

Once you have the {$carma_video} variable you can then show the video with code like this

{if $smarty.request.type == 'flv_high'}
{assign var=type value=$smarty.get.type}

<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','470','320','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('flashvars','&file={$carma_video.path}/{$carma_video.files.$type[0]}&streamer=xmoov.php');
so.write('player');
</script>


{/if}
  • $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.