From 026eb7098191feadbd76ca1852209c404bd40ada Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Mon, 27 Feb 2012 18:22:00 -0500 Subject: [PATCH] Video player instrumented to see speeds --- js/video_player.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/js/video_player.js b/js/video_player.js index fdc12c62c5..73a727a14c 100644 --- a/js/video_player.js +++ b/js/video_player.js @@ -87,6 +87,7 @@ function change_video_speed(speed, youtube_id) { new_position = ytplayer.getCurrentTime() * video_speed / speed; video_speed = speed; ytplayer.loadVideoById(youtube_id, new_position); + log_event("speed", {"new_speed":speed, "clip":youtube_id}); } function caption_at(index) { @@ -298,6 +299,7 @@ function onytplayerStateChange(newState) { function onPlayerError(errorCode) { // alert("An error occured: " + errorCode); + log_event("player_error", {"error":errorCode}); } // Currently duplicated to check for if video control changed by clicking the video for HTML5 @@ -349,6 +351,7 @@ function loadNewVideo(id, startSeconds) { catch(e) { window['console'].log(JSON.stringify(e)); } + log_event("load_video", {"id":id,"start":startSeconds}); //$("#slider").slider("option","value",startSeconds); //seekTo(startSeconds); } @@ -363,18 +366,21 @@ function play() { if (ytplayer) { ytplayer.playVideo(); } + log_event("play_video", {"id":getCurrentTime(), "code":getEmbedCode()}); } function pause() { if (ytplayer) { ytplayer.pauseVideo(); } + log_event("pause_video", {"id":getCurrentTime(), "code":getEmbedCode()}); } function stop() { if (ytplayer) { ytplayer.stopVideo(); } + log_event("stop_video", {"id":getCurrentTime(), "code":getEmbedCode()}); } function getPlayerState() { @@ -426,11 +432,15 @@ function unMute() { } function getEmbedCode() { - alert(ytplayer.getVideoEmbedCode()); + if(ytplayer) { + ytplayer.getVideoEmbedCode(); + } } function getVideoUrl() { - alert(ytplayer.getVideoUrl()); + if(ytplayer) { + ytplayer.getVideoUrl(); + } } function setVolume(newVolume) {