From 332f498616b4f850145bc63c522be3b3a5358f02 Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Sat, 4 Feb 2012 15:27:01 -0500 Subject: [PATCH] Groundwork for going back to same place in video --- js/video_player.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/js/video_player.js b/js/video_player.js index e91813b5f1..d71103ba81 100644 --- a/js/video_player.js +++ b/js/video_player.js @@ -48,6 +48,17 @@ function postJSON(url, data, callback) { }); } +function postJSONAsync(url, data, callback) { + $.ajax({type:'POST', + url: url, + dataType: 'json', + data: data, + success: callback, + headers : {'X-CSRFToken':getCookie('csrftoken')}, + async:true + }); +} + // For easy embedding of CSRF in forms $(function() { $('#csrfmiddlewaretoken').attr("value", getCookie('csrftoken')) @@ -212,7 +223,10 @@ function onPlayerStateChange(event) { var switched_tab = false; // switch to true when we destroy so we know to call onYouTubePlayerAPIReady() // clear pings to video status when we switch to a different sequence tab with ajax -function videoDestroy() { +function videoDestroy(id) { + postJSON('/modx/video/'+id+'/goto_position', + {'position' : ytplayer.getCurrentTime()}); + load_id = 0; clearInterval(updateytplayerInfoInterval); clearInterval(ajax_videoInterval); @@ -318,6 +332,8 @@ function loadNewVideo(id, startSeconds) { catch(e) { window['console'].log(JSON.stringify(e)); } + $("#slider").slider("option","value",startSeconds); + //seekTo(startSeconds); } function cueNewVideo(id, startSeconds) {