Using JWPlayer with Flash
NOTE: If you have not followed our initial set up instructions for JW Player, please visit our article Using JWPlayer
Using JW Player With Flash Files
If you are using JW Player with Flash files in CARMA the below changes to your CARMA templates will allow these files to be played.
Adjust the Code in view_clip
After setting up JW Player in our Using JWPlayer article update your view_clip template in your Members_Area_Templates with the following:
Between the Code:
{elseif $mime == 'application/x-shockwave-flash'} {* Video type swf *}
And
{/if}
Replace the existing code or add the following code to your design:
<script type="text/javascript" src="jwplayer.js" ></script> <div id="myElement">Loading the player ...</div> {literal} <script type="text/javascript"> <!-- jwplayer("myElement").setup({ {/literal} file: '{rebuild_link without="style" using="GET" encode=1 start=$smarty.server.HTTP_HOST}', {literal} height: 360, image: "/view_image.php" + escape("?galid={/literal}{$smarty.get.galid}{literal}&file=sample.jpg&width=768&height=432&crop=1&extension=.jpg"), width: 640 }); // --> </script> {/literal}
The above code will use the JW Player you have set up in your CARMA root directory, The "{rebuild_link" function retrieves the URL needed to play the flash file.
Adding the code to show_video
If you wish you can have the JW Player show up in your show_video template where you show all your videos from one content set.
Within this template you will see a smarty "foreach" loop set as such:
{foreach from=$carma_video.files.$type key=id item=file}
Within this loop, you can either replace the code within or add the following code:
<script type="text/javascript" src="jwplayer.js" ></script> <div id="myElement">Loading the player ...</div> {literal} <script type="text/javascript"> <!-- jwplayer("myElement").setup({ {/literal} file: 'http%3A%2F%2F{$smarty.server.HTTP_HOST}%2Fview_clip.php%3Fgalid%3D{$galid}%26num%3D{$id|default:0}%26type%3D{$type}%26ext%3Dfile.flv', {literal} height: 360, image: "/view_image.php" + escape("?galid={/literal}{$carma_video.galid}{literal}&file=sample.jpg&width=768&height=432&crop=1&extension=.jpg"), width: 640 }); // --> </script> {/literal}
In this case as opposed to the view_clip example the file is set with the URL that directly calls the Flash File itself. The URL in this example has been URL encoded for your convenience as this is necessary for JW Player to run the file properly.