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

jwplayer("container").getPosition(); Returning Undefined


The following code is returning undefined how do I get the following code to work on my page?

var x = jwplayer("container").getPosition();
document.write(x);

My ultimate goal was to get the following to work

if (jwplayer("container").getPosition(); > 60) {
document.getElementById('delay').style.display = 'block';
}

But this is not working. I want the div to display after the video hits a certain time.





2 Community Answers

jschuler

User  
1 rated :

I have it working with an HTML 5 Video but I want to get it to work with JWPLAYER

This code works for me:
<video src="http://hwcdn.net/d9s3i4k8/TUYM-Metabo379-49-UAB-2315.mp4?content=video" autoplay></video>

</div>
<div id="time"></div>
<script>
(function(){
var v = document.getElementsByTagName('video')[0]
var t = document.getElementById('time');
v.addEventListener('timeupdate',function(event){
t.innerHTML = v.currentTime;
if (v.currentTime > <%=REVEALDELAY%>) {document.getElementById('delay').style.display = 'block';document.getElementById('disclaimers').style.display = 'block';document.getElementById('references').style.display = 'block';document.getElementById('whitewrap').style.display = 'block';
document.cookie = "visit=yes";};
},false);
})();

Todd

JW Player Support Agent  
2 rated :

You have to put your

if (jwplayer(“container”).getPosition(); > 60) {
document.getElementById(‘delay’).style.display = ‘block’;
}

inside of an onTime() event, like this:

jwplayer().onTime(function(){
if (jwplayer(“container”).getPosition() > 60) {
document.getElementById(‘delay’).style.display = ‘block’;
}
});

because the onTime() is what fires every tenth of a second or so.

This question has received the maximum number of answers.