<?php
// Configuration.
$s2_jw_config["jwplayer"] = "/jwplayer/"; // Relative URL path to JW Player files directory.
$s2_jw_config["mp4_video_file_name"] = "video.mp4"; // Name of your MP4 test file.
// Don't edit anything else below unless you know what you're doing.
?>

<div id="jw-container">JW Player® appears here.</div>
<script src="<?php echo $s2_jw_config["jwplayer"]; ?>jwplayer.js"></script>
<script>jwplayer.key = 'YOUR KEY HERE';</script>

<script>
	// The Shortcode here will return a JSON object for JavaScript notation.
	// A direct URL to the RTMP source; counting the file against the current User in real-time.
	// API Shortcode `s2File` returns a null object if access is denied to the current User/Member.
	var mp4 = [s2File download="<?php echo $s2_jw_config["mp4_video_file_name"]; ?>" url_to_storage_source="true" count_against_user="true" get_streamer_json="true" /];
</script>

<script>
	if(typeof mp4 === 'object') // `s2File` returns a null object if access is denied to the current User.
		{
			jwplayer('jw-container').setup({
					playlist:
						[{
							sources: // List all available sources.
								[
									{type: 'rtmp', file: mp4['streamer'] + '/mp4:' + mp4['file']},
									{type: 'mp4', file: mp4['url']}
								]
						}],
					primary: 'flash' /* Try Flash® RTMP first, fallback on HTML5 or direct download of MP4 file. */,
					width: 480, height: 270 // Set video dimensions for all sources.
				});
		}
	else // Else, `s2File` returned a null object value.
		{
			document.write('Sorry, you do NOT have access to this file.');
		}
</script>
