Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Time Offset with Primary set as Flash


In my script I pull a start time from a MySQL table. This works only when the primary isn't set as Flash. However, I need the primary to be set a Flash because I need the HD button to show up by default. I need both of these features to exist. Parts of my code so far:

var isLogged = "<?php
if(!empty($login->getLogin())){ echo TRUE; }
else{ echo FALSE; }
?>";
var player = jwplayer("player-<?php echo $video->getBaseFileName(); ?>");
player.setup({
playlist: [{
image: "http://d9twdiekqysl5.cloudfront.net/<?php echo $video->getBaseFileName(); ?>/<?php echo $video->getBaseFileName(); ?>-00001.png",
sources: [{
file: "http://dep4zzgu32665.cloudfront.net/<?php echo $video->getBaseFileName(); ?>/<?php echo $video->getBaseFileName(); ?>.m3u8",
},{
file: "http://d3vd9hr1vidhzq.cloudfront.net/<?php echo $video->getBaseFileName(); ?>.mp4",
}],
tracks: [{
file: "https://leerburg.com/flix/vtt/test.vtt",
label: "English",
kind: "captions",
"default": false
}],
}],
width: "100%",
events: {
onPause: function(event) { if(isLogged) { updateFlixDuration(player.getPosition()); } },
onSeek: function(event) { if(isLogged) { updateFlixDuration(event.offset); } }
},
primary: "flash",
aspectratio:"16:9",
autostart:true,
skin: {
name: "glow",
active: "#E6E6E6",
inactive: "#000000",
background: "#474747"
},
logo: { hide: true }
});


var startTime = "<?php
$user = $login->getLogin();
if(!empty($user)){
$sql = "SELECT BookmarkTime FROM flix_bookmarks
WHERE Login = '$user' AND FlixID = '$flixID' AND BookmarkType = 'time'";
$result = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($result);
if($num_rows > 0) { while ($row = mysql_fetch_assoc($result)) { echo $row['BookmarkTime']; } }
else {
$sql1 = "INSERT INTO flix_bookmarks (Login, FlixID, BookmarkType, BookmarkName, BookmarkTime, BookmarkNotes)
VALUES ('$user', '$flixID', 'time', 'testing', '0', 'test')";
$result1 = mysql_query($sql1) or die(mysql_error());
echo '0';
}
} else {echo '0';}
?>";
// Player starts at the start time and creates a button that allows for 10 rewinds
player.on('ready', function(){
var controlbar = document.getElementsByClassName('jw-controlbar-left-group')[0];
var controlbarDiv = document.createElement('div');
controlbarDiv.setAttribute('onclick', 'var position = player.getPosition(); position -= 10; player.seek(position);');
controlbarDiv.setAttribute('class', 'jw-icon jw-icon-inline jw-button-color jw-reset');
controlbarDiv.setAttribute('id', 'rewind');
controlbar.insertBefore(controlbarDiv, controlbar.childNodes[0]);
player.seek(startTime); /*This part here is completely ignored */
});

When player.seek(startTime) is called, that part is ignored when primary is flash and plays the video from the start (0:00:00). I've checked startTime's value and it isn't 0 seconds. I need help figuring out how to do this resume functionality while the primary is flash or at the very least, add the HD button when the primary is HTML5

3 Community Answers

Todd

JW Player Support Agent  
0 rated :

Flash cannot seek to unbuffered portions of the video. My guess is that because you are calling seek() in an ready() event before Flash has even started buffering, there’s no way the player can load enough of the video to be able to seek ahead.

ryan

User  
0 rated :

How would check for when the video is completely loaded?

Todd

JW Player Support Agent  
0 rated :

My first thought would be to use .getBuffer()

From our API reference doc at http://support.jwplayer.com/customer/portal/articles/1413089-javascript-api-reference:

.getBuffer()
Returns the current PlaylistItem’s filled buffer, as a percentage (0 to 100) of the total video’s length.

This question has received the maximum number of answers.