From 12e49831e199c8db877d1f4f14dae126cf2eb454 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 4 Oct 2013 16:26:34 +0200 Subject: [PATCH] Better ReplayTV support --- raitv.user.js | 77 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 12 deletions(-) diff --git a/raitv.user.js b/raitv.user.js index 07ac048..ec74e58 100644 --- a/raitv.user.js +++ b/raitv.user.js @@ -99,19 +99,9 @@ function() { // and of course once at the beginning of it all 8-) slReset(); - if (window.replayTv && window.replayTv.vid2data[replayTv.currVideo]) { - urls.std = window.replayTv.vid2data[replayTv.currVideo].h264; - } - var sch = document.getElementById("silverlightControlHost"); - if (!sch) { - sch = document.getElementById("SilverlightPlayer"); - sch.style.width = '100%'; - sch.style.height = '100%'; - } - if (sch) { - // debug - console.log(urls); + var sch; + var placeStreamList = function() { // find place to append the stream list to // if possible, look for an existing ul in what is likely to be the top // otherwise, create an ul and put it either in a miniLink if available, @@ -135,6 +125,69 @@ function() { specs.appendChild(streamlist); console.log(streamlist, 'appended'); + } + + var ourReplayTV = function(det) { + if (!sch) { + sch = document.getElementById("SilverlightPlayer"); + sch.style.width = '100%'; + sch.style.height = '100%'; + placeStreamList(); + } + // stop loading any current audio/video + if (sch.firstChild && sch.firstChild.src) { + console.log('stopping current A/V'); + sch.firstChild.src = ''; + } + + slReset(); + + var srcs = ""; + for (var k in det) { + if (k.match(/^h264/)) { + var url = det[k]; + if (url && url.length > 0) { + srcs += srctag(url, 'video', 'h264'); + var r = k.split('_'); + if (r[1]) { + r = r[0] + " (" + r[1] + "KB/s)"; + } else { + r = r[0]; + } + streamlist.appendChild(H5aRaw(r, url)); + } + } + } + // re-create the video player + sch.innerHTML = ""; + + } + + if (window.replayTv) { + window.replayTv.playVideo_ujs = window.replayTv.playVideo; + window.replayTv.playVideo = function(det) { + console.log("IN"); + try { + window.replayTv.playVideo_ujs.call(window.replayTv, det); + } catch (e) { + console.log(e); + } + ourReplayTV(det); + console.log("OUT"); + } + if (window.replayTv.currVideo) { + window.replayTv.playVideo(window.replayTv.vid2data[window.replayTv.currVideo]); + } + } + + sch = document.getElementById("silverlightControlHost"); + if (sch) { + // debug + console.log(urls); + + placeStreamList(); // if we are on a page that defines the videourl* metas, go straight to creating // the video element if (urls.std) { -- 2.32.0.93.g670b81a890