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
This commit is contained in:
@@ -77,8 +77,8 @@ function submit_circuit(circuit_id) {
|
||||
// Video player
|
||||
|
||||
var load_id = 0;
|
||||
|
||||
var video_speed = 1.0;
|
||||
var caption_id;
|
||||
var video_speed = "1.0";
|
||||
|
||||
var updateytPlayerInterval;
|
||||
var ajax_videoInterval;
|
||||
@@ -86,7 +86,8 @@ var ajax_videoInterval;
|
||||
function change_video_speed(speed, youtube_id) {
|
||||
new_position = ytplayer.getCurrentTime() * 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});
|
||||
}
|
||||
|
||||
@@ -190,7 +191,7 @@ function onYouTubePlayerReady(playerId) {
|
||||
ytplayer.addEventListener("onError", "onPlayerError");
|
||||
if((typeof load_id != "undefined") && (load_id != 0)) {
|
||||
var id=load_id;
|
||||
loadNewVideo(id, 0);
|
||||
loadNewVideo(caption_id, id, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,11 +358,12 @@ function updateytplayerInfo() {
|
||||
}
|
||||
|
||||
// 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..."]};
|
||||
$.getJSON("/static/subs/"+id+".srt.sjson", function(data) {
|
||||
$.getJSON("/static/subs/"+cap_id+".srt.sjson", function(data) {
|
||||
captions=data;
|
||||
});
|
||||
caption_id = cap_id;
|
||||
load_id = id;
|
||||
//if ((typeof ytplayer != "undefined") && (ytplayer.type=="application/x-shockwave-flash")) {
|
||||
// Try it every time. If we fail, we want the error message for now.
|
||||
@@ -378,6 +380,15 @@ function loadNewVideo(id, 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) {
|
||||
if (ytplayer) {
|
||||
ytplayer.cueVideoById(id, startSeconds);
|
||||
|
||||
Reference in New Issue
Block a user