Commit d9479bd3 by Kyle Fiedler

Added images for real this time and fixed merge conflicts

parents 16fdcd57 c991190c
/*!
* jQuery Cookie Plugin
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2011, Klaus Hartl
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://www.opensource.org/licenses/mit-license.php
* http://www.opensource.org/licenses/GPL-2.0
*/
(function($) {
$.cookie = function(key, value, options) {
// key and at least value given, set cookie...
if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) {
options = $.extend({}, options);
if (value === null || value === undefined) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
value = String(value);
return (document.cookie = [
encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// key and possibly options given, get cookie...
options = value || {};
var decode = options.raw ? function(s) { return s; } : decodeURIComponent;
var pairs = document.cookie.split('; ');
for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) {
if (decode(pair[0]) === key) return decode(pair[1] || ''); // IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, thus pair[1] may be undefined
}
return null;
};
})(jQuery);
......@@ -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,8 +86,13 @@ 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});
console.log("setting");
console.log(speed);
$.cookie("video_speed", speed, {'expires':3650, 'path':'/'});
}
function caption_at(index) {
......@@ -190,7 +195,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 +362,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 +384,15 @@ function loadNewVideo(id, startSeconds) {
//seekTo(startSeconds);
}
function syncPlayButton(){
var state = getPlayerState();
if (state == 1 || state == 3) {
$("#video_control").removeClass("play").addClass("pause");
} else if (state == 2 || state == -1 || state == 0){
$("#video_control").removeClass("pause").addClass("play");
}
}
function cueNewVideo(id, startSeconds) {
if (ytplayer) {
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