summaryrefslogtreecommitdiff
path: root/smarttv-client
diff options
context:
space:
mode:
authorthlo <smarttv640@gmail.com>2012-12-27 22:24:51 +0100
committerthlo <t.lohmar@gmx.de>2012-12-27 22:24:51 +0100
commit482d1be52352adbedb7a596137c5fe8c55491de8 (patch)
tree6251cc36e54ce5e8da71d885f85bc53edbc72bb4 /smarttv-client
parentcbf4463e82091172e0120375aec89c84553492b6 (diff)
downloadvdr-plugin-smarttvweb-482d1be52352adbedb7a596137c5fe8c55491de8.tar.gz
vdr-plugin-smarttvweb-482d1be52352adbedb7a596137c5fe8c55491de8.tar.bz2
Increase robustness (main part of code runs in chrome now). Bug fixes.
Diffstat (limited to 'smarttv-client')
-rwxr-xr-xsmarttv-client/Javascript/Audio.js25
-rwxr-xr-xsmarttv-client/Javascript/Config.js123
-rwxr-xr-xsmarttv-client/Javascript/Data.js14
-rwxr-xr-xsmarttv-client/Javascript/Display.js224
-rwxr-xr-xsmarttv-client/Javascript/Main.js270
-rwxr-xr-xsmarttv-client/Javascript/Network.js21
-rwxr-xr-xsmarttv-client/Javascript/Options.js12
-rwxr-xr-xsmarttv-client/Javascript/Player.js85
-rwxr-xr-xsmarttv-client/Javascript/Server.js28
9 files changed, 449 insertions, 353 deletions
diff --git a/smarttv-client/Javascript/Audio.js b/smarttv-client/Javascript/Audio.js
index 6046c37..f5c548e 100755
--- a/smarttv-client/Javascript/Audio.js
+++ b/smarttv-client/Javascript/Audio.js
@@ -9,23 +9,30 @@ Audio.init = function()
this.plugin = document.getElementById("pluginAudio");
- if (!this.plugin)
- {
+ if (!this.plugin) {
success = false;
}
return success;
};
-Audio.setRelativeVolume = function(delta)
-{
- this.plugin.SetVolumeWithKey(delta);
+Audio.setRelativeVolume = function(delta) {
+ if (Config.deviceType == 0)
+ this.plugin.SetVolumeWithKey(delta);
+ else
+ Main.log("Un-supported Audio Device");
Display.setVolume( this.getVolume() );
};
-Audio.getVolume = function()
-{
- alert("Volume : " + this.plugin.GetVolume());
- return this.plugin.GetVolume();
+Audio.getVolume = function() {
+ var res = 0;
+ if (Config.deviceType == 0) {
+ res = this.plugin.GetVolume();
+ }
+ else {
+ Main.log("Un-supported Audio Device");
+ }
+
+ return res;
};
diff --git a/smarttv-client/Javascript/Config.js b/smarttv-client/Javascript/Config.js
index ad0196f..9e111d9 100755
--- a/smarttv-client/Javascript/Config.js
+++ b/smarttv-client/Javascript/Config.js
@@ -1,8 +1,8 @@
var Config = {
- cfgFileName : curWidget.id + "/config.dta",
+ cfgFileName : "",
XHRObj : null,
xmlDocument : null,
- serverUrl : "", // Will become the main URL for contacting the server
+ serverUrl : "http://192.168.1.122:8000", // Will become the main URL for contacting the server. Form "http://<server>:port"
serverAddr : "",
serverAddrDefault: "192.168.1.122:8000",
format :"has",
@@ -13,7 +13,11 @@ var Config = {
initialTimeOut: 3, // sec
skipDuration : 30, // sec
noLiveChannels : 30,
- firstLaunch : false
+ firstLaunch : false,
+
+ deviceType : 0 // Used to differentiate between browsers and platforms
+ // 0: Samsung
+
};
@@ -24,32 +28,53 @@ var Config = {
* Come back here, read the file and continue
*/
-
Config.init = function () {
- var fileSystemObj = new FileSystem();
-
- if (fileSystemObj.isValidCommonPath(curWidget.id) == 0){
-// Display.showPopup ("First Launch of the Widget --> Launching Config Menu");
- alert("First Launch of the Widget");
- // should switch to the config screen here
- var res = fileSystemObj.createCommonDir(curWidget.id);
- if (res == true) {
- Config.firstLaunch = true;
- Main.init();
- Main.changeState(4);
+/* Main.logToServer ("navigator.appCodeName= " + navigator.appCodeName);
+ Main.logToServer ("navigator.appName= " + navigator.appName);
+ Main.logToServer ("navigator.platform= " + navigator.platform);
+
+ Main.logToServer ("modelName= " + deviceapis.tv.info.getModel());
+ Main.logToServer ("productType= " + deviceapis.tv.info.getProduct());
+*/
+
+ if (this.deviceType == 0) {
+ // This is a Samsung Smart TV
+
+ try {
+ this.cfgFileName = curWidget.id + "/config.dta";
+ }
+ catch (e) {
+ Main.log("curWidget.id does not exists. Is that a Samsung?");
+ return;
+ };
+
+ var fileSystemObj = new FileSystem();
+
+ if (fileSystemObj.isValidCommonPath(curWidget.id) == 0){
+// Display.showPopup ("First Launch of the Widget --> Launching Config Menu");
+ Main.log("First Launch of the Widget");
+ // should switch to the config screen here
+ var res = fileSystemObj.createCommonDir(curWidget.id);
+ if (res == true) {
+ Config.firstLaunch = true;
+
+ Main.init(); // Obsolete?
+
+ Main.changeState(4);
+ return;
+ }
+ else {
+ Main.init();
+ Display.showPopup ("ERROR: Cannot create widget folder");
+ Main.logToServer("ERROR: Cannot create widget folder curWidget.id= " +curWidget.id);
+ }
return;
}
else {
- Main.init();
- Display.showPopup ("ERROR: Cannot create widget folder");
- Main.log("ERROR: Cannot create widget folder curWidget.id= " +curWidget.id);
- }
- return;
- }
- else {
- Config.readContext();
+ Config.readContext();
+ }
}
Config.fetchConfig();
@@ -118,16 +143,16 @@ Config.readContext = function () {
}
catch (e) {
- Main.log("Config.readContext: Error while reading: e= " +e);
+ Main.logToServer("Config.readContext: Error while reading: e= " +e);
var res = fileSystemObj.createCommonDir(curWidget.id);
if (res == true) {
- Main.log("Config.readContext: Widget Folder created");
+ Main.logToServer("Config.readContext: Widget Folder created");
Display.showPopup ("Config Read Error: Try widget restart");
}
else {
- Main.log("Config.readContext: Widget Folder creation failed");
+ Main.logToServer("Config.readContext: Widget Folder creation failed");
Display.showPopup ("Config Read Error: Try re-installing the widget");
- alert("-------------- Error: res = false ------------------------");
+ Main.log("-------------- Error: res = false ------------------------");
}
Config.firstLaunch = true;
@@ -144,8 +169,8 @@ Config.getXmlValue = function (itm) {
res = val[0].firstChild.data;
}
catch (e) {
- Main.log("parsing widget.conf: Item= " + itm + " not found" + e);
- alert ("parsing widget.conf: Item= " + itm + " not found e= " + e);
+ Main.logToServer("parsing widget.conf: Item= " + itm + " not found" + e);
+ Main.log ("parsing widget.conf: Item= " + itm + " not found e= " + e);
}
return res;
@@ -159,8 +184,8 @@ Config.getXmlString = function (itm) {
res = val[0].firstChild.data;
}
catch (e) {
- Main.log("parsing widget.conf: Item= " + itm + " not found" + e);
- alert ("parsing widget.conf: Item= " + itm + " not found e= " + e);
+ Main.logToServer("parsing widget.conf: Item= " + itm + " not found" + e);
+ Main.log ("parsing widget.conf: Item= " + itm + " not found e= " + e);
};
return res;
@@ -168,28 +193,28 @@ Config.getXmlString = function (itm) {
Config.processConfig = function () {
if (this.XHRObj.status != 200) {
- alert ("Config Server Error");
+ Main.log ("Config Server Error");
Display.showPopup("Config Server Error " + this.XHRObj.status);
- Main.log("Config Server Error " + this.XHRObj.status);
+ Main.logToServer("Config Server Error " + this.XHRObj.status);
}
else {
var xmlResponse = this.XHRObj.responseXML;
if (xmlResponse == null) {
- alert ("xml error");
+ Main.log ("xml error");
Display.showPopup("Error in XML Config File");
- Main.log("Error in XML Config File");
+ Main.logToServer("Error in XML Config File");
return;
}
this.xmlDocument = xmlResponse.documentElement;
if (!this.xmlDocument ) {
- alert("Failed to get valid Config XML");
+ Main.log("Failed to get valid Config XML");
Display.showPopup("Failed to get valid Config XML");
- Main.log("Failed to get valid Config XML");
+ Main.logToServer("Failed to get valid Config XML");
return;
}
else {
- alert ("Paring config XML now");
- Main.log("Paring config XML now");
+ Main.log ("Parsing config XML now");
+ Main.logToServer("Parsing config XML now");
this.format = Config.getXmlString("format");
var res = Config.getXmlValue("tgtBufferBitrate");
if (res != 0)
@@ -212,16 +237,16 @@ Config.processConfig = function () {
res = Config.getXmlValue("liveChannels");
if (res != 0) noLiveChannels = res;
- alert("**** Config ****");
- alert("serverUrl= " + Config.serverUrl);
- alert("format= " + Config.format);
- alert("tgtBufferBitrate= " + Config.tgtBufferBitrate);
- alert("totalBufferDuration= " + Config.totalBufferDuration);
- alert("initialBuffer= " + Config.initialBuffer);
- alert("pendingBuffer= " + Config.pendingBuffer);
- alert("skipDuration= " + Config.skipDuration);
- alert("initialTimeOut= " + Config.initialTimeOut);
- alert("**** /Config ****");
+ Main.log("**** Config ****");
+ Main.log("serverUrl= " + Config.serverUrl);
+ Main.log("format= " + Config.format);
+ Main.log("tgtBufferBitrate= " + Config.tgtBufferBitrate);
+ Main.log("totalBufferDuration= " + Config.totalBufferDuration);
+ Main.log("initialBuffer= " + Config.initialBuffer);
+ Main.log("pendingBuffer= " + Config.pendingBuffer);
+ Main.log("skipDuration= " + Config.skipDuration);
+ Main.log("initialTimeOut= " + Config.initialTimeOut);
+ Main.log("**** /Config ****");
};
};
diff --git a/smarttv-client/Javascript/Data.js b/smarttv-client/Javascript/Data.js
index a2de13f..e7049ee 100755
--- a/smarttv-client/Javascript/Data.js
+++ b/smarttv-client/Javascript/Data.js
@@ -18,7 +18,7 @@ Data.completed= function(sort) {
this.assets.sortPayload();
this.folderList.push({item : this.assets, id: 0});
- alert ("Data.completed()= " +this.folderList.length);
+ Main.log ("Data.completed()= " +this.folderList.length);
};
@@ -43,9 +43,9 @@ Data.addItem = function(t_list, pyld) {
};
Data.dumpFolderStruct = function(){
- alert("---------- dumpFolderStruct ------------");
+ Main.log("---------- dumpFolderStruct ------------");
this.assets.print(0);
- alert("---------- dumpFolderStruct Done -------");
+ Main.log("---------- dumpFolderStruct Done -------");
};
Data.getCurrentItem = function () {
@@ -76,7 +76,7 @@ Item.prototype.getTitle = function () {
Item.prototype.getPayload = function () {
if (this.isFolder == true) {
- alert("WARNING: getting payload on a folder title=" +this.title);
+ Main.log("WARNING: getting payload on a folder title=" +this.title);
}
return this.payload;
};
@@ -102,7 +102,7 @@ Item.prototype.addChild = function (key, pyld, level) {
}
else {
if (level > 10) {
- alert(" too many levels");
+ Main.log(" too many levels");
return;
}
var t = key.shift();
@@ -129,9 +129,9 @@ Item.prototype.print = function(level) {
prefix += " ";
for (var i = 0; i < this.childs.length; i++) {
- alert(prefix + this.childs[i].title);
+ Main.log(prefix + this.childs[i].title);
if (this.childs[i].isFolder == true) {
- alert(prefix+"Childs:");
+ Main.log(prefix+"Childs:");
this.childs[i].print(level +1);
}
}
diff --git a/smarttv-client/Javascript/Display.js b/smarttv-client/Javascript/Display.js
index fa90887..5c68b53 100755
--- a/smarttv-client/Javascript/Display.js
+++ b/smarttv-client/Javascript/Display.js
@@ -25,14 +25,16 @@ var Display =
Display.init = function()
{
var success = true;
-
+
+ // Samsung specific object
+ this.pluginTime = document.getElementById("pluginTime");
+
this.statusDiv = document.getElementById("status");
this.statusPopup = document.getElementById("statusPopup");
- this.pluginTime = document.getElementById("pluginTime");
this.bufferingElm = document.getElementById("bufferingBar");
- alert("Display.init now=" + this.pluginTime.GetEpochTime());
+// Main.log("Display.init now=" + this.pluginTime.GetEpochTime());
this.progOlHandler = new OverlayHandler("ProgHndl");
this.volOlHandler = new OverlayHandler("VolHndl");
@@ -41,7 +43,6 @@ Display.init = function()
this.volOlHandler.init(Display.handlerShowVolume, Display.handlerHideVolume);
this.popupOlHandler.init(Display.handlerShowPopup, Display.handlerHidePopup);
- Display.status("Stop");
if (!this.statusDiv)
{
success = false;
@@ -60,7 +61,7 @@ Display.init = function()
var elm = document.getElementById("selectItem"+i);
if (elm == null) {
done = true;
- alert( " only found to selectItem"+ (i-1));
+ Main.log( " only found to selectItem"+ (i-1));
break;
}
elm.style.paddingBottom = "3px";
@@ -69,10 +70,40 @@ Display.init = function()
elm.style.textAlign = "center";
}
- alert("Display initialized" );
+ Main.log("Display initialized" );
return success;
};
+Display.putInnerHTML = function (elm, val) {
+
+ switch (Config.deviceType) {
+ case 0:
+ // Samsung specific handling of innerHtml
+ widgetAPI.putInnerHTML(elm, val);
+ break;
+ default:
+ elm.innerHTML = val;
+ break;
+ }
+
+};
+
+Display.GetEpochTime = function() {
+ var res = 0;
+ switch (Config.deviceType) {
+ case 0:
+ // Samsung specific UTC time function
+ res = Display.pluginTime.GetEpochTime();
+ break;
+ default:
+ var now_millis = ((new Date).getTime());
+ res = (now_millis /1000.0);
+ break;
+ }
+
+ return res;
+};
+
Display.resetSelectItems = function (itm) {
var done = false;
var i = 0;
@@ -81,7 +112,7 @@ Display.resetSelectItems = function (itm) {
var elm = document.getElementById("selectItem"+i);
if (elm == null) {
done = true;
- alert( " only found to selectItem"+ (i-1));
+ Main.log( " only found to selectItem"+ (i-1));
break;
}
Display.unselectItem(elm);
@@ -100,7 +131,7 @@ Display.resetVideoList = function () {
break;
}
Display.unselectItem(elm);
- widgetAPI.putInnerHTML(elm, "");
+ Display.putInnerHTML(elm, "");
}
};
@@ -108,7 +139,7 @@ Display.resetVideoList = function () {
Display.setOlTitle = function (title) {
this.olTitle = title;
var elm = document.getElementById("olTitle");
- widgetAPI.putInnerHTML(elm, Display.olTitle);
+ Display.putInnerHTML(elm, Display.olTitle);
};
Display.setStartStop = function(start, stop) {
@@ -129,73 +160,10 @@ Display.setStartStop = function(start, stop) {
this.olStartStop = this.olStartStop + hours + ":" + minutes;
var elm = document.getElementById("olStartStop");
- widgetAPI.putInnerHTML(elm, Display.olStartStop);
+ Display.putInnerHTML(elm, Display.olStartStop);
};
/*
-//obsolete?
-Display.setTotalTime = function(total) {
- this.totalTime = total;
-};
-*/
-/*
-
-// Player.OnCurrentPlayTime
-Display.setTime = function(time) {
- var timePercent = (100 * time) / this.totalTime;
- var timeHTML = "";
- var timeHour = 0; var timeMinute = 0; var timeSecond = 0;
- var totalTimeHour = 0; var totalTimeMinute = 0;
- var totalTimesecond = 0;
-
- if(Player.state == Player.PLAYING)
- {
- totalTimeHour = Math.floor(this.totalTime/3600000);
- timeHour = Math.floor(time/3600000);
-
- totalTimeMinute = Math.floor((this.totalTime%3600000)/60000);
- timeMinute = Math.floor((time%3600000)/60000);
-
- totalTimeSecond = Math.floor((this.totalTime%60000)/1000);
- timeSecond = Math.floor((time%60000)/1000);
-
- timeHTML = timeHour + ":";
-
- if(timeMinute == 0)
- timeHTML += "00:";
- else if(timeMinute <10)
- timeHTML += "0" + timeMinute + ":";
- else
- timeHTML += timeMinute + ":";
-
- if(timeSecond == 0)
- timeHTML += "00/";
- else if(timeSecond <10)
- timeHTML += "0" + timeSecond + "/";
- else
- timeHTML += timeSecond + "/";
-
- timeHTML += totalTimeHour + ":";
-
- if(totalTimeMinute == 0)
- timeHTML += "00:";
- else if(totalTimeMinute <10)
- timeHTML += "0" + totalTimeMinute;
- else
- timeHTML += totalTimeMinute;
-
- if(totalTimeSecond == 0)
- timeHTML += "00";
- else if(totalTimeSecond <10)
- timeHTML += "0" + totalTimeSecond;
- else
- timeHTML += totalTimeSecond;
- }
- else
- timeHTML = "0:00:00/0:00:00";
-};
-*/
-
Display.getHumanTimeRepresentation = function(time) {
var totalTimeHour = 0;
var totalTimeMinute = 0;
@@ -223,7 +191,7 @@ Display.getHumanTimeRepresentation = function(time) {
return totalTimeStr;
};
-
+*/
/*
// called by Player.OnStreamInfoReady
Display.updateTotalTime = function(time) {
@@ -235,7 +203,7 @@ Display.updateTotalTime = function(time) {
Display.updatePlayTime = function() {
// Player.curPlayTimeStr = Display.getHumanTimeRepresentation(Player.curPlayTime);
var timeElement = document.getElementById("olTimeInfo");
- widgetAPI.putInnerHTML(timeElement, Player.curPlayTimeStr + " / " + Player.totalTimeStr);
+ Display.putInnerHTML(timeElement, Player.curPlayTimeStr + " / " + Player.totalTimeStr);
};
Display.updateProgressBar = function () {
@@ -244,10 +212,10 @@ Display.updateProgressBar = function () {
};
Display.updateRecBar = function (start_time, duration){
- var now = Display.pluginTime.GetEpochTime();
+ var now = Display.GetEpochTime();
var remaining = Math.round(((start_time + duration) - now) * 100/ duration);
-// alert (" remaining= " + remaining + " start= " + start_time + " dur= " + duration);
+// Main.log (" remaining= " + remaining + " start= " + start_time + " dur= " + duration);
var elm = document.getElementById("olRecProgressBar");
elm.style.display="block";
elm.style.width = remaining + "%";
@@ -256,9 +224,9 @@ Display.updateRecBar = function (start_time, duration){
Display.status = function(status) {
- alert(status);
- widgetAPI.putInnerHTML(this.statusDiv, status);
- widgetAPI.putInnerHTML(this.statusPopup, status);
+ Main.log(status);
+ Display.putInnerHTML(this.statusDiv, status);
+ Display.putInnerHTML(this.statusPopup, status);
};
Display.showStatus = function() {
@@ -271,7 +239,7 @@ Display.hideStatus = function() {
Display.progress = function(status) {
- widgetAPI.putInnerHTML(this.statusDiv, status);
+ Display.putInnerHTML(this.statusDiv, status);
};
@@ -308,6 +276,7 @@ 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 );
@@ -326,11 +295,11 @@ Display.handleDescription =function (selected) {
var min = Display.getNumString (digi.getMinutes(), 2);
var d_str ="";
-// alert("handleDescription: " +Data.getCurrentItem().childs[selected].payload.desc);
+// Main.log("handleDescription: " +Data.getCurrentItem().childs[selected].payload.desc);
var msg = "";
if (Main.state == 1) {
// Live
- var now = pluginTime.GetEpochTime();
+ var now = Display.GetEpochTime();
d_str = hour + ":" + min;
@@ -338,7 +307,10 @@ Display.handleDescription =function (selected) {
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
@@ -399,7 +371,7 @@ Display.getDisplayTitle = function(item) {
}
break;
default:
- alert("ERROR: Shall be in state 1 or 2. State= " + Main.state);
+ Main.log("ERROR: Shall be in state 1 or 2. State= " + Main.state);
break;
}
return res;
@@ -409,25 +381,22 @@ Display.setVideoList = function(selected, first) {
//
var listHTML = "";
var first_item = selected;
- if(typeof first !='undefined') {
- first_item = first;
- alert("Display.setVideoList first_item= " + first_item);
- }
-
+
var i=0;
- alert("Display.setVideoList title= " +Data.getCurrentItem().childs[selected].title + " selected= " + selected + " first_item= " + first_item);
+ Main.log("Display.setVideoList title= " +Data.getCurrentItem().childs[selected].title + " selected= " + selected + " first_item= " + first_item);
this.handleDescription(selected);
-
+
for (i = 0; i <= this.LASTIDX; i++) {
if ((first_item+i) >= Data.getVideoCount()) {
listHTML = "";
}
else {
-// alert(" - title[first_item+i]= " +Data.getCurrentItem().childs[(first_item +i)].title + " i= " + i);
listHTML = Display.getDisplayTitle (Data.getCurrentItem().childs[first_item+i]);
+// Main.log(" - title[first_item+i]= " +Data.getCurrentItem().childs[(first_item +i)].title + " i= " + i + " listHTML= " + listHTML);
+// Main.log(" - listHTML= " + listHTML);
}
this.videoList[i] = document.getElementById("video"+i);
- widgetAPI.putInnerHTML(this.videoList[i], listHTML);
+ Display.putInnerHTML(this.videoList[i], listHTML);
this.unselectItem(this.videoList[i]);
}
@@ -436,7 +405,7 @@ Display.setVideoList = function(selected, first) {
listHTML = (selected +1) + " / " + Data.getVideoCount();
- widgetAPI.putInnerHTML(document.getElementById("videoCount"), listHTML);
+ Display.putInnerHTML(document.getElementById("videoCount"), listHTML);
};
Display.selectItem = function (item) {
@@ -463,12 +432,12 @@ Display.unselectItem = function (item) {
Display.setVideoListPosition = function(position, move)
{
var listHTML = "";
- alert ("Display.setVideoListPosition title= " +Data.getCurrentItem().childs[position].title + " move= " +move);
+ Main.log ("Display.setVideoListPosition title= " +Data.getCurrentItem().childs[position].title + " move= " +move);
this.handleDescription(position);
listHTML = (position + 1) + " / " + Data.getVideoCount();
- widgetAPI.putInnerHTML(document.getElementById("videoCount"), listHTML);
+ Display.putInnerHTML(document.getElementById("videoCount"), listHTML);
if(Data.getVideoCount() < this.LASTIDX) {
@@ -505,7 +474,7 @@ Display.setVideoListPosition = function(position, move)
for(i = 0; i <= this.LASTIDX; i++) {
listHTML = Display.getDisplayTitle (Data.getCurrentItem().childs[i]);
// listHTML = Data.getCurrentItem().childs[i].title;
- widgetAPI.putInnerHTML(this.videoList[i], listHTML);
+ Display.putInnerHTML(this.videoList[i], listHTML);
if(i == this.currentWindow)
this.selectItem(this.videoList[i]);
@@ -517,7 +486,7 @@ Display.setVideoListPosition = function(position, move)
for(i = 0; i <= this.LASTIDX; i++) {
listHTML = Display.getDisplayTitle (Data.getCurrentItem().childs[i + position - this.currentWindow]);
// listHTML = Data.getCurrentItem().childs[i + position - this.currentWindow].title;
- widgetAPI.putInnerHTML(this.videoList[i], listHTML);
+ Display.putInnerHTML(this.videoList[i], listHTML);
}
}
}
@@ -530,7 +499,7 @@ Display.setVideoListPosition = function(position, move)
for(i = 0; i <= this.LASTIDX; i++) {
listHTML = Display.getDisplayTitle (Data.getCurrentItem().childs[i + position - this.currentWindow]);
// listHTML = Data.getCurrentItem().childs[i + position - this.currentWindow].title;
- widgetAPI.putInnerHTML(this.videoList[i], listHTML);
+ Display.putInnerHTML(this.videoList[i], listHTML);
if(i == this.currentWindow)
this.selectItem(this.videoList[i]);
@@ -542,7 +511,7 @@ Display.setVideoListPosition = function(position, move)
for(i = 0; i <= this.LASTIDX; i++) {
listHTML = Display.getDisplayTitle (Data.getCurrentItem().childs[i + position]);
// listHTML = Data.getCurrentItem().childs[i + position].title;
- widgetAPI.putInnerHTML(this.videoList[i], listHTML);
+ Display.putInnerHTML(this.videoList[i], listHTML);
}
}
}
@@ -551,7 +520,7 @@ Display.setVideoListPosition = function(position, move)
Display.setDescription = function(description) {
var descriptionElement = document.getElementById("description");
- widgetAPI.putInnerHTML(descriptionElement, description);
+ Display.putInnerHTML(descriptionElement, description);
};
//--------------------------------------------------------
@@ -583,7 +552,7 @@ Display.setVolume = function(level)
var volumeElement = document.getElementById("volumeInfo");
- widgetAPI.putInnerHTML(volumeElement, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + Audio.getVolume());
+ Display.putInnerHTML(volumeElement, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + Audio.getVolume());
};
// Called by main
@@ -606,7 +575,7 @@ Display.handlerHideVolume = function() {
//---------------------------------------------------------
Display.showPopup = function(text) {
var oldHTML = document.getElementById("popup").innerHTML;
- widgetAPI.putInnerHTML(document.getElementById("popup"), oldHTML + "<br>" + text);
+ Display.putInnerHTML(document.getElementById("popup"), oldHTML + "<br>" + text);
this.popupOlHandler.show();
};
@@ -617,7 +586,7 @@ Display.handlerShowPopup = function() {
Display.handlerHidePopup = function() {
document.getElementById("popup").style.display="none";
- widgetAPI.putInnerHTML(document.getElementById("popup"), "");
+ Display.putInnerHTML(document.getElementById("popup"), "");
};
//---------------------------------------------------------
@@ -635,9 +604,9 @@ Display.handlerShowProgress = function() {
document.getElementById("overlay").style.display="block";
if (Player.isRecording == true) {
document.getElementById("olRecProgressBar").style.display="block";
- var now = pluginTime.GetEpochTime();
+ var now = Display.GetEpochTime();
var remaining = Math.round(((Player.startTime + Player.duration) - now) * 100/ Player.duration);
- alert (" remaining= " + remaining);
+ Main.log (" remaining= " + remaining);
var elm = document.getElementById("olRecProgressBar");
elm.style.display="block";
elm.style.width = remaining + "%";
@@ -648,12 +617,12 @@ Display.handlerShowProgress = function() {
var timePercent = (Player.curPlayTime *100)/ Player.totalTime;
- alert("show OL Progress timePercent= " + timePercent);
+ Main.log("show OL Progress timePercent= " + timePercent);
document.getElementById("olProgressBar").style.width = timePercent + "%";
var timeElement = document.getElementById("olTimeInfo");
- widgetAPI.putInnerHTML(timeElement, Player.curPlayTimeStr + " / " + Player.totalTimeStr);
+ Display.putInnerHTML(timeElement, Player.curPlayTimeStr + " / " + Player.totalTimeStr);
var nowElement = document.getElementById("olNow");
var Digital=new Date();
@@ -661,14 +630,14 @@ Display.handlerShowProgress = function() {
var minutes=Digital.getMinutes();
if (minutes<=9)
minutes='0'+minutes;
- widgetAPI.putInnerHTML(nowElement, hours + ':' + minutes);
+ Display.putInnerHTML(nowElement, hours + ':' + minutes);
};
//----------------------------------------
function OverlayHandler (n) {
- this.pluginTime = null;
+// this.pluginTime = null;
this.active = false;
this.startTime = 0;
this.hideTime = 0;
@@ -684,34 +653,34 @@ OverlayHandler.prototype.init = function(showcb, hidecb) {
var success = true;
this.showCallback = showcb;
this.hideCallback = hidecb;
- this.pluginTime = document.getElementById("pluginTime");
+/* this.pluginTime = document.getElementById("pluginTime");
if (!this.pluginTime) {
- alert(this.handlerName + " cannot aquire time plugin : " + success);
+ Main.log(this.handlerName + " cannot aquire time plugin : " + success);
success = false;
}
-// alert(this.handlerName + " is initialized");
+*/
+ // Main.log(this.handlerName + " is initialized");
return success;
};
OverlayHandler.prototype.checkHideCallback = function () {
- var pluginTime = document.getElementById("pluginTime");
- var now = pluginTime.GetEpochTime();
-// alert(that.handlerName + "checkHideCallback: now= " + now + " hideTime= " + that.hideTime + " delta= " + (now - that.hideTime));
+ var now = Display.GetEpochTime();
+ // Main.log(that.handlerName + "checkHideCallback: now= " + now + " hideTime= " + that.hideTime + " delta= " + (now - that.hideTime));
if (now >= this.hideTime) {
-// alert(this.handlerName + "hiding " + this.handlerName + " howDur: act= " + (now - this.startTime) + " int= " + (this.hideTime-this.startTime));
+// Main.log(this.handlerName + "hiding " + this.handlerName + " howDur: act= " + (now - this.startTime) + " int= " + (this.hideTime-this.startTime));
this.olDelay = 3000;
if (this.hideCallback) {
this.hideCallback();
}
else
- alert(this.handlerName + ": No hideCallback defined - ignoring " );
+ Main.log(this.handlerName + ": No hideCallback defined - ignoring " );
this.active = false;
return;
}
var delay = (this.hideTime - now) * 1000;
-// alert(this.handlerName + "checkHideCallback: new timeout= " +delay);
+// Main.log(this.handlerName + "checkHideCallback: new timeout= " +delay);
// pass an anonymous function
var self = this;
@@ -720,10 +689,12 @@ OverlayHandler.prototype.checkHideCallback = function () {
OverlayHandler.prototype.show = function() {
if (!this.active ) {
- this.startTime = this.pluginTime.GetEpochTime();
+// this.startTime = this.pluginTime.GetEpochTime();
+ this.startTime = Display.GetEpochTime();
+
this.hideTime = this.startTime + (this.olDelay / 1000);
-// alert(this.handlerName + " showing " + this.handlerName + " from= " + this.startTime + " to at least= " + this.hideTime);
+// Main.log(this.handlerName + " showing " + this.handlerName + " from= " + this.startTime + " to at least= " + this.hideTime);
if (this.showCallback) {
this.showCallback();
@@ -732,11 +703,12 @@ OverlayHandler.prototype.show = function() {
this.active = true;
}
else
- alert(this.handlerName + ": No showCallback defined - ignoring " );
+ Main.log(this.handlerName + ": No showCallback defined - ignoring " );
}
else {
-// alert(this.handlerName + " extending showtime for " + this.handlerName + " for another " + (this.olDelay /1000)+ "sec");
- this.hideTime = this.pluginTime.GetEpochTime() + (this.olDelay /1000);
+// 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);
}
};
@@ -745,12 +717,12 @@ OverlayHandler.prototype.cancel = function () {
if (!this.active)
return;
-// alert("cancel for handler " + this.handlerName);
+// Main.log("cancel for handler " + this.handlerName);
if (this.hideCallback) {
this.hideCallback();
}
else
- alert(this.handlerName + ": No hideCallback defined - ignoring " );
+ Main.log(this.handlerName + ": No hideCallback defined - ignoring " );
this.active = false;
window.clearTimeout(this.timeoutObj);
diff --git a/smarttv-client/Javascript/Main.js b/smarttv-client/Javascript/Main.js
index fa3c863..a122557 100755
--- a/smarttv-client/Javascript/Main.js
+++ b/smarttv-client/Javascript/Main.js
@@ -1,7 +1,13 @@
-var widgetAPI = new Common.API.Widget();
-var tvKey = new Common.API.TVKeyValue();
+var widgetAPI = null;
+var tvKey = null;
-var custom = window.deviceapis.customdevice || {};
+try {
+ widgetAPI = new Common.API.Widget();
+ tvKey = new Common.API.TVKeyValue();
+}
+catch (e) {
+}
+//var custom = window.deviceapis.customdevice || {};
/*
@@ -39,6 +45,17 @@ var Main = {
Main.onLoad = function() {
Network.init();
+ try {
+ widgetAPI.sendReadyEvent();
+ }
+ catch (e) {
+ Config.deviceType = 1;
+ tvKey = Main.tvKeys;
+
+ Main.log("Not a Samsung Smart TV" );
+// Display.showPopup("Not a Samsung Smart TV. Lets see, how far we come");
+ }
+
Display.init();
this.defKeyHndl = new cDefaulKeyHndl;
@@ -47,23 +64,22 @@ Main.onLoad = function() {
this.menuKeyHndl = new cMenuKeyHndl(this.defKeyHndl);
this.selectMenuKeyHndl = new cSelectMenuKeyHndl(this.defKeyHndl);
- alert (" created KeyHandlers");
-
+ Main.log (" created KeyHandlers");
+
Config.init();
};
// Called by Config, when done
// TODO: Send sendReadyEvent early and show a splash screen during startup
Main.init = function () {
- alert("Main.init()");
+ Main.log("Main.init()");
if ( Player.init() && Audio.init() && Server.init() ) {
Display.setVolume( Audio.getVolume() );
// Start retrieving data from server
- Server.dataReceivedCallback = function()
- {
+ Server.dataReceivedCallback = function() {
/* Use video information when it has arrived */
- alert("Server.dataReceivedCallback");
+// Main.log("Server.dataReceivedCallback");
Display.setVideoList(Main.selectedVideo);
Display.show();
@@ -76,20 +92,32 @@ Main.init = function () {
document.getElementById("splashScreen").style.display="none";
- widgetAPI.sendReadyEvent();
}
else {
- alert("Failed to initialise");
+ Main.log("Failed to initialise");
}
};
Main.log = function (msg) {
- if (Config.serverUrl == "" )
- return;
+ // alert redirect
+ if (Config.deviceType == 0) {
+ alert (msg);
+ }
+ else {
+ console.log(msg);
+ }
+
+};
+
+Main.logToServer = function (msg) {
+// if (Config.serverUrl == "" )
+// return;
var XHRObj = new XMLHttpRequest();
- XHRObj.open("POST", Config.serverUrl + "/log", true);
+// XHRObj.open("POST", Config.serverUrl + "/log", true);
+ XHRObj.open("POST", "http://192.168.1.122:8000/log", true);
+
XHRObj.send("CLOG: " + msg);
};
@@ -99,14 +127,14 @@ Main.onUnload = function()
};
Main.changeState = function (state) {
- alert("change state: new state= " + state);
+ Main.log("change state: new state= " + state);
var old_state = this.state;
this.state = state;
switch (this.state) {
case 0:
Main.selectMenuKeyHndl.select = old_state;
- alert ("old Select= " + Main.selectMenuKeyHndl.select);
+ Main.log ("old Select= " + Main.selectMenuKeyHndl.select);
Display.resetSelectItems(Main.selectMenuKeyHndl.select);
document.getElementById("selectScreen").style.display="block";
@@ -160,10 +188,10 @@ Main.recordingsSelected = function() {
Server.setSort(true);
if (Config.format == "") {
Server.fetchVideoList(Config.serverUrl + "/recordings.xml?model=samsung"); /* Request video information from server */
- alert("fetchVideoList from: " + Config.serverUrl + "/recordings.xml?model=samsung");
+ Main.log("fetchVideoList from: " + Config.serverUrl + "/recordings.xml?model=samsung");
}
else {
- Main.log("Using format " + Config.format);
+ Main.logToServer("Using format " + Config.format);
if (Config.format == "")
Server.fetchVideoList(Config.serverUrl + "/recordings.xml?model=samsung&has4hd=false"); /* Request video information from server */
else
@@ -202,11 +230,10 @@ Main.mediaSelected = function() {
};
Main.optionsSelected = function() {
- alert ("Main.optionsSelected");
+ Main.log ("Main.optionsSelected");
};
-Main.enableKeys = function()
-{
+Main.enableKeys = function() {
document.getElementById("anchor").focus();
};
@@ -218,7 +245,7 @@ Main.keyDown = function() {
break;
case 1:
// Live
- alert("Live - Main.keyDown PlayerState= " + Player.getState());
+ Main.log("Live - Main.keyDown PlayerState= " + Player.getState());
if(Player.getState() == Player.STOPPED) {
// Menu Key
this.menuKeyHndl.handleKeyDown();
@@ -232,7 +259,7 @@ Main.keyDown = function() {
case 2:
case 3:
// recordings
- alert("Recordings - Main.keyDown PlayerState= " + Player.getState());
+ Main.log("Recordings - Main.keyDown PlayerState= " + Player.getState());
if(Player.getState() == Player.STOPPED) {
// Menu Key
this.menuKeyHndl.handleKeyDown();
@@ -244,16 +271,17 @@ Main.keyDown = function() {
break;
case 4:
- alert ("ERROR: Wrong State");
+ Main.log ("ERROR: Wrong State");
break;
};
};
Main.playItem = function (url) {
- alert(Main.state + " playItem for " +Data.getCurrentItem().childs[Main.selectedVideo].payload.link);
+ Main.log(Main.state + " playItem for " +Data.getCurrentItem().childs[Main.selectedVideo].payload.link);
var start_time = Data.getCurrentItem().childs[Main.selectedVideo].payload.start;
var duration = Data.getCurrentItem().childs[Main.selectedVideo].payload.dur;
- var now = Display.pluginTime.GetEpochTime();
+ var now = Display.GetEpochTime();
+
document.getElementById("olRecProgressBar").style.display="none";
switch (this.state) {
@@ -267,12 +295,12 @@ Main.playItem = function (url) {
Player.totalTime = Data.getCurrentItem().childs[Main.selectedVideo].payload.dur * 1000;
// Display.updateTotalTime(Player.totalTime);
var digi = new Date((Data.getCurrentItem().childs[Main.selectedVideo].payload.start*1000));
- alert (" Date(): StartTime= " + digi.getHours() + ":" + digi.getMinutes() + ":" + digi.getSeconds());
+ Main.log (" Date(): StartTime= " + digi.getHours() + ":" + digi.getMinutes() + ":" + digi.getSeconds());
// Player.cptOffset = (now - Data.getCurrentItem().childs[Main.selectedVideo].payload.start) * 1000;
Player.setCurrentPlayTimeOffset((now - Data.getCurrentItem().childs[Main.selectedVideo].payload.start) * 1000);
Player.OnCurrentPlayTime(0);
- alert ("Live now= " + now + " StartTime= " + Data.getCurrentItem().childs[Main.selectedVideo].payload.start + " offset= " +Player.cptOffset );
- alert("Live Content= " + Data.getCurrentItem().childs[Main.selectedVideo].title + " dur= " + Data.getCurrentItem().childs[Main.selectedVideo].payload.dur);
+ 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);
break;
case 2:
case 3:
@@ -280,10 +308,10 @@ Main.playItem = function (url) {
// Player.cptOffset = 0;
Player.isLive = false;
Player.isRecording = false;
- alert(" playItem: now= " + now + " start_time= " + start_time + " dur= " + duration + " (Start + Dur - now)= " + ((start_time + duration) -now));
+ Main.log(" playItem: now= " + now + " start_time= " + start_time + " dur= " + duration + " (Start + Dur - now)= " + ((start_time + duration) -now));
if ((now - (start_time + duration)) < 0) {
// still recording
- alert("*** Still Recording! ***");
+ Main.log("*** Still Recording! ***");
Player.isRecording = true;
Player.startTime = start_time;
Player.duration = duration;
@@ -318,7 +346,7 @@ Main.selectPageUp = function(up) {
var first_item = this.selectedVideo - Display.currentWindow;
if (first_item < 0 )
first_item = 0;
- alert("selectPageUp: this.selectedVideo= " + this.selectedVideo + " first_item= " + first_item);
+ Main.log("selectPageUp: this.selectedVideo= " + this.selectedVideo + " first_item= " + first_item);
Display.setVideoList(this.selectedVideo, first_item);
};
@@ -331,13 +359,13 @@ Main.selectPageDown = function(down) {
}
var first_item = this.selectedVideo - Display.currentWindow;
- alert("selectPageDown: this.selectedVideo= " + this.selectedVideo + " first_item= " + first_item);
+ Main.log("selectPageDown: this.selectedVideo= " + this.selectedVideo + " first_item= " + first_item);
Display.setVideoList(this.selectedVideo, first_item);
};
Main.nextVideo = function(no) {
this.selectedVideo = (this.selectedVideo + no) % Data.getVideoCount();
- alert("nextVideo= " + this.selectedVideo);
+ Main.log("nextVideo= " + this.selectedVideo);
};
Main.previousVideo = function(no) {
@@ -346,7 +374,7 @@ Main.previousVideo = function(no) {
if (this.selectedVideo < 0) {
this.selectedVideo += Data.getVideoCount();
}
- alert("previousVideo= " + this.selectedVideo);
+ Main.log("previousVideo= " + this.selectedVideo);
};
@@ -409,7 +437,7 @@ Main.muteMode = function()
break;
default:
- alert("ERROR: unexpected mode in muteMode");
+ Main.log("ERROR: unexpected mode in muteMode");
break;
}
};
@@ -418,6 +446,12 @@ Main.muteMode = function()
Main.getKeyCode = function(code) {
var res = "";
+
+ if (Config.deviceType != 0) {
+ // Not a Samsung
+ res = "Unknown Key (" + code + ")";
+ return res;
+ }
switch(code) {
case tvKey.KEY_1:
res = "KEY_1";
@@ -646,7 +680,7 @@ Main.getKeyCode = function(code) {
function cPlayStateKeyHndl(def_hndl) {
this.defaultKeyHandler = def_hndl;
this.handlerName = "PlayStateKeyHanlder";
- alert(this.handlerName + " created");
+ Main.log(this.handlerName + " created");
};
@@ -655,70 +689,70 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function () {
var keyCode = event.keyCode;
if(Player.getState() == Player.STOPPED) {
- alert("ERROR: Wrong state - STOPPED");
+ Main.log("ERROR: Wrong state - STOPPED");
return;
}
- alert(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode));
+ Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode));
switch(keyCode)
{
case tvKey.KEY_1:
- alert("KEY_1 pressed");
+ Main.log("KEY_1 pressed");
Display.showProgress();
Player.jumpToVideo(10);
break;
case tvKey.KEY_2:
- alert("KEY_2 pressed");
+ Main.log("KEY_2 pressed");
Display.showProgress();
Player.jumpToVideo(20);
break;
case tvKey.KEY_3:
- alert("KEY_3 pressed");
+ Main.log("KEY_3 pressed");
Display.showProgress();
Player.jumpToVideo(30);
break;
case tvKey.KEY_4:
- alert("KEY_4 pressed");
+ Main.log("KEY_4 pressed");
Display.showProgress();
Player.jumpToVideo(40);
break;
case tvKey.KEY_5:
- alert("KEY_5 pressed");
+ Main.log("KEY_5 pressed");
Display.showProgress();
Player.jumpToVideo(50);
break;
case tvKey.KEY_6:
- alert("KEY_6 pressed");
+ Main.log("KEY_6 pressed");
Display.showProgress();
Player.jumpToVideo(60);
break;
case tvKey.KEY_7:
- alert("KEY_7 pressed");
+ Main.log("KEY_7 pressed");
Display.showProgress();
Player.jumpToVideo(70);
break;
case tvKey.KEY_8:
- alert("KEY_8 pressed");
+ Main.log("KEY_8 pressed");
Display.showProgress();
Player.jumpToVideo(80);
break;
case tvKey.KEY_9:
- alert("KEY_9 pressed");
+ Main.log("KEY_9 pressed");
Display.showProgress();
Player.jumpToVideo(90);
break;
case tvKey.KEY_RIGHT:
case tvKey.KEY_FF:
- alert("FF");
+ Main.log("FF");
Display.showProgress();
Player.skipForwardVideo();
break;
case tvKey.KEY_LEFT:
case tvKey.KEY_RW:
- alert("RW");
+ Main.log("RW");
Display.showProgress();
Player.skipBackwardVideo();
break;
@@ -726,7 +760,7 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function () {
case tvKey.KEY_ENTER:
case tvKey.KEY_PLAY:
case tvKey.KEY_PANEL_ENTER:
- alert("ENTER");
+ Main.log("ENTER");
if(Player.getState() == Player.PAUSED) {
Player.resumeVideo();
}
@@ -735,19 +769,19 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function () {
case tvKey.KEY_RETURN:
case tvKey.KEY_PANEL_RETURN:
case tvKey.KEY_STOP:
- alert("STOP");
+ Main.log("STOP");
// Player.setWindow();
Player.stopVideo();
break;
case tvKey.KEY_PAUSE:
- alert("PAUSE");
+ Main.log("PAUSE");
Player.pauseVideo();
break;
case tvKey.KEY_UP:
case tvKey.KEY_PANEL_VOL_UP:
case tvKey.KEY_VOL_UP:
- alert("VOL_UP");
+ Main.log("VOL_UP");
Display.showVolume();
if(Main.mute == 0)
Audio.setRelativeVolume(0);
@@ -756,19 +790,77 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function () {
case tvKey.KEY_DOWN:
case tvKey.KEY_PANEL_VOL_DOWN:
case tvKey.KEY_VOL_DOWN:
- alert("VOL_DOWN");
+ Main.log("VOL_DOWN");
Display.showVolume();
if(Main.mute == 0)
Audio.setRelativeVolume(1);
break;
default:
- alert("Calling Default Key Hanlder");
+ Main.log("Calling Default Key Hanlder");
this.defaultKeyHandler.handleDefKeyDown(keyCode);
break;
}
};
+Main.tvKeys = {
+ KEY_UP :38,
+ KEY_DOWN :40,
+ KEY_LEFT :37,
+ KEY_RIGHT :39,
+ KEY_ENTER :13,
+
+ KEY_STOP :27, // ESC
+// KEY_MUTE :27,
+
+ // Un-used keycodes
+ KEY_RETURN :88,
+ KEY_EXIT :45,
+ KEY_RED :108,
+ KEY_GREEN :20,
+ KEY_YELLOW :21,
+ KEY_BLUE :22,
+ KEY_RW :69,
+ KEY_PAUSE :74,
+ KEY_FF :72,
+ KEY_PLAY :71,
+ KEY_STOP :70,
+ KEY_1 :101,
+ KEY_2 :98,
+ KEY_3 :6,
+ KEY_4 :8,
+ KEY_5 :9,
+ KEY_6 :10,
+ KEY_7 :12,
+ KEY_8 :13,
+ KEY_9 :14,
+ KEY_0 :17,
+
+ KEY_PANEL_CH_UP :104,
+ KEY_PANEL_CH_DOWN :106,
+ KEY_PANEL_VOL_UP :203,
+ KEY_PANEL_VOL_DOWN :204,
+ KEY_PANEL_ENTER :309,
+ KEY_PANEL_SOURCE :612,
+ KEY_PANEL_MENU :613,
+ KEY_PANEL_POWER :614,
+
+ KEY_POWER :76,
+ KEY_VOL_UP :7,
+ KEY_VOL_DOWN :11,
+ KEY_CH_UP :68,
+ KEY_CH_DOWN :65,
+ KEY_MTS :655,
+ KEY_12 :1057,
+ KEY_AD :1039,
+ KEY_FF_ :1078,
+ KEY_REWIND_ :1080,
+ KEY_SLEEP :1097,
+ KEY_STEP :1023,
+ KEY_HOME :1118
+
+};
+
//---------------------------------------------------
// Live Play State Key Handler
@@ -777,7 +869,7 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function () {
function cLivePlayStateKeyHndl(def_hndl) {
this.defaultKeyHandler = def_hndl;
this.handlerName = "LivePlayStateKeyHanlder";
- alert(this.handlerName + " created");
+ Main.log(this.handlerName + " created");
};
@@ -786,16 +878,16 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function () {
var keyCode = event.keyCode;
if(Player.getState() == Player.STOPPED) {
- alert("ERROR: Wrong state - STOPPED");
+ Main.log("ERROR: Wrong state - STOPPED");
return;
}
- alert(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode));
+ Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode));
switch(keyCode) {
case tvKey.KEY_1:
case tvKey.KEY_CH_UP:
- alert("Prog Up");
+ Main.log("Prog Up");
Display.showProgress();
Player.stopVideo();
Main.previousVideo(1);
@@ -805,7 +897,7 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function () {
case tvKey.KEY_4:
case tvKey.KEY_CH_DOWN:
- alert("Prog Down");
+ Main.log("Prog Down");
Display.showProgress();
Player.stopVideo();
Main.nextVideo(1);
@@ -816,7 +908,7 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function () {
case tvKey.KEY_ENTER:
case tvKey.KEY_PLAY:
case tvKey.KEY_PANEL_ENTER:
- alert("ENTER");
+ Main.log("ENTER");
Display.hide();
Display.showProgress();
break;
@@ -824,19 +916,19 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function () {
case tvKey.KEY_RETURN:
case tvKey.KEY_PANEL_RETURN:
case tvKey.KEY_STOP:
- alert("STOP");
+ Main.log("STOP");
Player.stopVideo();
Display.setVideoList(Main.selectedVideo);
Display.show();
break;
case tvKey.KEY_PAUSE:
- alert("PAUSE");
+ Main.log("PAUSE");
break;
case tvKey.KEY_UP:
case tvKey.KEY_PANEL_VOL_UP:
case tvKey.KEY_VOL_UP:
- alert("VOL_UP");
+ Main.log("VOL_UP");
Display.showVolume();
if(Main.mute == 0)
Audio.setRelativeVolume(0);
@@ -845,7 +937,7 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function () {
case tvKey.KEY_DOWN:
case tvKey.KEY_PANEL_VOL_DOWN:
case tvKey.KEY_VOL_DOWN:
- alert("VOL_DOWN");
+ Main.log("VOL_DOWN");
Display.showVolume();
if(Main.mute == 0)
Audio.setRelativeVolume(1);
@@ -863,34 +955,34 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function () {
function cMenuKeyHndl (def_hndl) {
this.defaultKeyHandler = def_hndl;
this.handlerName = "MenuKeyHandler";
- alert(this.handlerName + " created");
+ Main.log(this.handlerName + " created");
};
cMenuKeyHndl.prototype.handleKeyDown = function () {
var keyCode = event.keyCode;
- alert(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode));
+ Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode));
switch(keyCode) {
case tvKey.KEY_RIGHT:
- alert("Right");
+ Main.log("Right");
Main.selectPageDown(Main.DOWN);
break;
case tvKey.KEY_LEFT:
- alert("Left");
+ Main.log("Left");
Main.selectPageUp(Main.UP);
break;
case tvKey.KEY_ENTER:
case tvKey.KEY_PLAY:
case tvKey.KEY_PANEL_ENTER:
- alert("ENTER");
+ Main.log("ENTER");
if (Data.getCurrentItem().childs[Main.selectedVideo].isFolder == true) {
- alert ("selectFolder= " +Main.selectedVideo);
+ Main.log ("selectFolder= " +Main.selectedVideo);
Data.selectFolder(Main.selectedVideo);
Main.selectedVideo= 0;
Display.setVideoList(Main.selectedVideo);
@@ -907,24 +999,24 @@ cMenuKeyHndl.prototype.handleKeyDown = function () {
case tvKey.KEY_RETURN:
case tvKey.KEY_PANEL_RETURN:
if (Data.isRootFolder() == true) {
- alert ("root reached");
+ Main.log ("root reached");
Main.changeState(0);
}
else {
Main.selectedVideo = Data.folderUp();
- alert("folderUp selectedVideo= " + Main.selectedVideo);
+ Main.log("folderUp selectedVideo= " + Main.selectedVideo);
Display.setVideoList(Main.selectedVideo);
}
break;
case tvKey.KEY_DOWN:
- alert("DOWN");
+ Main.log("DOWN");
Main.selectNextVideo(Main.DOWN);
break;
case tvKey.KEY_UP:
- alert("UP");
+ Main.log("UP");
Main.selectPreviousVideo(Main.UP);
break;
@@ -941,7 +1033,7 @@ cMenuKeyHndl.prototype.handleKeyDown = function () {
function cSelectMenuKeyHndl (def_hndl) {
this.defaultKeyHandler = def_hndl;
this.handlerName = "SelectMenuKeyHandler";
- alert(this.handlerName + " created");
+ Main.log(this.handlerName + " created");
this.select = 1;
this.selectMax = 4; // Highest Select Entry
@@ -949,15 +1041,15 @@ function cSelectMenuKeyHndl (def_hndl) {
cSelectMenuKeyHndl.prototype.handleKeyDown = function () {
var keyCode = event.keyCode;
- alert(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode));
+ Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode));
switch(keyCode) {
case tvKey.KEY_ENTER:
case tvKey.KEY_PLAY:
case tvKey.KEY_PANEL_ENTER:
- alert("ENTER");
- alert ("CurSelect= " + this.select);
+ Main.log("ENTER");
+ Main.log ("CurSelect= " + this.select);
Main.changeState (this.select);
@@ -966,7 +1058,7 @@ cSelectMenuKeyHndl.prototype.handleKeyDown = function () {
if (++this.select > this.selectMax)
this.select = 1;
Display.selectItem(document.getElementById("selectItem"+this.select));
- alert("DOWN " +this.select);
+ Main.log("DOWN " +this.select);
break;
case tvKey.KEY_UP:
@@ -976,7 +1068,7 @@ cSelectMenuKeyHndl.prototype.handleKeyDown = function () {
this.select = this.selectMax;
Display.selectItem(document.getElementById("selectItem"+this.select));
- alert("UP "+ this.select);
+ Main.log("UP "+ this.select);
break;
default:
this.defaultKeyHandler.handleDefKeyDown(keyCode);
@@ -991,38 +1083,38 @@ cSelectMenuKeyHndl.prototype.handleKeyDown = function () {
function cDefaulKeyHndl() {
this.handlerName = "DefaultKeyHanlder";
- alert(this.handlerName + " created");
+ Main.log(this.handlerName + " created");
};
cDefaulKeyHndl.prototype.handleDefKeyDown = function (keyCode) {
- alert("cDefaulKeyHndl::handleKeyDown: " + Main.getKeyCode(keyCode));
+ Main.log("cDefaulKeyHndl::handleKeyDown: " + Main.getKeyCode(keyCode));
switch(keyCode) {
case tvKey.KEY_EXIT:
- alert(this.handlerName +"Exit");
+ Main.log(this.handlerName +"Exit");
Player.stopVideo();
widgetAPI.sendReturnEvent();
break;
case tvKey.KEY_VOL_UP:
- alert(this.handlerName + "VOL_UP");
+ Main.log(this.handlerName + "VOL_UP");
Display.showVolume();
if(Main.mute == 0)
Audio.setRelativeVolume(0);
break;
case tvKey.KEY_VOL_DOWN:
- alert(this.handlerName + "VOL_DOWN");
+ Main.log(this.handlerName + "VOL_DOWN");
Display.showVolume();
if(Main.mute == 0)
Audio.setRelativeVolume(1);
break;
case tvKey.KEY_MUTE:
- alert(this.handlerName + "MUTE");
+ Main.log(this.handlerName + "MUTE");
Main.muteMode();
break;
default:
- alert(this.handlerName + "Unhandled key");
+ Main.log(this.handlerName + "Unhandled key");
break;
}
};
diff --git a/smarttv-client/Javascript/Network.js b/smarttv-client/Javascript/Network.js
index 1dfcafc..b4c0772 100755
--- a/smarttv-client/Javascript/Network.js
+++ b/smarttv-client/Javascript/Network.js
@@ -1,18 +1,25 @@
var Network = {
plugin : null,
ownMac : "",
- ownGw : ""
+ ownGw : "",
+ isInited: false
};
Network.init = function () {
this.plugin = document.getElementById("pluginNetwork");
- var nw_type = this.plugin.GetActiveType();
- if ((nw_type == 0) || (nw_type == 1)) {
- this.ownMac = this.plugin.GetMAC(nw_type);
- this.ownGw = this.plugin.GetGateway(nw_type);
+ try {
+ var nw_type = this.plugin.GetActiveType();
+ if ((nw_type == 0) || (nw_type == 1)) {
+ this.ownMac = this.plugin.GetMAC(nw_type);
+ this.ownGw = this.plugin.GetGateway(nw_type);
+ }
+ Main.log( "ownMac= " + this.ownMac);
+ Main.log ("ownGw= " + this.ownGw);
+ this.isInited = true;
+ }
+ catch (e) {
+ // Code for Non Samsung SmartTV here
}
- alert( "ownMac= " + this.ownMac);
- alert ("ownGw= " + this.ownGw);
} ;
diff --git a/smarttv-client/Javascript/Options.js b/smarttv-client/Javascript/Options.js
index 11095c6..31e9d50 100755
--- a/smarttv-client/Javascript/Options.js
+++ b/smarttv-client/Javascript/Options.js
@@ -10,11 +10,11 @@ Options.init = function() {
};
Options.onComplete = function () {
- alert("Completed");
+ Main.log("Completed");
};
Options.onEnter = function () {
- alert("Enter: " + document.getElementById("widgetServerAddr").value );
+ Main.log("Enter: " + document.getElementById("widgetServerAddr").value );
Config.updateContext(document.getElementById("widgetServerAddr").value);
@@ -38,7 +38,7 @@ Options.onBlue = function () {
Options.onImeCreated = function(obj) {
// _g_ime.keySet ("12key");
// obj.setKeySetFunc('12key');
- Main.log ("Options.onImeCreated()");
+ Main.logToServer ("Options.onImeCreated()");
obj.setKeyFunc(tvKey.KEY_RETURN, function(keyCode) { widgetAPI.sendReturnEvent(); return false; } );
obj.setKeyFunc(tvKey.KEY_EXIT, function(keyCode) { widgetAPI.sendExitEvent(); return false; } );
@@ -51,7 +51,7 @@ Options.onImeCreated = function(obj) {
obj.setEnterFunc(Options.onEnter);
if (obj.setMode("_num") == false) {
- Main.log("obj.setMode(\"_num\") returns false");
+ Main.logToServer("obj.setMode(\"_num\") returns false");
}
Options.imeBox.setOnCompleteFunc(Options.onComplete);
@@ -61,8 +61,8 @@ Options.onImeCreated = function(obj) {
Options.onReady = function () {
document.getElementById('widgetServerAddr').focus();
- Main.log ("Options.onReady()");
- alert ("KeySet= " + this.imeBox.getKeySet());
+ Main.logToServer ("Options.onReady()");
+ Main.log ("KeySet= " + this.imeBox.getKeySet());
};
diff --git a/smarttv-client/Javascript/Player.js b/smarttv-client/Javascript/Player.js
index a04c26f..716f36c 100755
--- a/smarttv-client/Javascript/Player.js
+++ b/smarttv-client/Javascript/Player.js
@@ -1,3 +1,7 @@
+/*
+ * This module only works with the Samsung Media Players. For other player objects, the code need to be adjusted
+ */
+
var Player =
{
plugin : null,
@@ -29,19 +33,19 @@ var Player =
Player.init = function() {
var success = true;
- alert("success vale : " + success);
+ Main.log("success vale : " + success);
this.state = this.STOPPED;
this.plugin = document.getElementById("pluginPlayer");
if (!this.plugin)
{
- alert("success vale this.plugin : " + success);
+ Main.log("success vale this.plugin : " + success);
success = false;
}
- var vermsg = this.plugin.GetPlayerVersion();
- alert ("player plugin version: " +vermsg);
+// var vermsg = this.plugin.GetPlayerVersion();
+// Main.log ("player plugin version: " +vermsg);
this.plugin.OnCurrentPlayTime = 'Player.OnCurrentPlayTime';
this.plugin.OnStreamInfoReady = 'Player.OnStreamInfoReady';
@@ -53,13 +57,13 @@ Player.init = function() {
this.plugin.OnNetworkDisconnected = 'Player.OnNetworkDisconnected'; // when the ethernet is disconnected or the streaming server stops supporting the content in the middle of streaming.
this.plugin.OnRenderingComplete = 'Player.OnRenderingComplete';
- alert("success= " + success);
+ Main.log("success= " + success);
return success;
};
Player.deinit = function()
{
- alert("Player deinit !!! " );
+ Main.log("Player deinit !!! " );
if (this.plugin)
{
@@ -77,47 +81,42 @@ Player.setFullscreen = function() {
Player.setBuffer = function (btr){
var res = true;
-// var m_bitrate = Config.tgtBufferBitrate;
-// var buffer_sec = Config.totalBufferDuration;
-// var init_buffer_perc = Config.initialBuffer;
-// var pend_buffer_perc = Config.pendingBuffer;
-
var buffer_byte = (Config.totalBufferDuration * Config.tgtBufferBitrate) / 8.0;
- Main.log("Seting TotalBufferSize to " + Math.round(buffer_byte) +"Byte dur= " +Config.totalBufferDuration + "sec init_buffer_perc= " +Config.initialBuffer +"% pend_buffer_perc= " +Config.pendingBuffer + "% initialTimeOut= " +Config.initialTimeOut + "sec");
+ Main.logToServer("Seting TotalBufferSize to " + Math.round(buffer_byte) +"Byte dur= " +Config.totalBufferDuration + "sec init_buffer_perc= " +Config.initialBuffer +"% pend_buffer_perc= " +Config.pendingBuffer + "% initialTimeOut= " +Config.initialTimeOut + "sec");
//The SetTotalBufferSize function sets the streaming buffer size of media player.
res = this.plugin.SetTotalBufferSize(Math.round(buffer_byte));
if (res == false) {
Display.showPopup("SetTotalBufferSize(" + Math.round(buffer_byte) +") returns error");
- Main.log("SetTotalBufferSize(" + Math.round(buffer_byte) +") returns error");
+ Main.logToServer("SetTotalBufferSize(" + Math.round(buffer_byte) +") returns error");
}
// The SetInitialBuffer function sets the first buffering size as percentage of buffer size before starting playback.
res = this.plugin.SetInitialBuffer(Math.round( buffer_byte * Config.initialBuffer/ 100.0));
if (res == false) {
Display.showPopup("SetInitialBuffer(" + Math.round(buffer_byte * Config.initialBuffer/ 100.0) +") returns error");
- Main.log("SetInitialBuffer(" + Math.round(buffer_byte * Config.initialBuffer/ 100.0) +") returns error");
+ Main.logToServer("SetInitialBuffer(" + Math.round(buffer_byte * Config.initialBuffer/ 100.0) +") returns error");
}
//he SetInitialTimeOut function sets the maximum time out value for initial buffering before starting playback.
res = this.plugin.SetInitialTimeOut(Config.initialTimeOut);
if (res == false) {
Display.showPopup("SetInitialTimeOut(" + 2 +") returns error");
- Main.log("SetInitialTimeOut(" + 2 +") returns error");
+ Main.logToServer("SetInitialTimeOut(" + 2 +") returns error");
}
// The SetPendingBuffer function sets the size of a buffer as percentage of total buffer size that media player goes out from buffering status.
res = this.plugin.SetPendingBuffer(Math.round(buffer_byte * Config.pendingBuffer /100.0));
if (res == false) {
Display.showPopup("SetPendingBuffer(" + Math.round(buffer_byte * Config.pendingBuffer /100.0) +") returns error");
- Main.log("SetPendingBuffer(" + Math.round(buffer_byte * Config.pendingBuffer /100.0) +") returns error");
+ Main.logToServer("SetPendingBuffer(" + Math.round(buffer_byte * Config.pendingBuffer /100.0) +") returns error");
}
};
Player.setVideoURL = function(url) {
this.url = url;
- alert("URL = " + this.url);
+ Main.log("URL = " + this.url);
};
Player.setCurrentPlayTimeOffset = function(val) {
@@ -127,8 +126,12 @@ Player.setCurrentPlayTimeOffset = function(val) {
};
Player.playVideo = function() {
+ if (Config.deviceType != 0) {
+ Display.showPopup ("Only supported for TVs");
+ return;
+ }
if (this.url == null) {
- alert("No videos to play");
+ Main.log("No videos to play");
}
else
{
@@ -146,7 +149,7 @@ Player.playVideo = function() {
Player.setBuffer(15000000.0);
- alert ("StartPlayback for " + this.url);
+ Main.log ("StartPlayback for " + this.url);
// if (this.plugin.StartPlayback() == false)
// Display.showPopup("StartPlayback returns false");
@@ -157,7 +160,7 @@ Player.playVideo = function() {
Player.pauseVideo = function() {
Display.showProgress();
- Main.log("pauseVideo");
+ Main.logToServer("pauseVideo");
this.state = this.PAUSED;
Display.status("Pause");
@@ -179,12 +182,12 @@ Player.stopVideo = function() {
}
}
else {
- alert("Ignoring stop request, not in correct state");
+ Main.log("Ignoring stop request, not in correct state");
}
};
Player.resumeVideo = function() {
- Main.log("resumeVideo");
+ Main.logToServer("resumeVideo");
Display.showProgress();
this.state = this.PLAYING;
Display.status("Play");
@@ -201,14 +204,14 @@ Player.jumpToVideo = function(percent) {
Player.bufferState = 0;
Display.showProgress();
if (this.state != this.PLAYING) {
- alert ("Player not Playing");
+ Main.log ("Player not Playing");
return;
}
if (this.totalTime == -1 && this.isLive == false)
this.totalTime = this.plugin.GetDuration();
var tgt = Math.round(((percent-2)/100.0) * this.totalTime/ 1000.0);
- alert("jumpToVideo= " + percent + "% of " + (this.totalTime/1000) + "sec tgt = " + tgt + "sec curPTime= " + (this.curPlayTime/1000) +"sec");
+ Main.log("jumpToVideo= " + percent + "% of " + (this.totalTime/1000) + "sec tgt = " + tgt + "sec curPTime= " + (this.curPlayTime/1000) +"sec");
// Display.showPopup("jumpToVideo= " + percent + "% of " + (this.totalTime/1000) + "sec<br>--> tgt = " + tgt + "sec curPTime= " + (this.curPlayTime/1000)+"sec");
this.plugin.Stop();
@@ -240,7 +243,7 @@ Player.getState = function() {
//------------------------------------------------
Player.onBufferingStart = function() {
- Main.log("Buffer Start: " + Player.curPlayTime);
+ Main.logToServer("Buffer Start: " + Player.curPlayTime);
Player.bufferStartTime = new Date().getTime();
Player.bufferState = 0;
@@ -265,7 +268,7 @@ Player.onBufferingComplete = function() {
Display.status("Play");
Display.hideStatus();
- Main.log("Buffer Completed - Buffering Duration= " + (new Date().getTime() - Player.bufferStartTime) + " ms");
+ Main.logToServer("Buffer Completed - Buffering Duration= " + (new Date().getTime() - Player.bufferStartTime) + " ms");
Player.bufferState = 100;
Display.bufferUpdate();
@@ -274,7 +277,7 @@ Player.onBufferingComplete = function() {
Player.setFullscreen();
Display.hide();
- Main.log("onBufferingComplete ");
+ Main.logToServer("onBufferingComplete ");
/* Player.pauseVideo();
window.setTimeout(Player.resumeVideo, 1000); */
};
@@ -283,40 +286,30 @@ Player.onBufferingComplete = function() {
Player.OnCurrentPlayTime = function(time) {
Player.curPlayTime = parseInt(time) + parseInt(Player.cptOffset);
-// alert ("OnCurrentPlayTime time= " + time + " this.curPlayTime= " +this.curPlayTime );
-// Display.setTime(Player.curPlayTime);
-
// Update the Current Play Progress Bar
Display.updateProgressBar();
if (Player.isRecording == true) {
Display.updateRecBar(Player.startTime, Player.duration);
}
- Player.curPlayTimeStr = Display.getHumanTimeRepresentation(Player.curPlayTime);
+ Player.curPlayTimeStr = Display.durationString(Player.curPlayTime / 1000.0);
+
Display.updatePlayTime();
};
Player.OnStreamInfoReady = function() {
- alert("*** OnStreamInfoReady ***");
-// Display.showPopup("*** OnStreamInfoReady *** ");
-// Display.showPopup("GetCurrentBitrates= " + Player.plugin.GetCurrentBitrates());
- Main.log("GetCurrentBitrates= " + Player.plugin.GetCurrentBitrates());
+ Main.log("*** OnStreamInfoReady ***");
+ Main.logToServer("GetCurrentBitrates= " + Player.plugin.GetCurrentBitrates());
if ((Player.isLive == false) && (Player.isRecording == false)) {
Player.totalTime = Player.plugin.GetDuration();
}
-// Display.updateTotalTime (Player.totalTime);
- Player.totalTimeStr = Display.getHumanTimeRepresentation(Player.totalTime);
-
-
-// alert("totalTime= " + Player.totalTime + " totalTimeStr= " +Player.totalTimeStr);
-// Display.setTotalTime(totalTime);
-
+ Player.curPlayTimeStr = Display.durationString(Player.totalTime / 1000.0);
/* var height = Player.plugin.GetVideoHeight();
var width = Player.GetVideoWidth();
Display.showPopup("Resolution= " + height + " x " +width);
- alert("Resolution= " + height + " x " +width);
+ Main.log("Resolution= " + height + " x " +width);
*/
};
@@ -327,14 +320,14 @@ Player.OnRenderingComplete = function() {
Player.OnConnectionFailed = function() {
// fails to connect to the streaming server
- alert ("ERROR: Failed to connect to the streaming server");
+ Main.log ("ERROR: Failed to connect to the streaming server");
// widgetAPI.putInnerHTML(document.getElementById("popup"), "Failed to connect to the streaming server");
Display.showPopup("Failed to connect to the streaming server");
};
Player.OnStreamNotFound = function() {
// 404 file not found
- alert ("ERROR: Stream Not Found");
+ Main.log ("ERROR: Stream Not Found");
// widgetAPI.putInnerHTML(document.getElementById("popup"), "Stream Not Found");
Display.showPopup("Stream Not Found");
@@ -342,7 +335,7 @@ Player.OnStreamNotFound = function() {
Player.OnNetworkDisconnected = function() {
// when the ethernet is disconnected or the streaming server stops supporting the content in the middle of streaming.
- alert ("ERROR: Lost Stream (Unavailable?)");
+ Main.log ("ERROR: Lost Stream (Unavailable?)");
// widgetAPI.putInnerHTML(document.getElementById("popup"), "Lost Stream (Unavailable?)");
Display.showPopup("Lost Stream (Unavailable?)");
diff --git a/smarttv-client/Javascript/Server.js b/smarttv-client/Javascript/Server.js
index c64d320..ee23505 100755
--- a/smarttv-client/Javascript/Server.js
+++ b/smarttv-client/Javascript/Server.js
@@ -13,7 +13,7 @@ Server.init = function()
var success = true;
var splashElement = document.getElementById("splashStatus");
- widgetAPI.putInnerHTML(splashElement, "Starting Up");
+ Display.putInnerHTML(splashElement, "Starting Up");
if (this.XHRObj) {
this.XHRObj.destroy();
@@ -28,7 +28,7 @@ Server.setSort = function (val) {
};
Server.fetchVideoList = function(url) {
- alert("fetching Videos url= " + url);
+ Main.log("fetching Videos url= " + url);
if (this.XHRObj == null) {
this.XHRObj = new XMLHttpRequest();
}
@@ -37,7 +37,7 @@ Server.fetchVideoList = function(url) {
this.XHRObj.onreadystatechange = function()
{
var splashElement = document.getElementById("splashStatus");
- widgetAPI.putInnerHTML(splashElement, "State" + Server.XHRObj.readyState);
+ Display.putInnerHTML(splashElement, "State" + Server.XHRObj.readyState);
if (Server.XHRObj.readyState == 4) {
Server.createVideoList();
@@ -49,7 +49,7 @@ Server.fetchVideoList = function(url) {
}
else {
var splashElement = document.getElementById("splashStatus");
- widgetAPI.putInnerHTML(splashElement, "Failed !!!" );
+ Display.putInnerHTML(splashElement, "Failed !!!" );
Display.showPopup("Failed to create XHR");
if (this.errorCallback != null) {
@@ -59,14 +59,14 @@ Server.fetchVideoList = function(url) {
};
Server.createVideoList = function() {
- alert ("creating Video list now");
- Main.log("creating Video list now");
+ Main.log ("creating Video list now");
+ Main.logToServer("creating Video list now");
var splashElement = document.getElementById("splashStatus");
- widgetAPI.putInnerHTML(splashElement, "Creating Video list now" );
+ Display.putInnerHTML(splashElement, "Creating Video list now" );
if (this.XHRObj.status != 200) {
- widgetAPI.putInnerHTML(splashElement, "XML Server Error " + this.XHRObj.status);
+ Display.putInnerHTML(splashElement, "XML Server Error " + this.XHRObj.status);
Display.status("XML Server Error " + this.XHRObj.status);
Display.showPopup("XML Server Error " + this.XHRObj.status);
if (this.errorCallback != null) {
@@ -78,7 +78,7 @@ Server.createVideoList = function() {
var xmlResponse = this.XHRObj.responseXML;
if (xmlResponse == null) {
Display.status("xmlResponse == null" );
- widgetAPI.putInnerHTML(splashElement, "Error in XML File ");
+ Display.putInnerHTML(splashElement, "Error in XML File ");
Display.showPopup("Error in XML File");
if (this.errorCallback != null) {
this.errorCallback("XmlError");
@@ -89,18 +89,18 @@ Server.createVideoList = function() {
// var xmlElement = this.XHRObj.responseXML.documentElement;
if (!xmlElement) {
- widgetAPI.putInnerHTML(splashElement, "Failed to get valid XML!!!");
+ Display.putInnerHTML(splashElement, "Failed to get valid XML!!!");
Display.status("Failed to get valid XML");
Display.showPopup("Failed to get valid XML");
return;
}
else
{
- widgetAPI.putInnerHTML(splashElement, "Parsing ...");
+ Display.putInnerHTML(splashElement, "Parsing ...");
var items = xmlElement.getElementsByTagName("item");
if (items.length == 0) {
Display.showPopup("Something wrong. Response does not contain any item");
- Main.log("Something wrong. Response does not contain any item");
+ Main.logToServer("Something wrong. Response does not contain any item");
};
@@ -120,7 +120,7 @@ Server.createVideoList = function() {
}
catch (e) {
- alert("ERROR: "+e);
+ Main.log("ERROR: "+e);
}
var desc = descriptionElement.firstChild.data;
@@ -137,7 +137,7 @@ Server.createVideoList = function() {
}
Data.completed(this.doSort);
- widgetAPI.putInnerHTML(splashElement, "Done...");
+ Display.putInnerHTML(splashElement, "Done...");
if (this.dataReceivedCallback)
{