Commit f07b4425 authored by spoinsar's avatar spoinsar
Browse files

fix youtube-like timecode link in video descrition


git-svn-id: http://subversion.utc/svn/webtv@200 6dbbdbe0-869d-41b9-a499-9a762c387331
parent 496ded0b
......@@ -29,6 +29,7 @@ var mp4_hd='{$mp4_hd}';
var vp9_sd='{$vp9_sd}';
var vp9_hd='{$vp9_hd}';
var width="{$player_data.width}";
{literal}
videojs("mainvid",
{
......@@ -48,8 +49,11 @@ videojs("mainvid",
},function(){
var player=this;
window.player = player;
// strangly can't use "canPlayType" on the videojs player on this version
var dummyplayer = document.createElement('video');
var srcarray=new Array();
if (vp9_sd) {
if (vp9_sd && dummyplayer.canPlayType('video/webm; codecs="vp9, opus"')=='probably') {
srcarray.push(
{
src: vp9_sd,
......@@ -60,7 +64,7 @@ videojs("mainvid",
}
);
}
if (vp9_hd) {
if (vp9_hd && dummyplayer.canPlayType('video/webm; codecs="vp9, opus"')=='probably') {
srcarray.push(
{
src: vp9_hd,
......@@ -95,6 +99,12 @@ videojs("mainvid",
}
player.updateSrc(srcarray);
var time=getTimeFromHash(location.hash);
if (time) {
videoseek(time);
}
{/literal}
{if $vdata.broadcast!='public'}
{literal}
......@@ -103,5 +113,28 @@ videojs("mainvid",
{/if}
{literal}
});
// time conversion function based on http://stackoverflow.com/a/9640417
function hmsToSecondsOnly(str) {
var p = str.split(':'),
s = 0, m = 1;
while (p.length > 0) {
s += m * parseInt(p.pop(), 10);
m *= 60;
}
return s;
}
function getTimeFromHash(url) {
return url.substr(url.indexOf('time=')).split('&')[0].split('=')[1];
}
function videoseek(str) {
player.currentTime(hmsToSecondsOnly(str));
player.poster(null);
}
{/literal}
</script>
\ No newline at end of file
Supports Markdown
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