<commit_before><!DOCTYPE HTML>
<html>
<head>
<title>Playhead segments</title>
<script type="text/javascript" src="../../../tests/qunit/qunit-bootstrap.js"></script>
<script type="text/javascript" src="../../../mwEmbedLoader.php"></script>
<script type="text/javascript" src="../../../docs/js/doc-bootstrap.js"></script>
<script type="text/javascript">	
function jsKalturaPlayerTest( videoId ){
	var kdp = $('#' + videoId )[0];
	// Name this module 
	module( "Playhead segment" );
	asyncTest("Playhead segment", function(){
		window['onPlayerSeekEnd'] = function(){
			addSeekTests();
			setTimeout(function(){
				start();
			},100)
		}
		// check the start time is set
		equal( kdp.evaluate('{video.player.currentTime}'), 0, "Kdp time at startup is zero" );
		equal( kdp.evaluate('{duration}'), 20, "20 second duration for 20 second segment." );
		
		// add seek listener ( seek to 5 seconds and check time is accurate )
		kdp.addJsListener( 'playerSeekEnd', 'onPlayerSeekEnd');
		// after 1 second of playback issue a seek to 20 seconds
		setTimeout(function(){
			kdp.sendNotification('doSeek', 20 );
		}, 1000 );
	});
	
	window['addSeekTests'] = function(){
		asyncTest("Playhead seeks", function(){
			equal( kdp.evaluate('{video.player.currentTime}'), 20, "seek time is 20" );
			// true player time: 
			var $iframe = $( '#' + videoId + '_ifp' ).contents();
			var rawVid = $iframe.find('#myVideoTarget')[0].getPlayerElement();
			equal( rawVid.currentTime, 20, "true video time is 20" );
			start();
		});
	};
}
</script>
<!-- qunit-kaltura must come after qunit-bootstrap.js and after mwEmbedLoader.php and after any jsCallbackReady stuff-->
<script type="text/javascript" src="resources/qunit-kaltura-bootstrap.js"></script>
</head>
<body>
<h2>Playhead Segment support</h2>
<div id="segmentConfig"></div>

Switch segment to <input id="k-from" size="4" style="width:30px" value="30"> to <input id="k-to" style="width:30px" size="4" value="37">
<a href="#" id="switchTime">GO</a>
<script>
	kWidget.addReadyCallback(function( playerId ){
		var kdp = $('#' + playerId )[0];
		$('#switchTime').click( function(){
			kdp.setKDPAttribute('mediaProxy', 'mediaPlayFrom', $('#k-from').val() );
			kdp.setKDPAttribute('mediaProxy', 'mediaPlayTo', $('#k-to').val() );
			kdp.sendNotification('doSeek', $('#k-from').val() );
			return false;
		});
	});
</script>


<div id="myVideoTarget" style="width:400px;height:330px;float:left">
</div>

<script>
	var flashvars = { 
		'mediaProxy.mediaPlayFrom' : 10,
		'mediaProxy.mediaPlayTo': 30,
		'segmentScrubber':{
			'plugin' : true
		}
	};
	
	function doEmbedPlayer( fv ){
		kWidget.embed({<commit_msg>updated test file to include code sample<commit_after><!DOCTYPE HTML>
<html>
<head>
<title>Playhead segments</title>
<script type="text/javascript" src="../../../tests/qunit/qunit-bootstrap.js"></script>
<script type="text/javascript" src="../../../mwEmbedLoader.php"></script>
<script type="text/javascript" src="../../../docs/js/doc-bootstrap.js"></script>
<script type="text/javascript">	
function jsKalturaPlayerTest( videoId ){
	var kdp = $('#' + videoId )[0];
	// Name this module 
	module( "Playhead segment" );
	asyncTest("Playhead segment", function(){
		window['onPlayerSeekEnd'] = function(){
			addSeekTests();
			setTimeout(function(){
				start();
			},100)
		}
		// check the start time is set
		equal( kdp.evaluate('{video.player.currentTime}'), 0, "Kdp time at startup is zero" );
		equal( kdp.evaluate('{duration}'), 20, "20 second duration for 20 second segment." );
		
		// add seek listener ( seek to 5 seconds and check time is accurate )
		kdp.addJsListener( 'playerSeekEnd', 'onPlayerSeekEnd');
		// after 1 second of playback issue a seek to 20 seconds
		setTimeout(function(){
			kdp.sendNotification('doSeek', 20 );
		}, 1000 );
	});
	
	window['addSeekTests'] = function(){
		asyncTest("Playhead seeks", function(){
			equal( kdp.evaluate('{video.player.currentTime}'), 20, "seek time is 20" );
			// true player time: 
			var $iframe = $( '#' + videoId + '_ifp' ).contents();
			var rawVid = $iframe.find('#myVideoTarget')[0].getPlayerElement();
			equal( rawVid.currentTime, 20, "true video time is 20" );
			start();
		});
	};
}
</script>
<!-- qunit-kaltura must come after qunit-bootstrap.js and after mwEmbedLoader.php and after any jsCallbackReady stuff-->
<script type="text/javascript" src="resources/qunit-kaltura-bootstrap.js"></script>
</head>
<body>
<h2>Playhead Segment support</h2>
<div id="segmentConfig"></div>
Sample code for switching segments:
<pre class="prettyprint linenums">
&lt;script&gt;<br/>	kWidget.addReadyCallback(function( playerId ){<br/>		var kdp = $('#' + playerId )[0];<br/>		$('#switchTime').click( function(){<br/>			kdp.setKDPAttribute('mediaProxy', 'mediaPlayFrom', $('#k-from').val() );<br/>			kdp.setKDPAttribute('mediaProxy', 'mediaPlayTo', $('#k-to').val() );<br/>			kdp.sendNotification('doSeek', $('#k-from').val() );<br/>			return false;<br/>		});<br/>	});<br/>&lt;/script&gt;
</pre>
Switch segment to <input id="k-from" size="4" style="width:30px" value="30"> to <input id="k-to" style="width:30px" size="4" value="37">
<a href="#" id="switchTime">GO</a>
<script>
	kWidget.addReadyCallback(function( playerId ){
		var kdp = $('#' + playerId )[0];
		$('#switchTime').click( function(){
			kdp.setKDPAttribute('mediaProxy', 'mediaPlayFrom', $('#k-from').val() );
			kdp.setKDPAttribute('mediaProxy', 'mediaPlayTo', $('#k-to').val() );
			kdp.sendNotification('doSeek', $('#k-from').val() );
			return false;
		});
	});
</script>
<br /><br />
<span id="playbackModeSelector"></span><br />
<div id="myVideoTarget" style="width:400px;height:330px">
</div>

<script>
	var flashvars = { 
		'mediaProxy.mediaPlayFrom' : 10,
		'mediaProxy.mediaPlayTo': 30,
		'segmentScrubber':{
			'plugin' : true
		}
	};
	
	function doEmbedPlayer( fv ){
		kWidget.embed({
{'fraction_non_alphanumeric': 0.20490964882372997, 'fraction_numerical': 0.018240709171496762, 'mean_word_length': 4.679574056147144, 'pattern_counts': {'":': 0, '<': 82, '<?xml version=': 0, '>': 82, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5008803', 'n_tokens_mistral': 2201, 'n_tokens_neox': 1971, 'n_words': 453}