[xiph-commits] r18216 - websites/xiph.org/video
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Wed Feb 22 05:39:42 PST 2012
Author: xiphmont
Date: 2012-02-22 05:39:42 -0800 (Wed, 22 Feb 2012)
New Revision: 18216
Modified:
websites/xiph.org/video/video.js
Log:
Update the video.js driving the video pages to accept a time offset for linking
Modified: websites/xiph.org/video/video.js
===================================================================
--- websites/xiph.org/video/video.js 2012-02-21 22:59:16 UTC (rev 18215)
+++ websites/xiph.org/video/video.js 2012-02-22 13:39:42 UTC (rev 18216)
@@ -34,6 +34,24 @@
}
+// If the URL has a time offset query, set the video offset
+var uri_time = -1;
+function check_set_time(video, query)
+{
+ var queries = query.split("?");
+ for(q in queries) {
+ var f = queries[q].split("=");
+ var key = f[0];
+ var value = f[1];
+
+ if(key == "time"){
+ if(video && !(value===undefined))
+ uri_time = parseFloat(value);
+ }
+ }
+}
+
+
// Search up from one of the control elements until we hit the upper video wrapper
function findWrapper(el){
var wrapper = el;
@@ -95,6 +113,10 @@
// reloading the vid will cause it to start over; save play status and playtime
var playing = !(video.paused);
var position = video.currentTime;
+ if(uri_time > 0) {
+ position = uri_time;
+ uri_time = -1;
+ }
// update the video, video wrapper, and control wrapper size
video.style.width = vid_width;
@@ -140,7 +162,7 @@
// the old vid left off until metadata has successfully loaded;
// push the rest of the playback resume process into a callback
video.addEventListener("loadedmetadata",
- function() {
+ function() {
// don't set if zero; that will drop the poster and cause preload
if(position>0)
video.currentTime = position;
@@ -215,6 +237,12 @@
fixupVideo(this);
});
+ // the URI might have an anchor requesting a specific time
+ // offset
+ $('video').each(function() {
+ check_set_time(this, window.location.search);
+ });
+
$('.vid_control').each(function() {
this.onmouseout=function(){mousein=0;hideControls(this)};
this.onmouseover=function(){mousein=1;showControls(this)};
@@ -248,5 +276,6 @@
this.onfocus=function(){focusControl(this);};
this.onchange=function(){SetTime(this);};
});
+
});
More information about the commits
mailing list