问题
how to make the JW Player have a "resume" or "remember" function which marks position of last
play position of movie and remembers it when you come back to watch video again? So, if a
viewer stopped watching a movie at 36:25 minutes on a 2 hour movie and had to go offline, when
they returned to watch movie, the JW player would open to the correct position and "resume"
play.
回答1:
This should get you started:
http://osric.com/chris/jwplayer/jwplayer5.4/ontime.html
The JavaScript from that page is as follows:
$(document).ready( function() {
jwplayer("container").setup({
file:"playlist.xml",
height: 300,
width: 400,
events: {
onTime: function(event) {
$('#timer').html(Math.floor(event.position));
}
}
});
That code sets an element with the id of "timer" to be the value of the current position.
You could then create either a cookie to save the variable from the JS.
Edit
You can use this link to help with the cookie function:
http://www.w3schools.com/js/js_cookies.asp
$(document).ready( function() {
jwplayer("container").setup({
file:"playlist.xml",
height: 300,
width: 400,
events: {
onPause: function(event) {
setCookie(event.position);
}
}
});
来源:https://stackoverflow.com/questions/8929691/jw-player-resume-after-refresh