Example 1: Using the Default Endcard
This sample shows the player loaded with a video duration of 11-seconds and a factor of 50%, allowing for ~5-second time-limit. It uses the default, built-in endcard. No 'endcard' flashVars is used.
Here's the code:
<div id="container">
<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.
<script type="text/javascript">
var s1 = new SWFObject("player.swf","ply","400","300","9","#000000");
s1.addParam("allowfullscreen","true");
s1.addParam("allowscriptaccess","always");
s1.addVariable("file","video.flv");
s1.addVariable("duration","11");
s1.addVariable("plugins","timelimiter");
s1.addVariable("timelimiter.factor","50");
s1.addVariable("bufferlength","5");
s1.write("container");
</script>
</div> <!-- end container -->
Example 2: Alternate Text for the Default EndCard
This sample shows the player loaded with the same duration of 11-seconds and factor of 50%, allowing for ~5-second time-limit. It uses alternate text for the default endCard. This time, the 'endcardtext' flashVars is used.
Here's the code:
<div id="container2">
<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.
<script type="text/javascript">
var s1 = new SWFObject("player.swf","ply","400","300","9","#000000");
s1.addParam("allowfullscreen","true");
s1.addParam("allowscriptaccess","always");
s1.addVariable("file","video.flv");
s1.addVariable("duration","11");
s1.addVariable("plugins","timelimiter");
s1.addVariable("timelimiter.factor","50");
s1.addVariable("timelimiter.endcardtext","This EndCard Text was created using flashVars!");
s1.addVariable("bufferlength","5");
s1.write("container2");
</script>
</div> <!-- end container2 -->
Example 3: Using an External Endcard
This sample shows the player loaded with the same duration of 11-seconds and factor of 50%, allowing for ~5-second time-limit. It uses an external endcard. This time, the 'endcard' flashVars is used.
Here's the code:
<div id="container3">
<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.
<script type="text/javascript">
var s1 = new SWFObject("player.swf","ply","400","300","9","#000000");
s1.addParam("allowfullscreen","true");
s1.addParam("allowscriptaccess","always");
s1.addVariable("file","video.flv");
s1.addVariable("duration","11");
s1.addVariable("plugins","timelimiter");
s1.addVariable("timelimiter.factor","50");
s1.addVariable("timelimiter.endcard","endcard.jpg");
s1.addVariable("bufferlength","5");
s1.write("container3");
</script>
</div> <!-- end container3 -->
Example 4: Using an Erroneous External Endcard
This sample once again shows the same video: duration of 11-seconds and a factor of 50%. It uses an external endcard, but I have chosen a filename that does not exist, to show what happens when it encounters an error. The default internal endcard should appear.
Here's the code:
<div id="container4">
<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.
<script type="text/javascript">
var s1 = new SWFObject("player.swf","ply","400","300","9","#000000");
s1.addParam("allowfullscreen","true");
s1.addParam("allowscriptaccess","always");
s1.addVariable("file","video.flv");
s1.addVariable("duration","11");
s1.addVariable("plugins","timelimiter");
s1.addVariable("timelimiter.factor","50");
s1.addVariable("timelimiter.endcard","afdsjoifr.jpg");
s1.addVariable("bufferlength","5");
s1.write("container4");
</script>
</div> <!-- end container4 -->
Example 5: Using flashVars for both External endCard and alternate Internal endCard Text
This sample once again shows the same video: duration of 11-seconds and a factor of 50%. It tries to use an external endcard, but I have also tried to load new text for the internal endcard, to show what happens when it encounters this particular error. The default internal endcard should appear, but with the new text specified in the flashVars.
Here's the code:
<div id="container5">
<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.
<script type="text/javascript">
var s1 = new SWFObject("player.swf","ply","400","300","9","#000000");
s1.addParam("allowfullscreen","true");
s1.addParam("allowscriptaccess","always");
s1.addVariable("file","video.flv");
s1.addVariable("duration","11");
s1.addVariable("plugins","timelimiter");
s1.addVariable("timelimiter.factor","50");
s1.addVariable("timelimiter.endcard","endcard.jpg");
s1.addVariable("timelimiter.endcardtext","This example tried to call an external endcard, *and* to load this text. Guess who won?");
s1.addVariable("bufferlength","5");
s1.write("container5");
</script>
</div> <!-- end container5 -->
TimeLimiter:
a plug-in for the JW Player v.4.3+
This is a sample of the new timelimiter plug-in for the JW-Player.
Developed by Leland Hirschman, for www.gpanswers.com
NOTE: This plug-in is not yet available on the Longtail Plug-In Repository, but is shown here now in preparation.
Changes since the previous Version:
2009-05-04 - The internal endcard is now dynamic text, and can be changed via flashVars. If both an external endcard *and* alternate text for the internal endcard are provided, the plug-in will default to the internal endcard with the alternate text provided in flashVars. The new flashVars is 'endcardtext'.
2009-04-28 - Due to some errors loading the endcard file on the client's streaming server, I had to make a few changes to the way the plug-in handles the endcard:
- The default endcard is now built into the plug-in. An external endcard is no longer required.
- An external endcard may still be used, and if so, will replace the internal endcard
- If the external endcard cannot be found, or any other errors occur when trying to load the external endcard, the internal endcard will be loaded instead.
- When the internal endcard is used, the original video file is never unloaded from the player, so the player controls are hidden.
- When an external endcard is used, the player controls are left in place, in the event that the external endcard is another video file or playlist
Requirements:
- JW Player 4.3+
- This plug-in uses the 'duration' flashVars that is part of the standard player. You need to pass the duration of your videos as a flashVars. Directions below.
- The file called 'endcard.jpg' (right-click, then save as...) is now optional. The endcard may be any file that the player can load, and can be defined using flashVars. Directions below.
Background:
A client was looking for some security measures for the video portion of his website. His video section is available by paid membership only. Each video in the videos section may only be viewed twice per membership. He wanted to prevent users from watching a video, pushing the scroll-bar back to the beginning repeatedly to watch again (or, in his words, 'to call their co-workers in to the office one-at-a-time to show them the video'). He wanted to allow them the opportunity to re-watch portions of the video once or twice (if they missed something or needed a better understanding of that part, for example), but did not want them to be able to watch the entire video over-and-over. This plug-in is the result of that need.
What it Does:
TimeLimiter limits the Total Available Time that a given video or playlist may play. It determines the Total Available Time by a 'factor' (percentage) of the 'duration' flashVars (or a factor of 1-hour, if the duration is unspecified). Upon completion of the time-limit, the video is stopped, and the screen is covered by a message that the time limit has been exceeded. Alternately, a new file may be loaded.
Basically, when the plug-in is loaded, a timer is created, taking the current 'duration' flashVars and multiplying it by the 'factor' flashVars (as a percentage). If the 'duration' flashVars was not set (its default is '0'), the timer multiplies the factor (as a percentage) by 60-minutes. For example, if a video is 30-minutes, and you set the 'factor' at 150%, the total length of time that the video may be played will be 45-minutes. By default, the factor is set to 250%, but may be customized by the user with flashVars.
As soon as the video begins to play, the timer is started. The timer only runs while the video is playing. You may pause or stop the video at any time, and the timer be paused as well. You may also move the playhead around the video, and the timer will be unaffected. Once created, this timer is completely separate from the video's timer. It just counts the passing seconds while the video is playing. Nothing more. When the timer reaches it's end-time, it hides the screen with the endcard message by default, or an external file may be loaded instead.
Quick Reference:
| Plug-In Name: | timelimiter | ||
|---|---|---|---|
| flashVars | |||
| flashVars Name | Default | Type | Description |
| duration | 0 | [number] | REQUIRED The duration of the file in *seconds*. A standard JW Player falshVars. If default of '0' is detected, the plug-in assumes a 60-minute duration when figuring the time-limit, but does not adjust the duration flashVars. |
| timelimiter.factor | 250 | [number] | A number representing the percentage by which the duration should be multiplied. 250 = 250% of duration. |
| timelimiter.endcard | [NULL] | [path/to.file] | A path (absolute or relative) to an endcard file, to load upon completion of the time-limit. May be any type of file that the JW Player can load. |
| timelimiter.endcardtext | {NULL] | [string] | A text string to replace the default text in the internal endcard. |
Basic Installation:
By default, when plug-ins are used, they are loaded from the official Longtail Plug-In Repository. This plug-in has not yet been submitted to the Repository, as it is still in the 'client-review' stage.
To load the plug-in, add the following flashVars to your code, as required by the JW Player loaded using swfobject:
s1.addParam("flashvars","file=video.flv&duration=360&plugins=timelimiter[,otherplugins][&...&otherflashVars&...]");
-or-
s1.addVariable("file","video.flv");
s1.addVariable("duration","360");
s1.addVariable("plugins","timelimiter[,otherplugins]");
... depending on the method you currently use to call the player. I prefer the 2nd method, because it's easier to read.
REMEMBER: This plug-in uses the video's 'duration' flashVars to figure out the total available play-time. Please remember to set this flashVars, as shown, to ensure that the plug-in works correctly.
duration [number] (default:0) - Duration of the file in *seconds*.
Examples:
- example #1:
s1.addVariable("duration","360");
Translates to 360-seconds, which equals 6:00 (6:min x 60sec/min = 360sec). - example #2:
s1.addVariable("duration","1800");
Translates to 1800-seconds, which equals 30:00 (30:min x 60sec/min = 1800sec). - example #3:
s1.addVariable("duration","2742");
Translates to 2742-seconds, which equals 45:42 (45:min x 60sec/min = 2700sec + 42sec = 2742sec).
Customized Installation - flashVars:
Three additional flashVars are available with this plug-in. They are:
timelimiter.factor [number] (default:250) - A percentage of the video's duration, which will determine the Total Available Time.
Examples:
- example #1:
s1.addVariable("timelimiter.factor","150");
Translates to a factor of 150%, or one-and-a-half-times the length of your video; so a 5-minute video could be viewed - and portions re-viewed - for a total of 7.5-minutes. - example #2:
s1.addVariable("timelimiter.factor","200");
Translates to a factor of 200%, or two-times the length of your video; so a 5-minute video could be viewed - and portions re-viewed - for a total of 10-minutes. - example #3:
s1.addVariable("timelimiter.factor","10");
Translates to a factor of 10%, or one-tenth the length of your video; so a 5-minute video could be viewed for a total of 30-seconds. A great way to show 'previews' of videos!
timelimiter.endcard ['path/to.file'] (default: an internal graphic is used) - may be an absolute or relative path to a replacement endcard. The endcard can be any file that the player supports.
Examples:
- example #1:
s1.addVariable("timelimiter.endcard","http://www.yoursite.com/images/custom_endcard.png");
Tells the plug-in to use the file shown in the absolute link as the endcard, instead of the default graphic. - example #2:
s1.addVariable("timelimiter.endcard","custom_endcard.jpg");
Tells the plug-in to use the file shown in the relative link (relative to the JW Player) as the endcard, instead of the default. - example #3:
s1.addVariable("timelimiter.endcard","../images/custom_endcard.png");
Tells the plug-in to use the file shown in the relative link (relative to the JW Player) as the endcard, instead of the default.
timelimiter.endcardtext [string] (default: NULL) - a text string to substitute for the default text in the internal endCard.
Examples:
- example:
s1.addVariable("timelimiter.endcardtext","This text is loaded dynamically with flashVars!");
Tells the plug-in to use the phrase "This text is loaded dynamically with flashVars!" on the internal endcard, instead of the default text.
OK, you ask, but how do I put it all together...?
The Complete Code:
To properly use this plug-in, with extra customization using flashVars, use the examples along the side, adjusting the values as needed.
Additional Notes:
This plug-in could alternately be used to show only the first x% of a video, as a preview function... for example, you could show only the first 30-seconds of a 5-minute video as a teaser by loading this plug-in with a 'factor' of 10%.
The endcard is, by default, a simple message that the user has exceeded the allotted time limits. However, you may substitute any short text string using the 'endcardtext' flashVars. Alternately, any file that the JW Player can load can be used, and can be specified using the 'endcard' flashVars. You can follow it up with a standard short video (such as a corporate ad, sponsors ad, etc), a playlist, etc. Please note, however, that if you use both flashVars, that the player will use the internal endCard, with the text provided in the flashVars.
When using with a playlist, set the duration flashvars when you load the player. The plug-in will create the timer before the first item in the playlist is loaded. That means you can define a total time available for a playlist. So you can define a playlist of several shorter files, and allow whatever length of time you want to allow users to play the files (and skip around those files) in the playlist.
Bug Alert: There is a known bug when using this plug-in to limit the time of watching a playlist. Sometimes (for reasons as yet unknown), when the player stops at the end of the time-limit, it does not properly load the endcard. Since the client who ordered this plug-in only loads single files into the player at a given time, I have put off finding the cause of and fixing this bug until a future version. Be forewarned!
This plug-in will start the timer over again with each re-loading of the player. Therefore, it works best as a security measure when the ability to re-load the player is limited as well. The client for whom this plug-in was developed limits his users to load a video only twice. This plug-in limits the total length of time they may view the video each of the two times it's loaded.
This plug-in requires that the video is loaded with the 'duration' flashVars, one that is part of the standard player. If the video is not loaded with a duration, the plug-in assumes a default of 60-minutes. This default time is used to determine the total available playing time, but does *not* set the player's 'duration' flashVars to 60-minutes. If no 'duration' is set when the player is loaded, then the player will otherwise act as it normally does when no duration is set. Only the plug-in uses 60-minutes as a default duration, simply as a default to avoid errors.
Version History:
v.1.0-RC1 - 2009-04-18 - available for client review only.
v.1.0-RC2 - 2009-04-28 - available for client review only.
v.1.0-RC3 - 2009-05-04 - available for client review only.
© 2009, Leland Hirschman