<?php
// SNIPPET NAME: JWPlayer
// SNIPPET DESCRIPTION: A Snippet to place the JW FLV Player into a MODx Page
// VERSION 1.1
/*---------------------------------
================
:: CREDIT
================
This Snippet writes the code necessary to properly display the JW FLV player in MODx
THE JW FLV player is developed by Jeroen Wijering and is available at http://www.jeroenwijering.com/
Respect the developer's license: http://creativecommons.org/licenses/by-nc-sa/3.0/
MODx Snippet thingie by George D. Carstensen
www.anablepo.com
=======
1.0.1 Changelog
Multiple player per page better supported - thanks keshon
================
:: INSTALL
================
- Download the .zip at http://www.jeroenwijering.com/?item=JW_FLV_Player
- Unzip the file and rename it 'embed'
- Place /embed/ inside another directory entitled 'JWPlayer'
- Upload the JWPlayer directory to your assets/snippets/ directory
- Paste the text of this document in a snippet - entitled 'JWPlayer'
- Reccommended: Create a Templave Variable (TV) Called 'videosrc' and
Set the input type as 'file'
* I'm not packaging these files in the snippet download - because the player is
sometimes updated - and you probably want the newest one.
* Tested and written for JW FLV MEDIA PLAYER v. 4.0
================
:: USAGE
================
- Simple! Place the snippet call [[JWPlayer? &src=[*videosrc*]]] in your document.
- If you chose to create the TV above, use the call [[JWPlayer? &src=[*videosrc*]]]
and set the filename using the TV dialog in your document.
- If you choose to use paramaters, simply append them like so:
[[JWPlayer? &src=[*videosrc*]¶meter1=value1¶meter2=value2&]]
(kind-of like a URL line, but make sure there's a space between the ? and the &.)
- If you use the player more than once in a page with different sources, scrap the TV and do this:
[[JWPlayer? &src=path/to/file]]
================
:: AVAILABLE PARAMETERS
================
*- All of these parameters defaults are editable below
&width - width in px
&height - height in px
&logo - location of logo from MODx install root. (ex: assets/images/monkeys/logo.png )
&fullscreen - enables fullscreen function ( true | false )
&stretching - specifies stretch type (uniform | fill | exactfit | none )
-'uniform' plays the video and fills up the frame - using black bars to perserve aspect
-'fill' fills up the frame while maintaining aspect ratio - may result in clipping.
-'exactfit' stretches the movie to fit the frame - aspect ratio is out the window
-'none' doesn't stretch at all - just plays the video in it's original dimensions.
Clipping possible.
&controlbar - displays controlbar either as a floaty transparent thing, or the traditional
bottom ( float | over | none )
================
:: FORMATS
================
Baseline h.264. The player isn't too picky about the file extension - I use .mp4, but I tested it with .flv and .m4v.
To be kind, stick to about 600/700 mb/sec or less.
---------------------------------*/
//EDITABLE PARAMETER DEFAULTS - only edit the stuff in Quotes - " ~ "
$width = (isset($width)) ? strtolower($width) : "550" ; //default video width in px
$height = (isset($height)) ? strtolower($height) : "434" ; //default video height in px
$logo = (isset($logo)) ? strtolower($logo) : "assets/images/system/vidlogo.png" ; //location of logo for overlay
$fullscreen = (isset($fullscreen)) ? strtolower($fullscreen) : "true" ; //Enable fullscreen function
$stretching = (isset($stretching)) ? strtolower($stretching) : "fill" ; //Stretching options available: uniform | fill | exactfit | none
$controlbar = (isset($controlbar)) ? strtolower($controlbar) : "over" ; //Controlbar location options available: bottom | over | none
$image = (isset($image)) ? strtolower($image) : "assets/images/preview/drapeau.jpg" ; //default preview image
$title = (isset($title)) ? strtolower($title) : "" ; //default Video Title
$author = (isset($author)) ? strtolower($author) : "UNIR-MN" ; //default Video Author
$description = (isset($description)) ? strtolower($description) : "" ; //default Video Description
$dateadded= (isset($dateadded)) ? strtolower($dateadded) : "" ; //Date video was added
//FINISH EDITABLE CONTENT - if you don't know what you're doing - Keep Out!
$jw_base = $modx->config['site_url'] . "assets/snippets/JWPlayer/";
$Site_base = $modx->config['site_url'];
$file = $modx->config['site_url'] . $src;
$logosrc = $modx->config['site_url'].$logo;
echo "<script type=\"text/javascript\" src=\"" . $jw_base."embed/swfobject.js\"></script> \n";
echo "<div id=\"$file\"></div>\n<script type=\"text/javascript\"> \n";
echo "var so = new SWFObject('" . $jw_base . "embed/player-licensed-viral.swf','mpl','$width','$height','9'); \n";
echo "so.addParam('allowscriptaccess','always'); \n";
echo "so.addParam('allowfullscreen','true'); \n";
echo "so.addParam('wmode','transparent'); \n";
echo "so.addParam('flashvars','&dock=false&file=$file&logo=$logosrc&skin=$jw_base/embed/skins/modieus/modieus.swf&controlbar=$controlbar&fullscreen=$fullscreen&stretching=$stretching&image=$image&title=$title&author=$author&description=$description'); \n";
echo "so.write(\"$file\"); \n";
echo "</script>";
?>//FINISH EDITABLE CONTENT - if you don't know what you're doing - Keep Out! $jw_base = $modx->config['site_url'] . "assets/snippets/JWPlayer/"; $Site_base = $modx->config['site_url']; $file = $modx->config['site_url'] . $src; $logosrc = $modx->config['site_url'].$logo;
Change the $modx->config calls to $modx->getOption() (ie, $modx->getOption(’site_url’)), and change the ’echo’ statements at the end to instead return the output.
Other than that, it’ll work fine.
<?php
// SNIPPET NAME: JWPlayer
// SNIPPET DESCRIPTION: A Snippet to place the JW FLV Player into a MODx Page
// VERSION 1.1
/*---------------------------------
================
:: CREDIT
================
This Snippet writes the code necessary to properly display the JW FLV player in MODx
THE JW FLV player is developed by Jeroen Wijering and is available at http://www.jeroenwijering.com/
Respect the developer's license: http://creativecommons.org/licenses/by-nc-sa/3.0/
MODx Snippet thingie by George D. Carstensen
www.anablepo.com
=======
1.0.1 Changelog
Multiple player per page better supported - thanks keshon
================
:: INSTALL
================
- Download the .zip at http://www.jeroenwijering.com/?item=JW_FLV_Player
- Unzip the file and rename it 'embed'
- Place /embed/ inside another directory entitled 'JWPlayer'
- Upload the JWPlayer directory to your assets/snippets/ directory
- Paste the text of this document in a snippet - entitled 'JWPlayer'
- Reccommended: Create a Templave Variable (TV) Called 'videosrc' and
Set the input type as 'file'
* I'm not packaging these files in the snippet download - because the player is
sometimes updated - and you probably want the newest one.
* Tested and written for JW FLV MEDIA PLAYER v. 4.0
================
:: USAGE
================
- Simple! Place the snippet call [[JWPlayer? &src=[*videosrc*]]] in your document.
- If you chose to create the TV above, use the call [[JWPlayer? &src=[*videosrc*]]]
and set the filename using the TV dialog in your document.
- If you choose to use paramaters, simply append them like so:
[[JWPlayer? &src=[*videosrc*]¶meter1=value1¶meter2=value2&]]
(kind-of like a URL line, but make sure there's a space between the ? and the &.)
- If you use the player more than once in a page with different sources, scrap the TV and do this:
[[JWPlayer? &src=path/to/file]]
================
:: AVAILABLE PARAMETERS
================
*- All of these parameters defaults are editable below
&width - width in px
&height - height in px
&logo - location of logo from MODx install root. (ex: assets/images/monkeys/logo.png )
&fullscreen - enables fullscreen function ( true | false )
&stretching - specifies stretch type (uniform | fill | exactfit | none )
-'uniform' plays the video and fills up the frame - using black bars to perserve aspect
-'fill' fills up the frame while maintaining aspect ratio - may result in clipping.
-'exactfit' stretches the movie to fit the frame - aspect ratio is out the window
-'none' doesn't stretch at all - just plays the video in it's original dimensions.
Clipping possible.
&controlbar - displays controlbar either as a floaty transparent thing, or the traditional
bottom ( float | over | none )
================
:: FORMATS
================
Baseline h.264. The player isn't too picky about the file extension - I use .mp4, but I tested it with .flv and .m4v.
To be kind, stick to about 600/700 mb/sec or less.
---------------------------------*/
//EDITABLE PARAMETER DEFAULTS - only edit the stuff in Quotes - " ~ "
$width = (isset($width)) ? strtolower($width) : "550" ; //default video width in px
$height = (isset($height)) ? strtolower($height) : "434" ; //default video height in px
$logo = (isset($logo)) ? strtolower($logo) : "assets/images/system/vidlogo.png" ; //location of logo for overlay
$fullscreen = (isset($fullscreen)) ? strtolower($fullscreen) : "true" ; //Enable fullscreen function
$stretching = (isset($stretching)) ? strtolower($stretching) : "fill" ; //Stretching options available: uniform | fill | exactfit | none
$controlbar = (isset($controlbar)) ? strtolower($controlbar) : "over" ; //Controlbar location options available: bottom | over | none
$image = (isset($image)) ? strtolower($image) : "assets/images/preview/drapeau.jpg" ; //default preview image
$title = (isset($title)) ? strtolower($title) : "" ; //default Video Title
$author = (isset($author)) ? strtolower($author) : "UNIR-MN" ; //default Video Author
$description = (isset($description)) ? strtolower($description) : "" ; //default Video Description
$dateadded= (isset($dateadded)) ? strtolower($dateadded) : "" ; //Date video was added
//FINISH EDITABLE CONTENT - if you don't know what you're doing - Keep Out!
$jw_base = $modx->getOption('site_url') . "assets/snippets/JWPlayer/";
$Site_base = $modx->getOption('site_url');
$file = $modx->getOption('site_url') . $src;
$logosrc = $modx->getOption('site_url').$logo;
"<script type=\"text/javascript\" src=\"" . $jw_base."embed/swfobject.js\"></script> \n";
"<div id=\"$file\"></div>\n<script type=\"text/javascript\"> \n";
"var so = new SWFObject('" . $jw_base . "embed/player-licensed-viral.swf','mpl','$width','$height','9'); \n";
"so.addParam('allowscriptaccess','always'); \n";
"so.addParam('allowfullscreen','true'); \n";
"so.addParam('wmode','transparent'); \n";
"so.addParam('flashvars','&dock=false&file=$file&logo=$logosrc&skin=$jw_base/embed/skins/modieus/modieus.swf&controlbar=$controlbar&fullscreen=$fullscreen&stretching=$stretching&image=$image&title=$title&author=$author&description=$description'); \n";
"so.write(\"$file\"); \n";
"</script>";
?>$output = "<script type=\"text/javascript\" src=\"" . $jw_base."embed/swfobject.js\"></script> \n";
$output .= "<div id=\"$file\"></div>\n<script type=\"text/javascript\"> \n";
$output .= "var so = new SWFObject('" . $jw_base . "embed/player-licensed-viral.swf','mpl','$width','$height','9'); \n";
$output .= "so.addParam('allowscriptaccess','always'); \n";
$output .= "so.addParam('allowfullscreen','true'); \n";
$output .= "so.addParam('wmode','transparent'); \n";
$output .= "so.addParam('flashvars','&dock=false&file=$file&logo=$logosrc&skin=$jw_base/embed/skins/modieus/modieus.swf&controlbar=$controlbar&fullscreen=$fullscreen&stretching=$stretching&image=$image&title=$title&author=$author&description=$description'); \n";
$output .= "so.write(\"$file\"); \n";
$output .= "</script>";
return $output;
You’ll need to gather all that last part into a variable then return it:
$output = "<script type=\"text/javascript\" src=\"" . $jw_base."embed/swfobject.js\"></script> \n"; $output .= "<div id=\"$file\"></div>\n<script type=\"text/javascript\"> \n"; $output .= "var so = new SWFObject('" . $jw_base . "embed/player-licensed-viral.swf','mpl','$width','$height','9'); \n"; $output .= "so.addParam('allowscriptaccess','always'); \n"; $output .= "so.addParam('allowfullscreen','true'); \n"; $output .= "so.addParam('wmode','transparent'); \n"; $output .= "so.addParam('flashvars','&dock=false&file=$file&logo=$logosrc&skin=$jw_base/embed/skins/modieus/modieus.swf&controlbar=$controlbar&fullscreen=$fullscreen&stretching=$stretching&image=$image&title=$title&author=$author&description=$description'); \n"; $output .= "so.write(\"$file\"); \n"; $output .= "</script>"; return $output;
$output = '
<script type=\"text/javascript\" src=\"" . $jw_base."embed/swfobject.js\"></script>
<div id=\"$file\"></div>
<script type=\"text/javascript\">
var so = new SWFObject('" . $jw_base . "embed/player-licensed-viral.swf','mpl','$width','$height','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('wmode','transparent');
so.addParam('flashvars','&dock=false&file=$file&logo=$logosrc&skin=$jw_base/embed/skins/modieus/modieus.swf&controlbar=$controlbar&fullscreen=$fullscreen&stretching=$stretching&image=$image&title=$title&author=$author&description=$description');
so.write(\"$file\");
</script>";'
return $output;
This is something of an aside, but I’ve just discovered that longtail requires the purchase of license if you wish to use JW player on a site that uses a CMS.
If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS.