diff options
Diffstat (limited to 'smarttv-client')
-rw-r--r-- | smarttv-client/Javascript/Buttons.js | 173 | ||||
-rwxr-xr-x | smarttv-client/Javascript/Display.js | 557 | ||||
-rw-r--r-- | smarttv-client/Javascript/Helpbar.js | 11 | ||||
-rwxr-xr-x | smarttv-client/Javascript/Main.js | 99 | ||||
-rwxr-xr-x | smarttv-client/Javascript/Options.js | 13 | ||||
-rwxr-xr-x | smarttv-client/Javascript/Player.js | 15 | ||||
-rwxr-xr-x | smarttv-client/Javascript/Server.js | 64 | ||||
-rwxr-xr-x | smarttv-client/config.xml | 2 | ||||
-rwxr-xr-x | smarttv-client/index.html | 9 |
9 files changed, 644 insertions, 299 deletions
diff --git a/smarttv-client/Javascript/Buttons.js b/smarttv-client/Javascript/Buttons.js new file mode 100644 index 0000000..bec1155 --- /dev/null +++ b/smarttv-client/Javascript/Buttons.js @@ -0,0 +1,173 @@ +var Buttons = {
+ created: false,
+ btnSelected : 0,
+ btnMax : 1
+};
+
+/*
+ * First: do just the buttons for play / resume
+ */
+Buttons.init = function (){
+ if (this.created == false) {
+ Buttons.createButtons();
+ $("#pr-popup").hide();
+ this.created = true;
+ }
+};
+
+Buttons.show = function () {
+ Main.log("Buttons.show()");
+ $("#pr-popup").show();
+ $("#pr-popup-anchor").focus();
+
+ Buttons.reset ();
+};
+
+
+Buttons.hide = function () {
+ $("#pr-popup").hide();
+ $("#pr-popup-anchor").blur();
+ Main.enableKeys();
+};
+
+Buttons.createButtons= function () {
+ var p_width = $("body").outerWidth();
+ var p_height = $("body").outerHeight();
+
+ var sheet = $("<style>");
+ sheet.attr({type : 'text/css',
+ innerHTML : '\
+ #pr-popup { display:table; width:40%; height: 30%; position: absolute; text-align:center; border-width:1px;\
+ background:rgba(0,0,139, 0.8);border-style:solid;border-width:1px;border-radius:15px;\
+ -webkit-box-shadow:3px 3px 7px 4px rgba(0,0,0, 0.5);}\
+ .pr-btn { display:inline-block; \
+ margin-left: 10px; \
+ padding: 10px 10px 10px 10px;\
+ border-radius:10px; \
+ font-size:16px;\
+ border-style:solid;\
+ border-width:1px;\
+ background: transparent;}\
+ .pr-btn-pressed {display:inline-block; \
+ margin-left: 10px; \
+ padding: 10px 10px 10px 10px;\
+ border-radius:10px; \
+ font-size:16px;\
+ border-style:solid;\
+ border-width:1px;\
+ background: "white";\
+ background: "-webkit-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1) 100%)";\
+ }\
+ .pr-helpbar {display:inline-block;}\
+ }'});
+ $('body').append(sheet);
+
+// var domNode = $("<div>", {id: "pr-popup", "onkeydown":"Buttons.onInput();"});
+
+ var row = $('<div>');
+ row.css({"height":"80%", "display":"table-row", "vertical-align":"middle"});
+ var cell = $("<div>");
+ cell.css({"display":"table-cell", "vertical-align":"middle"});
+ cell.appendTo(row);
+ $("<button>", {id : "pr-btn-0", text: "Play", class: "pr-btn"}).appendTo(cell);
+ $("<button>", {id : "pr-btn-1", text: "Resume", class: "pr-btn"}).appendTo(cell);
+ $("#pr-popup").append(row);
+
+ $("#pr-popup").css({"left": ((p_width - $("#pr-popup").outerWidth()) /2) +"px", "top": ((p_height - $("#pr-popup").outerHeight()) /2) +"px"});
+
+ row = $('<div>', {style: "display:table-row; vertical-align:bottom; text-align:center"});
+// row.css({"display":"table-row", "vertical-align":"bottom"});
+ $("#pr-popup").append(row);
+ var elm = $("<div>", {class: "pr-helpbar"});
+ elm.css({"display":"table-cell", "vertical-align":"bottom"});
+ elm.appendTo(row);
+ Buttons.addHelpItem(elm, "Images/helpbar/help_lr.png", "Select");
+ Buttons.addHelpItem(elm, "Images/helpbar/help_enter.png", "OK");
+ Buttons.addHelpItem(elm, "Images/helpbar/help_back.png", "Cancel");
+
+
+ // row.appendTo(domNode);
+// $('body').append(domNode);
+
+ // Center
+// domNode.css({"left": ((p_width - domNode.outerWidth()) /2) +"px", "top": ((p_height - domNode.outerHeight()) /2) +"px"});
+
+
+};
+
+Buttons.addHelpItem = function(elm, url, msg) {
+// var hb_elm = $("<td>");
+
+ var hb_elm = $("<div>");
+ hb_elm.css({"display":"inline-block", "padding-right":"10px"});
+ elm.append(hb_elm);
+
+ hb_elm.append($("<img>", { src: url, style: "display:inline-block"}));
+ hb_elm.append($("<div>", { text: msg, style: "display:inline-block; padding-bottom:10px"}));
+
+ };
+
+Buttons.reset = function () {
+ for (var i =0; i <= Buttons.btnMax; i++) {
+ $("#pr-btn-" + i).removeClass('pr-btn-pressed').addClass('pr-btn');
+ }
+ $("#pr-btn-0").removeClass('pr-btn').addClass('pr-btn-pressed');
+};
+
+Buttons.selectBtnLeft = function () {
+ var btnname = "#pr-btn-"+Buttons.btnSelected;
+ Main.log("BtnLeft: Old: " +Buttons.btnSelected + " btn= "+btnname);
+ $(btnname).removeClass('pr-btn-pressed').addClass('pr-btn');
+ if (Buttons.btnSelected == 0)
+ Buttons.btnSelected = Buttons.btnMax;
+ else
+ Buttons.btnSelected--;
+ $("#pr-btn-" + Buttons.btnSelected).removeClass('pr-btn').addClass('pr-btn-pressed');
+ Main.log("BtnLeft: New: " +Buttons.btnSelected);
+};
+
+Buttons.selectBtnRight = function () {
+ $("#pr-btn-" + Buttons.btnSelected).removeClass('pr-btn-pressed').addClass('pr-btn');
+ if (Buttons.btnSelected == Buttons.btnMax)
+ Buttons.btnSelected = 0;
+ else
+ Buttons.btnSelected++;
+ $("#pr-btn-" + Buttons.btnSelected).removeClass('pr-btn').addClass('pr-btn-pressed');
+};
+
+Buttons.onInput = function () {
+ var keyCode = event.keyCode;
+ alert("Buttons Input= " + keyCode);
+ switch(keyCode) {
+ case tvKey.KEY_LEFT:
+ Main.log("Select Left");
+ Buttons.selectBtnLeft();
+ break;
+ case tvKey.KEY_RIGHT:
+ Main.log("Select Right");
+ Buttons.selectBtnRight();
+ break;
+ case tvKey.KEY_ENTER:
+ Main.log("Enter");
+ Display.hide();
+ Display.showProgress();
+ switch(Buttons.btnSelected){
+ case 0:
+ Main.logToServer("Buttons: Play from start");
+ Player.playVideo(-1);
+ break;
+ case 1:
+ Main.logToServer("Buttons: Resume from "+Player.resumePos);
+ Player.playVideo(Player.resumePos);
+// Server.getResume(Player.guid);
+ break;
+ }
+ Buttons.hide();
+ break;
+ case tvKey.KEY_RETURN:
+ Buttons.hide();
+ break;
+
+ }
+ widgetAPI.blockNavigation(event);
+ };
\ No newline at end of file diff --git a/smarttv-client/Javascript/Display.js b/smarttv-client/Javascript/Display.js index 218f942..4f181ae 100755 --- a/smarttv-client/Javascript/Display.js +++ b/smarttv-client/Javascript/Display.js @@ -6,6 +6,7 @@ var Display = bufferingElm : null,
FIRSTIDX : 0,
LASTIDX : 15,
+ itemHeight : 0,
currentWindow : 0,
olTitle : "",
@@ -20,7 +21,10 @@ var Display = videoList : new Array()
};
-
+/*
+ * General Functions
+ *
+ */
Display.init = function()
{
@@ -55,18 +59,9 @@ Display.init = function() $(elm).append($("<div>").css({ "display": "inline-block", "padding-top": "4px", "padding-bottom": "6px", "width":"70%"}));
$(elm).append($("<div>").css({ "display": "inline-block", "padding-top": "4px", "padding-bottom": "6px", "width":"5%"}));
-/* $(elm).children("div").eq(0).text ("Hallo1");
- $(elm).children("div").eq(1).text ("Hallo2");
- $(elm).children("div").eq(2).text ("Hallo3");
-*/
-/*
- * var elm = document.getElementById("video"+i);
- elm.style.paddingLeft = "10px";
- elm.style.paddingTop = "4px";
- elm.style.paddingBottom = "6px";
- */
}
+
var done = false;
var i = 0;
@@ -88,13 +83,6 @@ Display.init = function() return success;
};
-Display.setVideoItem = function (elm, cnt) {
- // cnt
- $(elm).children("div").eq(0).text (cnt.c1);
- $(elm).children("div").eq(1).text (cnt.c2);
- $(elm).children("div").eq(2).text (cnt.c3);
-};
-
Display.putInnerHTML = function (elm, val) {
alert(Config.deviceType + " " +elm + " " + val);
switch (Config.deviceType) {
@@ -125,124 +113,6 @@ Display.GetEpochTime = function() { return res;
};
-Display.resetSelectItems = function (itm) {
- var done = false;
- var i = 0;
- while (done != true) {
- i ++;
- var elm = document.getElementById("selectItem"+i);
- if (elm == null) {
- done = true;
- Main.log( " only found to selectItem"+ (i-1));
- break;
- }
- Display.unselectItem(elm);
- }
- Display.selectItem(document.getElementById("selectItem"+itm));
-};
-
-Display.resetVideoList = function () {
- var done = false;
- var i = 0;
- while (done != true) {
- i ++;
- var elm = document.getElementById("video"+i);
- if (elm == null) {
- done = true;
- break;
- }
- Display.unselectItem(elm);
- Display.setVideoItem(elm, {c1: "", c2: "", c3: ""});
- }
-
-};
-
-Display.setOlTitle = function (title) {
- this.olTitle = title;
- var elm = document.getElementById("olTitle");
- Display.putInnerHTML(elm, Display.olTitle);
-};
-
-Display.resetStartStop = function () {
- Display.olStartStop = "";
- var elm = document.getElementById("olStartStop");
- Display.putInnerHTML(elm, Display.olStartStop);
-
-};
-Display.setStartStop = function(start, stop) {
- this.olStartStop = "";
-
- var digi =new Date(start * 1000);
- var hours=digi.getHours();
- var minutes=digi.getMinutes();
- if (minutes<=9)
- minutes='0'+minutes;
- this.olStartStop = hours + ":" + minutes + " - ";
-
- digi =new Date(stop * 1000);
- hours=digi.getHours();
- minutes=digi.getMinutes();
- if (minutes<=9)
- minutes='0'+minutes;
- this.olStartStop = this.olStartStop + hours + ":" + minutes;
-
- var elm = document.getElementById("olStartStop");
- Display.putInnerHTML(elm, Display.olStartStop);
-};
-
-Display.setSkipDuration = function(duration) {
- this.olStartStop = "";
-
- this.olStartStop = duration;
-
- var elm = document.getElementById("olStartStop");
- Display.putInnerHTML(elm, "Next Skip: " + Display.olStartStop+"sec");
-};
-
-// Player.OnCurrentPlayTime
-Display.updatePlayTime = function() {
-// Player.curPlayTimeStr = Display.getHumanTimeRepresentation(Player.curPlayTime);
- var timeElement = document.getElementById("olTimeInfo");
- Display.putInnerHTML(timeElement, Player.curPlayTimeStr + " / " + Player.totalTimeStr);
-};
-
-Display.updateProgressBar = function () {
- var timePercent = (Player.curPlayTime *100)/ Player.totalTime;
- document.getElementById("olProgressBar").style.width = Math.round(timePercent) + "%";
-};
-
-Display.updateRecBar = function (start_time, duration){
- var now = Display.GetEpochTime();
-
- var remaining = Math.round(((start_time + duration) - now) * 100/ duration);
-// Main.log (" remaining= " + remaining + " start= " + start_time + " dur= " + duration);
- var elm = document.getElementById("olRecProgressBar");
- elm.style.display="block";
- elm.style.width = remaining + "%";
- elm.style.left = (100 - remaining) + "%";
-};
-
-
-Display.status = function(status) {
- Main.log(status);
- Display.putInnerHTML(this.statusDiv, status);
- Display.putInnerHTML(this.statusPopup, status);
-};
-
-Display.showStatus = function() {
- this.statusPopup.style.display="block";
-};
-
-Display.hideStatus = function() {
- this.statusPopup.style.display="none";
-};
-
-
-Display.progress = function(status) {
- Display.putInnerHTML(this.statusDiv, status);
-};
-
-
Display.durationString = function(time) {
var timeHour = 0;
var timeMinute = 0;
@@ -275,56 +145,6 @@ Display.durationString = function(time) { };
-Display.handleDescription =function (selected) {
- Main.log("Display.handleDescription ");
-
- if (Data.getCurrentItem().childs[selected].isFolder == true) {
- Display.setDescription( "Dir: " +Data.getCurrentItem().childs[selected].title );
- }
- else {
- var itm = Data.getCurrentItem().childs[selected];
- var title = itm.title;
- var prog = itm.payload.prog;
- var desc = itm.payload.desc;
- var length = itm.payload.dur;
-
- var digi = new Date(parseInt(itm.payload.start*1000));
- var mon = Display.getNumString ((digi.getMonth()+1), 2);
- var day = Display.getNumString (digi.getDate(), 2);
- var hour = Display.getNumString (digi.getHours(), 2);
- var min = Display.getNumString (digi.getMinutes(), 2);
-
- var d_str ="";
- var msg = "";
- if (Main.state == 1) {
- // Live
- var now = Display.GetEpochTime();
-
- d_str = hour + ":" + min;
-
- msg += title + "<br>";
- msg += "<b>"+ prog + "</b><br>";
- msg += "<br>Start: " + d_str + "<br>";
- msg += "Duration: " + Display.durationString(length) + "h<br>";
- Main.log("itm.payload.start= " + itm.payload.start + " length= " + length + " now= " +now);
- msg += "Remaining: " + Display.durationString((itm.payload.start + length - now));
-
-
- }
- else {
- // on-demand
- d_str = mon + "/" + day + " " + hour + ":" + min;
-
- msg += "<b>" + title + "</b>";
- msg += "<br><br>" + d_str;
- msg += " Duration: " + Display.durationString(length) + "h";
- }
- msg += "<br><br>"+ desc;
- Display.setDescription(msg);
- }
-
-};
-
Display.getNumString =function(num, fmt) {
var res = "";
@@ -343,43 +163,77 @@ Display.getNumString =function(num, fmt) { return res;
};
-Display.getDisplayTitle = function(item) {
- var res = {c1:"", c2:"", c3:""};
- switch (Main.state) {
- case 1:
- // Live
- if (item.isFolder == true) {
- res.c2 = item.title;
- res.c3 = "<" + Display.getNumString(item.childs.length, 2) +">";
- }
- else {
- res.c2 = item.title;
- }
- break;
- case 2:
- case 3:
- // Recordings
- if (item.isFolder == true) {
- res.c1 = "<" + Display.getNumString(item.childs.length, 3) + ">";
- res.c2 = item.title;
- }
- else {
- var digi = new Date(parseInt(item.payload.start*1000));
- var mon = Display.getNumString ((digi.getMonth()+1), 2);
- var day = Display.getNumString (digi.getDate(), 2);
- var hour = Display.getNumString (digi.getHours(), 2);
- var min = Display.getNumString (digi.getMinutes(), 2);
+Display.selectItem = function (item) {
- var d_str = mon + "/" + day + " " + hour + ":" + min;
- res.c1 = d_str;
- res.c2 = item.title;
- }
- break;
- default:
- Main.log("ERROR: Shall be in state 1 or 2. State= " + Main.state);
- break;
- }
- return res;
+ item.style.color = "black";
+ item.style.background = "white";
+ item.style.background = "-webkit-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1) 100%)";
+ item.style.borderRadius= "3px";
+ item.style["-webkit-box-shadow"] = "2px 2px 1px 2px rgba(0,0,0, 0.5)";
+ // item.style.backgroundColor = "white";
+
+};
+
+Display.unselectItem = function (item) {
+ item.style.color = "white";
+ item.style.backgroundColor = "transparent";
+ item.style.background = "transparent";
+ item.style["-webkit-box-shadow"] = "";
+};
+
+Display.jqSelectItem = function (item) {
+ //item is a JQ Object
+ item.css( {"color": "black", "background" : "white",
+ "background" : "-webkit-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1) 100%)",
+ "border-radius": "3px",
+ "-webkit-box-shadow": "2px 2px 1px 2px rgba(0,0,0, 0.5)"
+ });
+};
+
+Display.jqUnselectItem = function (item) {
+ item.css ({"color" : "white", "background" : "transparent", "-webkit-box-shadow": ""});
+};
+
+/*
+ * Main Select Screen Functions
+ *
+ */
+Display.resetSelectItems = function (itm) {
+ var done = false;
+ var i = 0;
+ while (done != true) {
+ i ++;
+ var elm = document.getElementById("selectItem"+i);
+ if (elm == null) {
+ done = true;
+ Main.log( " only found to selectItem"+ (i-1));
+ break;
+ }
+ Display.unselectItem(elm);
+ }
+ Display.selectItem(document.getElementById("selectItem"+itm));
+};
+
+/*
+ * Video Select Screen Functions
+ *
+ */
+Display.hide = function() {
+// document.getElementById("main").style.display="none";
+ $("#main").hide();
+};
+
+Display.show = function() {
+ // cancel ongoing overlays first
+ this.volOlHandler.cancel();
+ this.progOlHandler.cancel();
+ this.popupOlHandler.cancel();
+// document.getElementById("main").style.display="block";
+ $("#main").show();
+
+ this.itemHeight = Math.round(parseInt($("#videoList").height()) / (this.LASTIDX +1) );
+ alert ("vidList= " + $("#videoList").height()+ " itmHeight= " + this.itemHeight );
+
};
Display.setVideoList = function(selected, first) {
@@ -414,25 +268,92 @@ Display.setVideoList = function(selected, first) { Display.putInnerHTML(document.getElementById("videoCount"), listHTML);
};
-Display.selectItem = function (item) {
+Display.setVideoItem = function (elm, cnt) {
+ // cnt
+ $(elm).children("div").eq(0).text (cnt.c1);
+ $(elm).children("div").eq(1).text (cnt.c2);
+ $(elm).children("div").eq(2).text (cnt.c3);
- item.style.color = "black";
- item.style.background = "white";
- item.style.background = "-webkit-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1) 100%)";
- item.style.borderRadius= "3px";
- item.style["-webkit-box-shadow"] = "2px 2px 1px 2px rgba(0,0,0, 0.5)";
- // item.style.backgroundColor = "white";
+ var itm = $(elm).children("div").eq(1);
+ if (itm.outerHeight() > this.itemHeight) {
+ var temp = cnt.c2;
+ while(itm.outerHeight() > this.itemHeight) {
+ temp = temp.substr(0, temp.length-1);
+ itm.text(temp + '...');
+ }
+ }
+};
+//Video Select Screen
+Display.resetVideoList = function () {
+ var done = false;
+ var i = 0;
+ while (done != true) {
+ var elm = document.getElementById("video"+i);
+ if (elm == null) {
+ done = true;
+ break;
+ }
+ Display.unselectItem(elm);
+ Display.setVideoItem(elm, {c1: "", c2: "", c3: ""});
+ i ++;
+ }
+
};
-Display.unselectItem = function (item) {
- item.style.color = "white";
- item.style.backgroundColor = "transparent";
- item.style.background = "transparent";
- item.style["-webkit-box-shadow"] = "";
+//Video Select Screen
+Display.handleDescription =function (selected) {
+ Main.log("Display.handleDescription ");
+
+ if (Data.getCurrentItem().childs[selected].isFolder == true) {
+ Display.setDescription( "Dir: " +Data.getCurrentItem().childs[selected].title );
+ }
+ else {
+ var itm = Data.getCurrentItem().childs[selected];
+ var title = itm.title;
+ var prog = itm.payload.prog;
+ var desc = itm.payload.desc;
+ var length = itm.payload.dur;
+
+ var digi = new Date(parseInt(itm.payload.start*1000));
+ var mon = Display.getNumString ((digi.getMonth()+1), 2);
+ var day = Display.getNumString (digi.getDate(), 2);
+ var hour = Display.getNumString (digi.getHours(), 2);
+ var min = Display.getNumString (digi.getMinutes(), 2);
+
+ var d_str ="";
+ var msg = "";
+ if (Main.state == 1) {
+ // Live
+ var now = Display.GetEpochTime();
+
+ d_str = hour + ":" + min;
+
+ msg += title + "<br>";
+ msg += "<b>"+ prog + "</b><br>";
+ msg += "<br>Start: " + d_str + "<br>";
+ msg += "Duration: " + Display.durationString(length) + "h<br>";
+ Main.log("itm.payload.start= " + itm.payload.start + " length= " + length + " now= " +now);
+ msg += "Remaining: " + Display.durationString((itm.payload.start + length - now));
+
+
+ }
+ else {
+ // on-demand
+ d_str = mon + "/" + day + " " + hour + ":" + min;
+
+ msg += "<b>" + title + "</b>";
+ msg += "<br><br>" + d_str;
+ msg += " Duration: " + Display.durationString(length) + "h";
+ }
+ msg += "<br><br>"+ desc;
+ Display.setDescription(msg);
+ }
+
};
+
/*
* this.currentWindow: Cursor (selected item)
*/
@@ -522,6 +443,142 @@ Display.setDescription = function(description) { Display.putInnerHTML(descriptionElement, description);
};
+
+/*
+ * Overlay Functions
+ *
+ */
+/*
+ * Progress Overlay
+ *
+ */
+Display.setOlTitle = function (title) {
+ this.olTitle = title;
+ var elm = document.getElementById("olTitle");
+ Display.putInnerHTML(elm, Display.olTitle);
+};
+
+Display.resetStartStop = function () {
+ Display.olStartStop = "";
+ var elm = document.getElementById("olStartStop");
+ Display.putInnerHTML(elm, Display.olStartStop);
+
+};
+Display.setStartStop = function(start, stop) {
+ this.olStartStop = "";
+
+ var digi =new Date(start * 1000);
+ var hours=digi.getHours();
+ var minutes=digi.getMinutes();
+ if (minutes<=9)
+ minutes='0'+minutes;
+ this.olStartStop = hours + ":" + minutes + " - ";
+
+ digi =new Date(stop * 1000);
+ hours=digi.getHours();
+ minutes=digi.getMinutes();
+ if (minutes<=9)
+ minutes='0'+minutes;
+ this.olStartStop = this.olStartStop + hours + ":" + minutes;
+
+ var elm = document.getElementById("olStartStop");
+ Display.putInnerHTML(elm, Display.olStartStop);
+};
+
+Display.setSkipDuration = function(duration) {
+ this.olStartStop = "";
+
+ this.olStartStop = duration;
+
+ var elm = document.getElementById("olStartStop");
+ Display.putInnerHTML(elm, "Next Skip: " + Display.olStartStop+"sec");
+};
+
+// Player.OnCurrentPlayTime
+Display.updatePlayTime = function() {
+// Player.curPlayTimeStr = Display.getHumanTimeRepresentation(Player.curPlayTime);
+ var timeElement = document.getElementById("olTimeInfo");
+ Display.putInnerHTML(timeElement, Player.curPlayTimeStr + " / " + Player.totalTimeStr);
+};
+
+Display.updateProgressBar = function () {
+ var timePercent = (Player.curPlayTime *100)/ Player.totalTime;
+ document.getElementById("olProgressBar").style.width = Math.round(timePercent) + "%";
+};
+
+Display.updateRecBar = function (start_time, duration){
+ var now = Display.GetEpochTime();
+
+ var remaining = Math.round(((start_time + duration) - now) * 100/ duration);
+// Main.log (" remaining= " + remaining + " start= " + start_time + " dur= " + duration);
+ var elm = document.getElementById("olRecProgressBar");
+ elm.style.display="block";
+ elm.style.width = remaining + "%";
+ elm.style.left = (100 - remaining) + "%";
+};
+
+
+Display.status = function(status) {
+ Main.log(status);
+ Display.putInnerHTML(this.statusDiv, status);
+ Display.putInnerHTML(this.statusPopup, status);
+};
+
+Display.showStatus = function() {
+ this.statusPopup.style.display="block";
+};
+
+Display.hideStatus = function() {
+ this.statusPopup.style.display="none";
+};
+
+
+Display.progress = function(status) {
+ Display.putInnerHTML(this.statusDiv, status);
+};
+
+
+Display.getDisplayTitle = function(item) {
+ var res = {c1:"", c2:"", c3:""};
+ switch (Main.state) {
+ case 1:
+ // Live
+ if (item.isFolder == true) {
+ res.c2 = item.title;
+ res.c3 = "<" + Display.getNumString(item.childs.length, 2) +">";
+ }
+ else {
+ res.c2 = item.title;
+ }
+ break;
+ case 2:
+ case 3:
+ // Recordings
+ if (item.isFolder == true) {
+ res.c1 = "<" + Display.getNumString(item.childs.length, 3) + ">";
+ res.c2 = item.title;
+ }
+ else {
+ var digi = new Date(parseInt(item.payload.start*1000));
+ var mon = Display.getNumString ((digi.getMonth()+1), 2);
+ var day = Display.getNumString (digi.getDate(), 2);
+ var hour = Display.getNumString (digi.getHours(), 2);
+ var min = Display.getNumString (digi.getMinutes(), 2);
+
+ var d_str = mon + "/" + day + " " + hour + ":" + min;
+ res.c1 = d_str;
+ res.c2 = item.title;
+ }
+ break;
+ default:
+ Main.log("ERROR: Shall be in state 1 or 2. State= " + Main.state);
+ break;
+ }
+ return res;
+};
+
+
+
//--------------------------------------------------------
Display.bufferUpdate = function() {
// Player.bufferState
@@ -530,19 +587,9 @@ Display.bufferUpdate = function() { };
//--------------------------------------------------------
-Display.hide = function()
-{
- document.getElementById("main").style.display="none";
-};
-
-Display.show = function() {
- // cancel ongoing overlays first
- this.volOlHandler.cancel();
- this.progOlHandler.cancel();
- this.popupOlHandler.cancel();
- document.getElementById("main").style.display="block";
-};
-
+/*
+ * Volume Control Handlers (obsolete)
+ */
//---------------------------------------------------------
Display.setVolume = function(level)
{
@@ -571,6 +618,9 @@ Display.handlerHideVolume = function() { //---------------------------------------------------------
+/*
+ * Popup handlers
+ */
Display.showPopup = function(text) {
var oldHTML = document.getElementById("popup").innerHTML;
Display.putInnerHTML(document.getElementById("popup"), oldHTML + "<br>" + text);
@@ -639,8 +689,10 @@ Display.handlerShowProgress = function() { };
-
-//----------------------------------------
+/*
+ * OverlayHandler Class
+ *
+ */
function OverlayHandler (n) {
// this.pluginTime = null;
this.active = false;
@@ -670,9 +722,7 @@ OverlayHandler.prototype.init = function(showcb, hidecb) { OverlayHandler.prototype.checkHideCallback = function () {
var now = Display.GetEpochTime();
- // Main.log(that.handlerName + "checkHideCallback: now= " + now + " hideTime= " + that.hideTime + " delta= " + (now - that.hideTime));
if (now >= this.hideTime) {
-// Main.log(this.handlerName + "hiding " + this.handlerName + " howDur: act= " + (now - this.startTime) + " int= " + (this.hideTime-this.startTime));
this.olDelay = 3000;
if (this.hideCallback) {
@@ -685,9 +735,8 @@ OverlayHandler.prototype.checkHideCallback = function () { return;
}
var delay = (this.hideTime - now) * 1000;
-// Main.log(this.handlerName + "checkHideCallback: new timeout= " +delay);
- // pass an anonymous function
+ // pass an anonymous function to keep the context
var self = this;
this.timeoutObj = window.setTimeout(function() {self.checkHideCallback(); }, delay);
};
@@ -711,8 +760,6 @@ OverlayHandler.prototype.show = function() { Main.log(this.handlerName + ": No showCallback defined - ignoring " );
}
else {
-// Main.log(this.handlerName + " extending showtime for " + this.handlerName + " for another " + (this.olDelay /1000)+ "sec");
-// this.hideTime = this.pluginTime.GetEpochTime() + (this.olDelay /1000);
this.hideTime = Display.GetEpochTime() + (this.olDelay /1000);
}
};
diff --git a/smarttv-client/Javascript/Helpbar.js b/smarttv-client/Javascript/Helpbar.js index 0196d78..61e51bf 100644 --- a/smarttv-client/Javascript/Helpbar.js +++ b/smarttv-client/Javascript/Helpbar.js @@ -1,4 +1,3 @@ -
var Helpbar = {
isInited : false
};
@@ -23,13 +22,13 @@ Helpbar.createHelpbar = function() { var sheet = $("<style>");
sheet.attr({type : 'text/css',
innerHTML : '\
- .hb-bg {width:960px; height: 40px; left: 0px; top: 480px; font-size:16px;background: darkblue;background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 50%,#1e5799 100%);}\
+ .hb-bg {left:0px; top:480px; width:960px; height:40px; position: absolute; font-size:18px; background: darkblue;background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 50%,#1e5799 100%);}\
}'});
$('body').append(sheet);
-
+// $('<div>', { id: "helpbar", class: "hb-bg"}).appendTo ($("body"));
+// $('<div>', {id: "hb-row"}).appendTo("#helpbar");
$("<table>", {id:"helpbar", class: "hb-bg"}).appendTo ($("body"));
-// $("#helpbar").hide();
$("<tr>", {id: "hb-row", align:"center", valign:"middle"}).appendTo("#helpbar");
Helpbar.addItem("Images/helpbar/help_lr.png", "Move Cursor");
@@ -42,9 +41,10 @@ Helpbar.createHelpbar = function() { Helpbar.addItem("Images/helpbar/help_blue.png", "Colon (:)");
};
-
Helpbar.addItem = function(url, msg) {
var hb_elm = $("<td>");
+// var hb_elm = $("<div>");
+// hb_elm.css({"display":"inline-block"});
hb_elm.appendTo("#hb-row");
var tab = $("<table>");
@@ -54,5 +54,4 @@ Helpbar.addItem = function(url, msg) { $("<td>").append($("<img>", { src: url})).appendTo(row);
$("<td>").append($("<p>", { text: msg})).appendTo(row);
-
};
\ No newline at end of file diff --git a/smarttv-client/Javascript/Main.js b/smarttv-client/Javascript/Main.js index 10bf7fa..69db6ae 100755 --- a/smarttv-client/Javascript/Main.js +++ b/smarttv-client/Javascript/Main.js @@ -57,6 +57,12 @@ var Main = { NMUTE : 0,
YMUTE : 1,
+
+ eMAIN : 0, // state Main Select
+ eLIVE : 1, // State Live Select Screen / Video Playing
+ eREC : 2, // State Recording Select Screen / Video Playing
+ eMED : 3, // State Media Select Screen / Video Playing
+ eOPT : 4, // Options
defKeyHndl : null,
selectMenuKeyHndl : null,
@@ -86,6 +92,9 @@ Main.onLoad = function() { // Display.showPopup("Not a Samsung Smart TV. Lets see, how far we come");
}
+ $.ajaxSetup ({
+ cache: false
+ });
Display.init();
Display.selectItem(document.getElementById("selectItem1"));
Spinner.init();
@@ -119,6 +128,7 @@ showHandler = function() { Main.init = function () {
Main.log("Main.init()");
+ Buttons.init();
if ( Player.init() && Server.init() && Audio.init()) {
Display.setVolume( Audio.getVolume() );
@@ -141,6 +151,7 @@ Main.init = function () { else {
Main.log("Failed to initialise");
}
+
/*
*
* Fetch JS file
@@ -185,7 +196,7 @@ Main.changeState = function (state) { this.state = state;
switch (this.state) {
- case 0:
+ case Main.eMAIN:
Main.selectMenuKeyHndl.select = old_state;
Main.log ("old Select= " + Main.selectMenuKeyHndl.select);
@@ -195,25 +206,25 @@ Main.changeState = function (state) { Display.hide();
Display.resetVideoList();
break;
- case 1:
+ case Main.eLIVE:
document.getElementById("selectScreen").style.display="none";
Display.show();
Data.reset ();
Main.liveSelected();
break;
- case 2:
+ case Main.eREC:
document.getElementById("selectScreen").style.display="none";
Display.show();
Data.reset ();
Main.recordingsSelected();
break;
- case 3:
+ case Main.eMED:
document.getElementById("selectScreen").style.display="none";
Display.show();
Data.reset ();
Main.mediaSelected();
break;
- case 4:
+ case Main.eOPT:
// Options
// Options.init();
document.getElementById("selectScreen").style.display="none";
@@ -221,20 +232,20 @@ Main.changeState = function (state) { // document.getElementById("optionsScreen").style.display="block";
Main.optionsSelected();
break;
-
}
};
Main.recordingsSelected = function() {
Player.stopCallback = function() {
//
- var msg = "devid:" + Network.getMac() + "\n";
- msg += "title:" + Data.getCurrentItem().childs[Main.selectedVideo].title + "\n";
- msg += "start:" +Data.getCurrentItem().childs[Main.selectedVideo].payload.start + "\n";
+// var msg = "devid:" + Network.getMac() + "\n";
+// Player.curPlayTime = 15.4 * 1000;
+ var msg = "";
+ msg += "filename:" + Data.getCurrentItem().childs[Main.selectedVideo].payload.guid + "\n";
msg += "resume:"+ (Player.curPlayTime/1000) + "\n" ;
var XHRObj = new XMLHttpRequest();
- XHRObj.open("POST", Config.serverUrl + "/resume", true);
+ XHRObj.open("POST", Config.serverUrl + "/setResume.xml", true);
XHRObj.send(msg);
Display.show();
@@ -299,6 +310,7 @@ Main.optionsSelected = function() { };
Main.enableKeys = function() {
+ Main.log("Main.enableKeys");
document.getElementById("anchor").focus();
};
@@ -342,6 +354,7 @@ Main.keyDown = function() { };
};
+
Main.playItem = function (url) {
Main.log(Main.state + " playItem for " +Data.getCurrentItem().childs[Main.selectedVideo].payload.link);
var start_time = Data.getCurrentItem().childs[Main.selectedVideo].payload.start;
@@ -351,10 +364,12 @@ Main.playItem = function (url) { document.getElementById("olRecProgressBar").style.display="none";
switch (this.state) {
- case 1:
+ case Main.eLIVE:
// Live
// Check for updates
-
+ Display.hide();
+ Display.showProgress();
+
Display.setOlTitle(Data.getCurrentItem().childs[Main.selectedVideo].title + " - " +Data.getCurrentItem().childs[Main.selectedVideo].payload.prog);
Display.setStartStop (start_time, (start_time + duration));
Player.isLive = true;
@@ -371,11 +386,46 @@ Main.playItem = function (url) { Player.OnCurrentPlayTime(0);
Main.log ("Live now= " + now + " StartTime= " + Data.getCurrentItem().childs[Main.selectedVideo].payload.start + " offset= " +Player.cptOffset );
Main.log("Live Content= " + Data.getCurrentItem().childs[Main.selectedVideo].title + " dur= " + Data.getCurrentItem().childs[Main.selectedVideo].payload.dur);
+
+ Player.guid = Data.getCurrentItem().childs[Main.selectedVideo].payload.guid;
+
+ Player.setVideoURL( Data.getCurrentItem().childs[Main.selectedVideo].payload.link);
+ Player.playVideo(-1);
break;
- case 2:
- case 3:
+ case Main.eMED:
+ Display.hide();
+ Display.showProgress();
+
+ Player.setCurrentPlayTimeOffset(0);
+ Player.isLive = false;
+ Player.isRecording = false;
+ Main.log(" playItem: now= " + now + " start_time= " + start_time + " dur= " + duration + " (Start + Dur - now)= " + ((start_time + duration) -now));
+
+ document.getElementById("olRecProgressBar").display="none";
+ Display.setOlTitle(Data.getCurrentItem().childs[Main.selectedVideo].title);
+ Display.resetStartStop();
+
+ Player.setVideoURL( Data.getCurrentItem().childs[Main.selectedVideo].payload.link);
+ Player.playVideo(-1);
+
+ Player.guid = "unknown";
+
+ break;
+ case Main.eREC:
+ /*
+ * Check is isnew = false
+ * if yes, then open a popup with the choice to play or to resume
+ * The player is in any case started from somewhere else
+
+ * If resume, then play is issued from resume callback
+ */
+// Main.getResume(Data.getCurrentItem().childs[Main.selectedVideo].payload.guid);
+ Player.setVideoURL( Data.getCurrentItem().childs[Main.selectedVideo].payload.link);
+ Player.guid = Data.getCurrentItem().childs[Main.selectedVideo].payload.guid;
+
+ Server.getResume(Player.guid);
+
Player.setCurrentPlayTimeOffset(0);
-// Player.cptOffset = 0;
Player.isLive = false;
Player.isRecording = false;
Main.log(" playItem: now= " + now + " start_time= " + start_time + " dur= " + duration + " (Start + Dur - now)= " + ((start_time + duration) -now));
@@ -398,11 +448,22 @@ Main.playItem = function (url) { }
Display.setOlTitle(Data.getCurrentItem().childs[Main.selectedVideo].title);
Display.resetStartStop();
+ Main.log("IsNew= " +Data.getCurrentItem().childs[Main.selectedVideo].payload.isnew);
+
+
+/* if (Data.getCurrentItem().childs[Main.selectedVideo].payload.isnew == "false") {
+ Buttons.show();
+ }
+ else {
+ Display.hide();
+ Display.showProgress();
+
+ Player.playVideo(-1);
+ }
+*/
break;
};
- Player.setVideoURL( Data.getCurrentItem().childs[Main.selectedVideo].payload.link);
- Player.playVideo();
};
Main.selectPageUp = function() {
@@ -1081,9 +1142,9 @@ cMenuKeyHndl.prototype.handleKeyDown = function () { Display.setVideoList(Main.selectedVideo, Main.selectedVideo); // thlo
}
else{
- Display.hide();
+/* Display.hide();
Display.showProgress();
-
+*/
Main.playItem();
}
break;
diff --git a/smarttv-client/Javascript/Options.js b/smarttv-client/Javascript/Options.js index 06d9ad0..f59a58a 100755 --- a/smarttv-client/Javascript/Options.js +++ b/smarttv-client/Javascript/Options.js @@ -53,21 +53,12 @@ Options.createKeypad = function () { var sheet = $("<style>");
sheet.attr({type : 'text/css',
innerHTML : '\
- .ui-btn {width:70px; height: 48px; display:inline-block, font-size:20px;background:url("Images/keypad/kp-button.png");}\
- .ui-btn-pressed {width:70px; height: 48px; display:inline-blockfont-size:20px;background:url("Images/keypad/kp-button-inv.png");}\
+ .ui-btn {width:70px; height: 48px; display:inline-block; font-size:20px;background:url("Images/keypad/kp-button.png");}\
+ .ui-btn-pressed {width:70px; height: 48px; display:inline-block;font-size:20px;background:url("Images/keypad/kp-button-inv.png");}\
.ui-keypad {left:650px; top:135px; width: 220px; text-align:center; border-width:1px; background: #1e5799; border-style:solid;\
}'});
$('body').append(sheet);
-/* var domNode = $('<div>');
- domNode.attr({id : 'ime_keypad',
- innerHTML : '<table class="ui-keypad"> \
- <tr><td><button id="kb-btn-1" class="ui-btn">1</button></td><td><button id="kb-btn-2" class="ui-btn">2</button></td><td><button id="kb-btn-3" class="ui-btn">3</button></td></tr>\
- <tr><td><button id="kb-btn-4" class="ui-btn">4</button></td><td><button id="kb-btn-5" class="ui-btn">5</button></td><td><button id="kb-btn-6" class="ui-btn">6</button></td></tr>\
- <tr><td><button id="kb-btn-7" class="ui-btn">7</button></td><td><button id="kb-btn-8" class="ui-btn">8</button></td><td><button id="kb-btn-9" class="ui-btn">9</button></td></tr>\
- <tr><td><button id="kb-btn-dot" class="ui-btn">.</button></td><td><button id="kb-btn-0" class="ui-btn">0</button></td><td><button id="kb-btn-col" class="ui-btn">:</button></td></tr>\
- </table>'});
-*/
var domNode = $('<div>', { id: "ime_keypad", class: "ui-keypad"});
var row = $('<div>');
$("<button>", {id : "kb-btn-1", text: "1", class: "ui-btn"}).appendTo(row);
diff --git a/smarttv-client/Javascript/Player.js b/smarttv-client/Javascript/Player.js index 3a677e0..9d9c1e0 100755 --- a/smarttv-client/Javascript/Player.js +++ b/smarttv-client/Javascript/Player.js @@ -11,9 +11,11 @@ var Player = isRecording : false,
url : "",
+ guid : "unknown",
startTime : 0,
duration : 0,
-
+
+ resumePos : -1,
state : 0,
cptOffset : 0, // millis
curPlayTime : 0, // millis
@@ -146,13 +148,14 @@ Player.setVideoURL = function(url) { Main.log("URL = " + this.url);
};
+
Player.setCurrentPlayTimeOffset = function(val) {
// val in milli sec
this.cptOffset = val;
// Display.showPopup("CurrentPlayTimeOffset= " + this.cptOffset);
};
-Player.playVideo = function() {
+Player.playVideo = function(resume_pos) {
if (Config.deviceType != 0) {
Display.showPopup ("Only supported for TVs");
return;
@@ -161,7 +164,6 @@ Player.playVideo = function() { Main.log("No videos to play");
}
else {
-
Player.bufferState = 0;
Display.bufferUpdate();
@@ -180,8 +182,11 @@ Player.playVideo = function() { Player.skipDuration = Config.skipDuration; // reset
Main.log ("StartPlayback for " + this.url);
-
- this.plugin.Play( this.url );
+
+ if (resume_pos == -1)
+ this.plugin.Play( this.url );
+ else
+ this.plugin.ResumePlay(this.url, resume_pos);
Audio.plugin.SetSystemMute(false);
pluginObj.setOffScreenSaver();
this.pluginBD.DisplayVFD_Show(0100); // Play
diff --git a/smarttv-client/Javascript/Server.js b/smarttv-client/Javascript/Server.js index 2bd800f..e53e0d9 100755 --- a/smarttv-client/Javascript/Server.js +++ b/smarttv-client/Javascript/Server.js @@ -116,6 +116,7 @@ Server.createVideoList = function() { var guid = "";
var fps = -1;
var ispes = "unknown";
+ var isnew = "unknown";
try {
// startstrVal = items[index].getElementsByTagName("startstr")[0].firstChild.data;
startVal = parseInt(items[index].getElementsByTagName("start")[0].firstChild.data);
@@ -130,6 +131,11 @@ Server.createVideoList = function() { }
catch (e) {}
try {
+ isnew = items[index].getElementsByTagName("isnew")[0].firstChild.data;
+ }
+ catch (e) {}
+
+ try {
fps = parseInt(items[index].getElementsByTagName("fps")[0].firstChild.data);
}
catch (e) {}
@@ -145,6 +151,7 @@ Server.createVideoList = function() { start: startVal,
dur: durVal,
ispes : ispes,
+ isnew : isnew,
fps : fps});
}
@@ -159,3 +166,60 @@ Server.createVideoList = function() { }
}
};
+
+
+
+Server.getResume = function (guid) {
+ Main.log ("***** getResume *****");
+ $.ajax({
+ url: Config.serverUrl + "/getResume.xml",
+ type : "POST",
+ data : "filename:" + guid +"\n",
+ success : function(data, status, XHR ) {
+ Main.log("**** Resome Success Response - status= " + status + " mime= " + XHR.responseType + " data= "+ data);
+ var xmlResponse = XHR.responseXML;
+ if (xmlResponse == null) {
+ Main.logToServer("Resume: xmlResponse is null");
+ Display.hide();
+ Display.showProgress();
+ Player.playVideo();
+ }
+ var xmlElement = xmlResponse.documentElement;
+ if (!xmlElement) {
+ Main.logToServer("Resume: Dont get xml");
+ Display.hide();
+ Display.showProgress();
+ Player.playVideo();
+
+ }
+ var xml_str = (new XMLSerializer()).serializeToString(xmlElement);
+ Main.logToServer(" XML Response= " + xml_str + " NodeType= " + xmlElement.nodeType);
+ Main.logToServer("xmlElement.firstChild.nodeType= " + xmlElement.firstChild.nodeType);
+ Main.logToServer("xmlElement.firstChild.nodeName= " + xmlElement.firstChild.nodeName);
+ Main.logToServer("xmlElement.firstChild.nodeValue= " + xmlElement.firstChild.nodeValue);
+ var resume_val = -1.0;
+ try {
+ resume_val = parseFloat(xmlElement.firstChild.nodeValue);
+ Main.log("resume val= " + resume_val );
+ Main.logToServer("resume val= " + resume_val );
+ Player.resumePos = resume_val;
+ Buttons.show();
+// Player.playVideo( resume_val);
+ }
+ catch (e) {
+ Main.log("Resume Parsing Error: " +e);
+ Display.hide();
+ Display.showProgress();
+ Player.playVideo();
+ }
+
+ },
+ error : function (jqXHR, status, error) {
+ Main.log("**** Resome Error Response - status= " + status + " error= "+ error);
+ Display.hide();
+ Display.showProgress();
+ Player.playVideo();
+ }
+ });
+};
+
diff --git a/smarttv-client/config.xml b/smarttv-client/config.xml index 2c55be8..c239fd8 100755 --- a/smarttv-client/config.xml +++ b/smarttv-client/config.xml @@ -9,7 +9,7 @@ <BigThumbIcon>Images/icon/SmartTvWeb_115.png</BigThumbIcon>
<ListIcon>Images/icon/SmartTvWeb_85.png</ListIcon>
<BigListIcon>Images/icon/SmartTvWeb_95.png</BigListIcon>
- <ver>0.85</ver>
+ <ver>0.86</ver>
<mgrver></mgrver>
<fullwidget>y</fullwidget>
<movie>y</movie>
diff --git a/smarttv-client/index.html b/smarttv-client/index.html index fcd7f0e..1241049 100755 --- a/smarttv-client/index.html +++ b/smarttv-client/index.html @@ -4,7 +4,9 @@ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Vdr on SmartTV</title>
- <script type="text/javascript" src="$MANAGER_WIDGET/Common/OpenSrc/jquery-1.4.2.min.js"></script>
+ <script type="text/javascript" src="$MANAGER_WIDGET/Common/OpenSrc/jquery-1.4.2.min.js"></script>
+<!-- <script type="text/javascript" src="$MANAGER_WIDGET/Common/OpenSrc/jquery-1.4.2.min.js"></script> -->
+<!-- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> -->
<!-- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> -->
<!-- Common widget API -->
@@ -28,6 +30,7 @@ <script language="javascript" type="text/javascript" src="Javascript/Options.js"></script>
<script language="javascript" type="text/javascript" src="Javascript/Epg.js"></script>
<script language="javascript" type="text/javascript" src="Javascript/Spinner.js"></script>
+ <script language="javascript" type="text/javascript" src="Javascript/Buttons.js"></script>
<!-- Style sheets -->
<link rel="stylesheet" href="CSS/Main.css" type="text/css">
@@ -130,6 +133,8 @@ <div id="Spinning">
<img ></img>
</div>
-
+ <div id="pr-popup">
+ <a href='javascript:void(0);' id='pr-popup-anchor' onkeydown='Buttons.onInput();'></a>
+ </div>
</body>
</html>
|