Commit 40e52cb9 by Ernie Park

update video player to accommodate remembering video speeds when switching in…

update video player to accommodate remembering video speeds when switching in sequences and fix bug where play button gets out of sync when switching speeds

--HG--
branch : ernie-static-video-fixes
parent d4b17006
...@@ -77,8 +77,8 @@ function submit_circuit(circuit_id) { ...@@ -77,8 +77,8 @@ function submit_circuit(circuit_id) {
// Video player // Video player
var load_id = 0; var load_id = 0;
var caption_id;
var video_speed = 1.0; var video_speed = "1.0";
var updateytPlayerInterval; var updateytPlayerInterval;
var ajax_videoInterval; var ajax_videoInterval;
...@@ -86,7 +86,8 @@ var ajax_videoInterval; ...@@ -86,7 +86,8 @@ var ajax_videoInterval;
function change_video_speed(speed, youtube_id) { function change_video_speed(speed, youtube_id) {
new_position = ytplayer.getCurrentTime() * video_speed / speed; new_position = ytplayer.getCurrentTime() * video_speed / speed;
video_speed = speed; video_speed = speed;
ytplayer.loadVideoById(youtube_id, new_position); ytplayer.loadVideoById(youtube_id, new_position);
syncPlayButton();
log_event("speed", {"new_speed":speed, "clip":youtube_id}); log_event("speed", {"new_speed":speed, "clip":youtube_id});
} }
...@@ -190,7 +191,7 @@ function onYouTubePlayerReady(playerId) { ...@@ -190,7 +191,7 @@ function onYouTubePlayerReady(playerId) {
ytplayer.addEventListener("onError", "onPlayerError"); ytplayer.addEventListener("onError", "onPlayerError");
if((typeof load_id != "undefined") && (load_id != 0)) { if((typeof load_id != "undefined") && (load_id != 0)) {
var id=load_id; var id=load_id;
loadNewVideo(id, 0); loadNewVideo(caption_id, id, 0);
} }
} }
...@@ -357,11 +358,12 @@ function updateytplayerInfo() { ...@@ -357,11 +358,12 @@ function updateytplayerInfo() {
} }
// functions for the api calls // functions for the api calls
function loadNewVideo(id, startSeconds) { function loadNewVideo(cap_id, id, startSeconds) {
captions={"start":[0],"end":[0],"text":["Attempting to load captions..."]}; captions={"start":[0],"end":[0],"text":["Attempting to load captions..."]};
$.getJSON("/static/subs/"+id+".srt.sjson", function(data) { $.getJSON("/static/subs/"+cap_id+".srt.sjson", function(data) {
captions=data; captions=data;
}); });
caption_id = cap_id;
load_id = id; load_id = id;
//if ((typeof ytplayer != "undefined") && (ytplayer.type=="application/x-shockwave-flash")) { //if ((typeof ytplayer != "undefined") && (ytplayer.type=="application/x-shockwave-flash")) {
// Try it every time. If we fail, we want the error message for now. // Try it every time. If we fail, we want the error message for now.
...@@ -378,6 +380,15 @@ function loadNewVideo(id, startSeconds) { ...@@ -378,6 +380,15 @@ function loadNewVideo(id, startSeconds) {
//seekTo(startSeconds); //seekTo(startSeconds);
} }
function syncPlayButton(){
var state = getPlayerState();
if (state == 1 || state == 3) {
$("#video_control").removeClass().addClass("pause");
} else if (state == 2 || state == -1 || state == 0){
$("#video_control").removeClass().addClass("play");
}
}
function cueNewVideo(id, startSeconds) { function cueNewVideo(id, startSeconds) {
if (ytplayer) { if (ytplayer) {
ytplayer.cueVideoById(id, startSeconds); ytplayer.cueVideoById(id, startSeconds);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment