diff options
author | thlo <t.lohmar@gmx.de> | 2013-04-05 17:43:54 +0200 |
---|---|---|
committer | thlo <t.lohmar@gmx.de> | 2013-04-05 17:43:54 +0200 |
commit | 0d3bb5c8d940b416ccc06a68a8ccfc35370fdbd4 (patch) | |
tree | 5e1b34165922afd5940e3ff566221fbd34d76155 | |
parent | d5c26eb7a9c51e82be0ac41bd04f4433043776cd (diff) | |
download | vdr-plugin-smarttvweb-0d3bb5c8d940b416ccc06a68a8ccfc35370fdbd4.tar.gz vdr-plugin-smarttvweb-0d3bb5c8d940b416ccc06a68a8ccfc35370fdbd4.tar.bz2 |
Selection of audio tracks.
First version of web video (yt) support.
various bug fixes.
-rwxr-xr-x | smarttv-client/CSS/Main.css | 60 | ||||
-rw-r--r-- | smarttv-client/Javascript/Comm.js | 101 | ||||
-rwxr-xr-x | smarttv-client/Javascript/Config.js | 7 | ||||
-rwxr-xr-x | smarttv-client/Javascript/Display.js | 73 | ||||
-rwxr-xr-x | smarttv-client/Javascript/Main.js | 221 | ||||
-rwxr-xr-x | smarttv-client/Javascript/Network.js | 3 | ||||
-rwxr-xr-x | smarttv-client/Javascript/Player.js | 488 | ||||
-rwxr-xr-x | smarttv-client/Javascript/Server.js | 49 | ||||
-rw-r--r-- | smarttv-client/Javascript/Urls.js | 257 | ||||
-rwxr-xr-x | smarttv-client/config.xml | 2 | ||||
-rwxr-xr-x | smarttv-client/index.html | 24 |
11 files changed, 940 insertions, 345 deletions
diff --git a/smarttv-client/CSS/Main.css b/smarttv-client/CSS/Main.css index ca16181..3b23da8 100755 --- a/smarttv-client/CSS/Main.css +++ b/smarttv-client/CSS/Main.css @@ -24,6 +24,8 @@ body { left: 0px; top: 0px;
width: 960px; height: 540px;
background-color: blue;
+ z-index:10;
+
}
#splashStatus {
@@ -41,6 +43,8 @@ body { position: absolute;
left: 0px; top: 0px;
width: 960px; height: 540px;
+ z-index:10;
+
background: url("../Images/selectScreen-bg.png");
background: radial-gradient(ellipse at 80% 80%, #c5deea 0%,#8abbd7 31%,#066dab 100%);
background: -webkit-radial-gradient(80% 80%, ellipse cover, rgba(197,222,234,1) 0%,rgba(138,187,215,1) 31%,rgba(6,109,171,1) 100%);
@@ -74,12 +78,18 @@ body { /* background-size: 100%;
*/
+#webapiplayer {
+ position: absolute;
+ left: 0px; top: 0px;
+ width: 960px; height: 540px;
+}
#optionsScreen {
position: absolute;
left: 0px; top: 0px;
width: 960px; height: 540px;
background: url("../Images/selectScreen-bg.png");
background: -webkit-radial-gradient(80% 80%, ellipse cover, rgba(197,222,234,1) 0%,rgba(138,187,215,1) 31%,rgba(6,109,171,1) 100%);
+ z-index:10;
}
#optionsView {
@@ -100,7 +110,8 @@ body { #statusPopup {
position: absolute;
- left: 80%; top: 10px;
+ display: none;
+ left: 80%; top: 10px;
width: 10%; height: 6%;
-webkit-border-radius: 1em;
-webkit-box-shadow:3px 3px 7px 4px rgba(0,0,0, 0.5);
@@ -112,6 +123,7 @@ body { padding-left:20px;
padding-right:20px;
background-color: rgba(0,0,0,0.5);
+ z-index:20;
}
#notify {
@@ -129,7 +141,7 @@ body { padding-left:20px;
padding-right:20px;
background-color: rgba(0,0,0,0.5);
- z-index:20;
+ z-index:50;
overflow:hidden;
text-overflow: ellipsis;
white-space : nowrap;
@@ -140,9 +152,9 @@ body { position: absolute;
display: none;
left: 0px; top: 0px;
- width: 960px; height: 30%;
+ width: 960px; height: 162px;
border-style:solid;
- z-index:10;
+ z-index:50;
padding-top:20px;
padding-left:20px;
padding-right:20px;
@@ -151,6 +163,36 @@ body { background-color: -webkit-linear-gradient(-45deg, rgba(167,207,223,1) 0%,rgba(35,83,138,1) 100%);
}
+#infoTitle{
+ position: absolute;
+ left: 2px; top: 0px;
+ width: 960px; height: 26px;
+ overflow:hidden;
+ text-overflow:ellipsis;
+ white-space:nowrap;
+}
+
+#infoDuration{
+ position: absolute;
+ left: 2px; top: 26px;
+ width: 960px; height: 21px;
+ font-size:14px;
+}
+
+#infoDesc{
+ position: absolute;
+ left: 2px; top: 47px;
+ width: 960px; height: 90px;
+ font-size:14px;
+ overflow:hidden;
+}
+
+#infoAudio {
+ position: absolute;
+ left: 2px; top: 141px;
+ width: 960px; height: 21px;
+ font-size:14px;
+}
#popup{
position: absolute;
display: none;
@@ -159,7 +201,7 @@ body { border-style:solid;
border-width:2px;
-webkit-border-radius: 7px;
- z-index:10;
+ z-index:50;
overflow-y: scroll;
padding-top:20px;
@@ -173,6 +215,8 @@ body { #main {
display: none;
position: absolute;
+ z-index:10;
+
left: 0px; top: 0px;
width: 960px; height: 540px;
background: rgba(0, 0, 139, 0.5);
@@ -188,7 +232,7 @@ body { background-repeat:repeat-x;
padding-top:3px;
padding-left:10px;
- z-index:10;
+ z-index:15;
}
#logo div {
@@ -374,7 +418,7 @@ body { background-repeat:repeat-x;
background-color: black;
background-color: rgba(0, 0, 0, 0.5);
- z-index:20;
+ z-index:50;
}
#olProgressBarBG {
@@ -465,6 +509,6 @@ body { background-repeat:no-repeat;
opacity:0.5;
display:none;
- z-index:20;
+ z-index:60;
}
diff --git a/smarttv-client/Javascript/Comm.js b/smarttv-client/Javascript/Comm.js new file mode 100644 index 0000000..d4cdd18 --- /dev/null +++ b/smarttv-client/Javascript/Comm.js @@ -0,0 +1,101 @@ +
+var Comm = {
+ customMgr : {},
+ deviceInstance : []
+};
+
+Comm.init = function () {
+ // >> Register custom manager callback to receive device connect and disconnect events
+ Comm.customMgr = webapis.customdevice || {};
+
+ Comm.customMgr.registerManagerCallback(Comm.onDeviceStatusChange);
+
+ // >> Initializes custom device profile and gets available devices
+ Comm.customMgr.getCustomDevices(Comm.onCustomObtained);
+ Main.log("curWidget.id= " + curWidget.id);
+ Main.logToServer("curWidget.id= (" + curWidget.id+")");
+};
+
+Comm.onDeviceStatusChange = function (sParam) {
+ switch( Number(sParam.eventType) ) {
+ case Comm.customMgr.MGR_EVENT_DEV_CONNECT:
+ Main.logToServer("onDeviceStatusChange - MGR_EVENT_DEV_CONNECT: name= " + sParam.name + " type= " +sParam.deviceType);
+ break;
+ case Comm.customMgr.MGR_EVENT_DEV_DISCONNECT:
+ Main.logToServer("onDeviceStatusChange - MGR_EVENT_DEV_DISCONNECT: name= " + sParam.name + " type= " +sParam.deviceType);
+ break;
+ default:
+ Main.logToServer("onDeviceStatusChange - Unknown event eType= " + sParam.eventType + " name= " + sParam.name+ " dType= "+sParam.deviceType);
+ break;
+ }
+ Comm.customMgr.getCustomDevices(Comm.onCustomObtained);
+};
+
+Comm.onCustomObtained = function (customs) {
+ Main.logToServer("onCustomObtained - found " + customs.length + " custom device(s)");
+ for(var i=0; i<customs.length; i++) {
+ if(customs[i]!=null && customs[i].getType() == Comm.customMgr.DEV_SMART_DEVICE) {
+ Main.logToServer("onCustomObtained - is Comm.custom.DEV_SMART_DEVICE: i=" + i);
+ Comm.deviceInstance[i] = customs[i];
+ Comm.deviceInstance[i].registerDeviceCallback(Comm.onDeviceEvent);
+ }
+ else {
+ Main.logToServer("ERROR in onCustomObtained: i= " + i + " No CB registered ");
+ }
+ }
+};
+
+Comm.onDeviceEvent = function(sParam) {
+ // sParam is CustomDeviceInfo
+ switch(Number(sParam.infoType)) {
+ case Comm.customMgr.DEV_EVENT_MESSAGE_RECEIVED:
+ //CustomDeviceMessageInfo
+// Main.log("#### onDeviceEvent -1- DEV_EVENT_MESSAGE_RECEIVED:" + sParam.data.message1);
+// Main.logToServer("#### onDeviceEvent -1- DEV_EVENT_MESSAGE_RECEIVED:" + sParam.data.message1);
+ Comm.onMessageReceived(sParam.data.message1, sParam.data.message2);
+ break;
+ case Comm.customMgr.DEV_EVENT_JOINED_GROUP:
+ //CustomDeviceGroupInfo
+// Main.log("#### onDeviceEvent -1- DEV_EVENT_JOINED_GROUP ####");
+// Main.logToServer("#### onDeviceEvent -1- DEV_EVENT_JOINED_GROUP ####");
+ break;
+ case Comm.customMgr.DEV_EVENT_LEFT_GROUP:
+ //CustomDeviceGroupInfo
+// Main.log("#### onDeviceEvent -1- DEV_EVENT_LEFT_GROUP ####");
+// Main.logToServer("#### onDeviceEvent -1- DEV_EVENT_LEFT_GROUP ####");
+ break;
+ default:
+ Main.logToServer("onDeviceEvent -1- Unknown event infoType= " + Number(sParam.infoType));
+ break;
+ }
+};
+
+
+Comm.onMessageReceived = function(message, context) {
+ // message -> message body
+ // context -> message context (headers and etc)
+ Main.logToServer("onMessageReceived:" + message);
+ var msg = eval('(' + message + ')');
+ if (msg.type == "YT") {
+ if (msg.payload.id == "undefined") {
+ Main.logToServer("ERROR: msg.payload.id is not defined");
+ return;
+ }
+ Main.logToServer("Found type YT " + msg.payload.id);
+ if (Main.state == Main.eURLS) {
+ if (msg.payload.id == "" ) {
+ Main.logToServer("ERROR: msg.payload.id is empty");
+ return;
+ }
+ Spinner.show();
+ UrlsFetcher.autoplay = msg.payload.id;
+ UrlsFetcher.removeWhenStopped = "";
+ if (msg.payload.store == false) {
+ UrlsFetcher.removeWhenStopped = msg.payload.id;
+ Main.logToServer("removeWhenStopped= " + msg.payload.id);
+ }
+ UrlsFetcher.appendGuid(msg.payload.id);
+ }
+ }
+
+};
diff --git a/smarttv-client/Javascript/Config.js b/smarttv-client/Javascript/Config.js index 38bed1c..027780a 100755 --- a/smarttv-client/Javascript/Config.js +++ b/smarttv-client/Javascript/Config.js @@ -18,6 +18,7 @@ var Config = { usePdlForRecordings : true,
uploadJsFile : "",
directAcessTimeout : 1500,
+ preferredQuality : 2,
widgetVersion : "unknown",
deviceType : 0 // Used to differentiate between browsers and platforms
// 0: Samsung
@@ -84,7 +85,7 @@ Config.init = function () { Config.readContext();
}
}
-
+ Server.notifyServer("started");
Config.fetchConfig();
};
@@ -111,6 +112,7 @@ Config.getWidgetVersion = function () { });
};
+
Config.fetchConfig = function () {
$.ajax({
url: this.serverUrl + "/widget.conf",
@@ -133,7 +135,8 @@ Config.fetchConfig = function () { Config.usePdlForRecordings = ($(data).find('usePdlForRecordings').text() == "false") ? false : true;
Config.uploadJsFile = $(data).find('uploadJsFile').text();
Config.directAcessTimeout = $(data).find('directAcessTimeout').text();
-
+ Config.preferredQuality = $(data).find('preferredQuality').text();
+
Player.skipDuration = Config.skipDuration;
if (Config.directAcessTimeout != "") {
DirectAccess.delay = Config.directAcessTimeout;
diff --git a/smarttv-client/Javascript/Display.js b/smarttv-client/Javascript/Display.js index 66d22dd..93a38ef 100755 --- a/smarttv-client/Javascript/Display.js +++ b/smarttv-client/Javascript/Display.js @@ -100,7 +100,10 @@ Display.GetEpochTime = function() { switch (Config.deviceType) {
case 0:
// Samsung specific UTC time function
- res = Display.pluginTime.GetEpochTime();
+// res = Display.pluginTime.GetEpochTime();
+ var now_millis = ((new Date).getTime());
+ res = (now_millis /1000.0);
+
break;
default:
var now_millis = ((new Date).getTime());
@@ -273,14 +276,19 @@ Display.tuneLeftSide = function() { res.w2 = "80%";
res.w3 = "5%";
break;
+ case Main.eREC:
+ res.w1 = "20%";
+ res.w2 = "70%";
+ res.w3 = "5%";
+ break;
case Main.eMED:
res.w1 = "5%";
res.w2 = "85%";
res.w3 = "5%";
break;
- case Main.eREC:
- res.w1 = "20%";
- res.w2 = "70%";
+ case Main.eURLS:
+ res.w1 = "5%";
+ res.w2 = "85%";
res.w3 = "5%";
break;
default:
@@ -463,6 +471,12 @@ Display.handleDescription =function (selected) { // msg += "<b>" + title + "</b>";
$("#descTitle").text(title);
break;
+ case Main.eURLS:
+// msg += "<b>" + title + "</b>";
+ $("#descTitle").text(title);
+ $("#descDuration").text("Duration: " + Display.durationString(length) + "h");
+ $("#descDesc").text(desc);
+ break;
default:
Main.logToServer("ERROR in Display.handleDescription: Should not be here");
break;
@@ -588,6 +602,9 @@ Display.getDisplayTitle = function(item) { res.c2 = item.title;
}
break;
+ case Main.eURLS:
+ res.c2 = item.title;
+ break;
default:
Main.logToServer("ERROR in Display.getDisplayTitle: Shall be in state 1, 2 or 3. State= " + Main.state);
break;
@@ -639,8 +656,9 @@ Display.updateOlForLive = function (start_time, duration, now) { Display.setOlTitle(Data.getCurrentItem().childs[Main.selectedVideo].title + " - " +Data.getCurrentItem().childs[Main.selectedVideo].payload.prog);
Display.setStartStop (start_time, (start_time + duration));
- Player.totalTime = Data.getCurrentItem().childs[Main.selectedVideo].payload.dur * 1000;
- Player.totalTimeStr =Display.durationString(Player.totalTime / 1000.0);
+ Player.setDuration();
+//thlo Player.totalTime = Data.getCurrentItem().childs[Main.selectedVideo].payload.dur * 1000;
+//thlo Player.totalTimeStr =Display.durationString(Player.totalTime / 1000.0);
// var digi = new Date((Data.getCurrentItem().childs[Main.selectedVideo].payload.start*1000));
// Main.log (" Date(): StartTime= " + digi.getHours() + ":" + digi.getMinutes() + ":" + digi.getSeconds());
@@ -706,11 +724,13 @@ Display.setTrickplay = function(direction, multiple) { // Player.OnCurrentPlayTime
Display.updatePlayTime = function() {
- $("#olTimeInfo").text(Player.curPlayTimeStr + " / " + Player.totalTimeStr);
+// $("#olTimeInfo").text(Player.curPlayTimeStr + " / " + Player.totalTimeStr);
+ $("#olTimeInfo").text(Player.curPlayTimeStr + " / " + Player.getDurationStr());
};
Display.updateProgressBar = function () {
- var timePercent = (Player.curPlayTime *100)/ Player.totalTime;
+//thlo var timePercent = (Player.curPlayTime *100)/ Player.totalTime;
+ var timePercent = (Player.curPlayTime *100)/ Player.getDuration();
$("#olProgressBar").css("width", (Math.round(timePercent) + "%"));
};
@@ -810,22 +830,48 @@ Display.showInfo = function(selected) { $("#infoTitle").text(title + "\n" + prog);
$("#infoDuration").text("Duration: " + Display.durationString(length) + "h Remaining: " + Display.durationString((itm.payload.start + length - now)));
$("#infoDesc").text(desc);
+ $("#infoAudio").text("Audio Tracks: " + Player.getNumOfAudioTracks() + " Subtitle Tracks: " + Player.getNumOfSubtitleTracks());
break;
case Main.eREC:
d_str = mon + "/" + day + " " + hour + ":" + min;
$("#infoTitle").text(title);
$("#infoDuration").text(d_str + " Duration: " + Display.durationString(length) + "h");
$("#infoDesc").text(desc);
+ $("#infoAudio").text("Audio Tracks: " + Player.getNumOfAudioTracks() + " Subtitle Tracks: " + Player.getNumOfSubtitleTracks());
break;
case Main.eMED:
$("#infoTitle").text(title);
+ $("#infoDuration").text("Duration: " + Display.durationString(Player.getDuration()) );
+ $("#infoAudio").text("Audio Tracks: " + Player.getNumOfAudioTracks() + " Subtitle Tracks: " + Player.getNumOfSubtitleTracks());
+ break;
+ case Main.eURLS:
+ $("#infoTitle").text(title);
+ $("#infoDuration").text("Duration: " + Display.durationString(length) );
+ $("#infoDesc").text(desc);
+
+/* var tgt_height = $("#infoDesc").height();
+ var temp = desc;
+
+ Main.log("tgt_height= " +tgt_height + " outerHeight= " + $('#infoDesc').outerHeight());
+ if( tgt_height < $('#infoDesc').outerHeight() ) {
+ while(tgt_height < $('#infoDesc').outerHeight()) {
+ $('#infoDesc').text( temp = temp.substr(0, temp.length-1) );
+ }
+ $('#infoDesc').text( temp = temp.substr(0, temp.length-3) );
+ $('#infoDesc').append('...');
+ }
+ */
+ $("#infoAudio").text("Audio Tracks: " + Player.getNumOfAudioTracks() + " Subtitle Tracks: " + Player.getNumOfSubtitleTracks());
break;
default:
Main.logToServer("ERROR in Display.handleDescription: Should not be here");
break;
}
this.infoOlHandler.show();
-
+ Main.log("Info title= (" + $("#infoTitle").position().top + ", " + $("#infoTitle").position().left+")");
+ Main.log("Info dur= (" + $("#infoDuration").position().top + ", " + $("#infoDuration").position().left+")");
+ Main.log("Info desc= (" + $("#infoDesc").position().top + ", " + $("#infoDesc").position().left+")");
+ Main.log("Info desc line-height: " + $("#infoDesc").css('line-height'));
};
Display.handlerShowInfo = function() {
@@ -881,7 +927,8 @@ Display.handlerShowProgress = function() { if (Player.isRecording == true) {
$("#olRecProgressBar").show();
var now = Display.GetEpochTime();
- var remaining = Math.round(((Player.startTime + Player.duration) - now) * 100/ Player.duration);
+//thlo var remaining = Math.round(((Player.startTime + Player.duration) - now) * 100/ Player.duration);
+ var remaining = Math.round(((Player.startTime + Player.getDuration()) - now) * 100/ Player.getDuration());
var elm = document.getElementById("olRecProgressBar");
elm.style.display="block";
elm.style.width = remaining + "%";
@@ -890,12 +937,14 @@ Display.handlerShowProgress = function() { else
$("#olRecProgressBar").hide();
- var timePercent = (Player.curPlayTime *100)/ Player.totalTime;
+//thlo var timePercent = (Player.curPlayTime *100)/ Player.totalTime;
+ var timePercent = (Player.curPlayTime *100)/ Player.getDuration();
document.getElementById("olProgressBar").style.width = timePercent + "%";
- $("#olTimeInfo").text(Player.curPlayTimeStr + " / " + Player.totalTimeStr);
+//thlo $("#olTimeInfo").text(Player.curPlayTimeStr + " / " + Player.totalTimeStr);
+ $("#olTimeInfo").text(Player.curPlayTimeStr + " / " + Player.getDurationStr());
var Digital=new Date();
var hours=Digital.getHours();
diff --git a/smarttv-client/Javascript/Main.js b/smarttv-client/Javascript/Main.js index f2594d3..2581074 100755 --- a/smarttv-client/Javascript/Main.js +++ b/smarttv-client/Javascript/Main.js @@ -51,7 +51,8 @@ var Main = { 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
+ eURLS : 4, // State Urls
+ eOPT : 5, // Options
defKeyHndl : null,
selectMenuKeyHndl : null,
@@ -128,8 +129,7 @@ Main.init = function () { Main.log("Main.init()");
Buttons.init();
- if ( Player.init() && Server.init() && Audio.init()) {
- Display.setVolume( Audio.getVolume() );
+ if ( Player.init() && Server.init() ) {
// Start retrieving data from server
Server.dataReceivedCallback = function() {
@@ -146,6 +146,14 @@ Main.init = function () { }
};
+ UrlsFetcher.dataReceivedCallback = function() {
+ /* Use video information when it has arrived */
+ Display.setVideoList(Main.selectedVideo, Main.selectedVideo);
+ Spinner.hide();
+ Display.show();
+ };
+
+
// Enable key event processing
this.enableKeys();
@@ -155,10 +163,15 @@ Main.init = function () { }
ClockHandler.start("#selectNow");
+ HeartbeatHandler.start();
+
Server.updateVdrStatus();
-
+// Server.notifyServer("started");
+
DirectAccess.init();
Config.getWidgetVersion();
+ Comm.init();
+
// DirectAccess.show();
// Timers.init();
// Display.initOlForRecordings();
@@ -207,11 +220,18 @@ Main.logToServer = function (msg) { */
};
-Main.onUnload = function()
-{
+Main.onUnload = function() {
+ Server.notifyServer("stopped");
Player.deinit();
};
+Main.testUrls = function () {
+ Main.log("################## Main.testUrls");
+ Spinner.show();
+ UrlsFetcher.autoplay = "6927QNxye6k";
+ UrlsFetcher.appendGuid("6927QNxye6k");
+
+};
Main.changeState = function (state) {
Main.log("change state: OldState= " + this.state + " NewState= " + state);
@@ -232,50 +252,53 @@ Main.changeState = function (state) { Main.log ("old Select= " + Main.selectMenuKeyHndl.select);
Display.resetSelectItems(old_state);
-// document.getElementById("selectScreen").style.display="block";
$("#selectScreen").show();
ClockHandler.start("#selectNow");
Display.hide();
Data.reset ();
+ //TODO: Should reset progress bar as well
Display.resetVideoList();
Display.resetDescription ();
break;
case Main.eLIVE:
-// document.getElementById("selectScreen").style.display="none";
$("#selectScreen").hide();
ClockHandler.start("#logoNow");
Display.show();
Main.selectedVideo = 0;
-// Data.reset ();
Main.liveSelected();
break;
case Main.eREC:
-// document.getElementById("selectScreen").style.display="none";
$("#selectScreen").hide();
ClockHandler.start("#logoNow");
Display.show();
Main.selectedVideo = 0;
-// Data.reset ();
Main.recordingsSelected();
break;
case Main.eMED:
-// document.getElementById("selectScreen").style.display="none";
$("#selectScreen").hide();
ClockHandler.start("#logoNow");
Display.show();
Main.selectedVideo = 0;
-// Data.reset ();
Main.mediaSelected();
break;
+ case Main.eURLS:
+ $("#selectScreen").hide();
+ ClockHandler.start("#logoNow");
+ Display.show();
+ Main.selectedVideo = 0;
+ Main.urlsSelected();
+
+// window.setTimeout(function() {Main.testUrls (); }, (5*1000));
+
+ break;
+
case Main.eOPT:
// Options
// Options.init();
-// document.getElementById("selectScreen").style.display="none";
$("#selectScreen").hide();
Options.show();
-// document.getElementById("optionsScreen").style.display="block";
Main.optionsSelected();
break;
}
@@ -303,10 +326,6 @@ Main.recordingsSelected = function() { };
Server.errorCallback = Main.serverError;
-/* Server.errorCallback = function (msg) {
- Server.errorCallback = Main.serverError;
- };
-*/
Server.setSort(true);
/* if (Config.format == "") {
Server.fetchVideoList(Config.serverUrl + "/recordings.xml?model=samsung");
@@ -336,12 +355,26 @@ Main.mediaSelected = function() { Display.showPopup(msg);
Main.changeState(0);
};
-// Player.isLive = false;
Server.setSort(true);
Spinner.show();
Server.fetchVideoList(Config.serverUrl + "/media.xml"); /* Request video information from server */
};
+Main.urlsSelected = function() {
+ Server.retries = 0;
+ Player.stopCallback = function() {
+ //
+ Display.show();
+ };
+ Server.errorCallback = function (msg) {
+ Display.showPopup(msg);
+ Main.changeState(0);
+ };
+ Server.setSort(true);
+ Spinner.show();
+ UrlsFetcher.fetchUrlList();
+};
+
Main.optionsSelected = function() {
Main.log ("Main.optionsSelected");
};
@@ -378,7 +411,7 @@ event = event || window.event; // selectView
this.selectMenuKeyHndl.handleKeyDown(event);
break;
- case 1:
+ case Main.eLIVE:
// Live
Main.log("Live - Main.keyDown PlayerState= " + Player.getState());
if(Player.getState() == Player.STOPPED) {
@@ -391,8 +424,9 @@ event = event || window.event; };
break;
- case 2:
- case 3:
+ case Main.eREC:
+ case Main.eMED:
+ case Main.eURLS:
// recordings
// Main.log("Recordings - Main.keyDown PlayerState= " + Player.getState());
if(Player.getState() == Player.STOPPED) {
@@ -405,7 +439,7 @@ event = event || window.event; };
break;
- case 4:
+ case Main.eOPT:
// Options.onInput();
// Main.log ("ERROR: Wrong State");
break;
@@ -447,9 +481,11 @@ Main.playItem = function (url) { // Server.getResume(Player.guid);
Main.log(" playItem: now= " + now + " start_time= " + start_time + " dur= " + duration + " (Start + Dur - now)= " + ((start_time + duration) -now));
+ Main.logToServer(" playItem: now= " + now + " start_time= " + start_time + " dur= " + duration + " (Start + Dur - now)= " + ((start_time + duration) -now));
- Player.totalTime = Data.getCurrentItem().childs[Main.selectedVideo].payload.dur * 1000;
- Player.totalTimeStr =Display.durationString(Player.totalTime / 1000.0);
+ Player.setDuration();
+//thlo Player.totalTime = Data.getCurrentItem().childs[Main.selectedVideo].payload.dur * 1000;
+//thlo Player.totalTimeStr =Display.durationString(Player.totalTime / 1000.0);
//thlo
if (Config.usePdlForRecordings == false) {
@@ -471,9 +507,10 @@ Main.playItem = function (url) { if ((now - (start_time + duration)) < 0) {
// still recording
Main.log("*** Still Recording! ***");
+ Main.logToServer("*** Still Recording! ***");
Player.isRecording = true;
Player.startTime = start_time;
- Player.duration = duration;
+ Player.duration = duration; // EpgDuration
// document.getElementById("olRecProgressBar").style.display="block";
$("#olRecProgressBar").show();
Display.updateRecBar(start_time, duration);
@@ -496,12 +533,6 @@ Main.playItem = function (url) { }
*/
}
-/* else {
- // TODO: Obsolete
- $("#olRecProgressBar").hide();
-// document.getElementById("olRecProgressBar").display="none";
- }
-*/
Player.setVideoURL( Data.getCurrentItem().childs[Main.selectedVideo].payload.link + url_ext);
Player.guid = Data.getCurrentItem().childs[Main.selectedVideo].payload.guid;
Main.log("Main.playItem - Player.guid= " +Player.guid);
@@ -528,6 +559,19 @@ Main.playItem = function (url) { Player.guid = "unknown";
break;
+ case Main.eURLS:
+ Display.hide();
+ Display.showProgress();
+ Player.mFormat = Player.ePDL;
+
+ Main.log(" playItem: now= " + now + " start_time= " + start_time + " dur= " + duration + " (Start + Dur - now)= " + ((start_time + duration) -now));
+
+ Display.setOlTitle(Data.getCurrentItem().childs[Main.selectedVideo].title);
+
+ Main.log("playItem: guid= " + Data.getCurrentItem().childs[Main.selectedVideo].payload.guid);
+ UrlsFetcher.getYtVideoUrl( Data.getCurrentItem().childs[Main.selectedVideo].payload.guid);
+
+ break;
default:
Main.logToServer("ERROR in Main.playItem: should not be here");
break;
@@ -536,19 +580,8 @@ Main.playItem = function (url) { };
Main.selectPageUp = function() {
-/* if (this.selectedVideo == 0) {
- Main.changeState(0);
- return;
- };
-*/
-// Main.previousVideo(Display.LASTIDX + 1);
Main.previousVideo(Display.getNumberOfVideoListItems());
-/* this.selectedVideo = (this.selectedVideo - (Display.LASTIDX + 1));
- if (this.selectedVideo < 0) {
- this.selectedVideo = 0;
- }
-*/
var first_item = this.selectedVideo - Display.currentWindow;
if (first_item < 0 )
first_item = 0;
@@ -558,14 +591,8 @@ Main.selectPageUp = function() { };
Main.selectPageDown = function() {
-// Main.nextVideo (Display.LASTIDX + 1);
Main.nextVideo (Display.getNumberOfVideoListItems());
-/* this.selectedVideo = (this.selectedVideo + Display.LASTIDX + 1);
- if (this.selectedVideo >= Data.getVideoCount()) {
- this.selectedVideo = Data.getVideoCount() -1;
- }
-*/
var first_item = this.selectedVideo - Display.currentWindow;
Main.log("selectPageDown: this.selectedVideo= " + this.selectedVideo + " first_item= " + first_item + " curWind= " + Display.currentWindow);
@@ -783,6 +810,13 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function (event) { case tvKey.KEY_ASPECT:
Player.toggleAspectRatio();
break;
+ case tvKey.KEY_BLUE:
+ Player.nextAudioTrack();
+ break;
+ case tvKey.KEY_YELLOW:
+ Player.nextSubtitleTrack();
+ break;
+ break;
default:
Main.log("Calling Default Key Hanlder");
this.defaultKeyHandler.handleDefKeyDown(keyCode);
@@ -939,6 +973,12 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function (event) { case tvKey.KEY_ASPECT:
Player.toggleAspectRatio();
break;
+ case tvKey.KEY_BLUE:
+ Player.nextAudioTrack();
+ break;
+ case tvKey.KEY_YELLOW:
+ Player.nextSubtitleTrack();
+ break;
default:
this.defaultKeyHandler.handleDefKeyDown(keyCode);
@@ -1103,7 +1143,7 @@ function cSelectMenuKeyHndl (def_hndl) { Main.log(this.handlerName + " created");
this.select = 1;
- this.selectMax = 4; // Highest Select Entry
+ this.selectMax = 5; // Highest Select Entry
};
cSelectMenuKeyHndl.prototype.handleKeyDown = function (event) {
@@ -1133,35 +1173,42 @@ cSelectMenuKeyHndl.prototype.handleKeyDown = function (event) { this.select = 4;
Main.changeState (this.select);
break;
-
- case tvKey.KEY_ENTER:
- case tvKey.KEY_PLAY:
- case tvKey.KEY_PANEL_ENTER:
- Main.log("ENTER");
- Main.log ("CurSelect= " + this.select);
- Main.changeState (this.select);
+ case tvKey.KEY_5:
+ Main.log("KEY_5 pressed");
+ this.select = 5;
+ Main.changeState (this.select);
+ break;
- case tvKey.KEY_DOWN:
- Display.unselectItem(document.getElementById("selectItem"+this.select));
- if (++this.select > this.selectMax)
- this.select = 1;
- Display.selectItem(document.getElementById("selectItem"+this.select));
- Main.log("DOWN " +this.select);
- break;
+ case tvKey.KEY_ENTER:
+ case tvKey.KEY_PLAY:
+ case tvKey.KEY_PANEL_ENTER:
+ Main.log("ENTER");
+ Main.log ("CurSelect= " + this.select);
+
+ Main.changeState (this.select);
+
+ break; //thlo: correct?
+ case tvKey.KEY_DOWN:
+ Display.unselectItem(document.getElementById("selectItem"+this.select));
+ if (++this.select > this.selectMax)
+ this.select = 1;
+ Display.selectItem(document.getElementById("selectItem"+this.select));
+ Main.log("DOWN " +this.select);
+ break;
- case tvKey.KEY_UP:
- Display.unselectItem(document.getElementById("selectItem"+this.select));
-
- if (--this.select < 1)
- this.select = this.selectMax;
- Display.selectItem(document.getElementById("selectItem"+this.select));
-
- Main.log("UP "+ this.select);
- break;
- default:
- this.defaultKeyHandler.handleDefKeyDown(keyCode);
- break;
+ case tvKey.KEY_UP:
+ Display.unselectItem(document.getElementById("selectItem"+this.select));
+
+ if (--this.select < 1)
+ this.select = this.selectMax;
+ Display.selectItem(document.getElementById("selectItem"+this.select));
+
+ Main.log("UP "+ this.select);
+ break;
+ default:
+ this.defaultKeyHandler.handleDefKeyDown(keyCode);
+ break;
}
};
@@ -1187,29 +1234,11 @@ cDefaulKeyHndl.prototype.handleDefKeyDown = function (keyCode) { widgetAPI.blockNavigation(event);
}
else {
+ Server.notifyServer("stopped");
widgetAPI.sendReturnEvent();
}
break;
-
-/* case tvKey.KEY_VOL_UP:
- Main.log(this.handlerName + "VOL_UP");
- Display.showVolume();
- if(Main.mute == 0)
- Audio.setRelativeVolume(0);
- break;
-
- case tvKey.KEY_VOL_DOWN:
- Main.log(this.handlerName + "VOL_DOWN");
- Display.showVolume();
- if(Main.mute == 0)
- Audio.setRelativeVolume(1);
- break;
- case tvKey.KEY_MUTE:
- Main.log(this.handlerName + "MUTE");
- Main.muteMode();
- break;
-*/
default:
Main.log(this.handlerName + "Unhandled key");
break;
diff --git a/smarttv-client/Javascript/Network.js b/smarttv-client/Javascript/Network.js index b4c0772..314dcca 100755 --- a/smarttv-client/Javascript/Network.js +++ b/smarttv-client/Javascript/Network.js @@ -2,6 +2,7 @@ var Network = { plugin : null,
ownMac : "",
ownGw : "",
+ ownIp : "",
isInited: false
};
@@ -12,9 +13,11 @@ Network.init = function () { if ((nw_type == 0) || (nw_type == 1)) {
this.ownMac = this.plugin.GetMAC(nw_type);
this.ownGw = this.plugin.GetGateway(nw_type);
+ this.ownIp = this.plugin.GetIP(nw_type);
}
Main.log( "ownMac= " + this.ownMac);
Main.log ("ownGw= " + this.ownGw);
+ Main.log ("ownIp= " + this.ownIp);
this.isInited = true;
}
catch (e) {
diff --git a/smarttv-client/Javascript/Player.js b/smarttv-client/Javascript/Player.js index 8f7a5cd..6708558 100755 --- a/smarttv-client/Javascript/Player.js +++ b/smarttv-client/Javascript/Player.js @@ -1,12 +1,11 @@ /*
* This module only works with the Samsung Media Players. For other player objects, the code need to be adjusted
*/
+var mainPlayer;
var Player =
{
- plugin : null,
- pluginBD : null,
- mFrontPanel : null,
+ AVPlayerObj : null,
isLive : false,
isRecording : false,
mFormat : 0,
@@ -19,7 +18,7 @@ var Player = url : "",
guid : "unknown",
startTime : 0,
- duration : 0,
+ duration : 0, // EpgDuration
resumePos : -1,
state : 0,
@@ -40,6 +39,8 @@ var Player = trickPlaySpeed : 1, // Multiple of 2 only.
trickPlayDirection : 1,
+ curAudioTrack : 0,
+ curSubtitleTrack : 0, // Zero means off
STOPPED : 0,
PLAYING : 1,
@@ -81,8 +82,9 @@ Player.resetAtStop = function () { this.isLive =false;
this.isRecording = false;
this.mFormat =Player.eUND;
-
- };
+ this.curAudioTrack =0;
+ this.curSubtitleTrack = 0;
+};
Player.toggleAspectRatio = function () {
/* var height = Player.plugin.GetVideoHeight();
@@ -105,24 +107,10 @@ Player.toggleAspectRatio = function () { // it is cropped 16 to 9
this.aspectRatio = this.eASP16to9;
Notify.showNotify("16 : 9", true);
- Main.logToServer("Player.toggleAspectRatio: 16 by 9 Now");
+// Main.logToServer("Player.toggleAspectRatio: 16 by 9 Now");
break;
}
Player.setFullscreen();
-/* if (this.aspectRatio == this.eASP16to9) {
- // Do 4 to 3
- this.plugin.SetDisplayArea(120, 0, 720, 540);
- // 4/3 = x/540
- this.aspectRatio = this.eASP4to3;
- Main.logToServer("Player.toggleAspectRatio: 4 by 3 Now");
- }
- else {
- // do 16 to 9
- Player.setFullscreen();
- this.aspectRatio = this.eASP16to9;
- Main.logToServer("Player.toggleAspectRatio: 16 by 9 Now");
- }
- */
};
@@ -133,141 +121,184 @@ Player.setWindow = function() { Player.setFullscreen = function() {
// this.plugin.SetDisplayArea(0, 0, 960, 540);
- var h = Player.plugin.GetVideoHeight();
- var w = Player.plugin.GetVideoWidth();
- Main.logToServer ("Resolution= " + w + " x " + h );
+ var resolution = Player.AVPlayerObj.getVideoResolution().split("|");
+
+ var w = resolution[0];
+ var h = resolution[1];
+ Main.logToServer ("Player.setFullscreen: Resolution= " + w + " x " + h );
Main.log ("Resolution= " + w + " x " + h );
switch (this.aspectRatio) {
case this.eASP16to9:
- this.plugin.SetDisplayArea(0, 0, 960, 540);
- this.plugin.SetCropArea(0, 0, w, h);
- Main.logToServer("Player.toggleAspectRatio: 16 by 9 Now");
+// this.plugin.SetDisplayArea(0, 0, 960, 540);
+// this.plugin.SetCropArea(0, 0, w, h);
+ Player.AVPlayerObj.setDisplayArea({left: 0, top:0, width:960, height:540 });
+ Player.AVPlayerObj.setCropArea(Player.onCropSuccess, Player.onError, {left: 0, top:0, width:w, height:h });
+
+ Main.logToServer("Player.setFullscreen: 16 by 9 Now");
break;
case this.eASP4to3:
// it is 4 to 3. do cropped do 16 to 9
- this.plugin.SetDisplayArea(120, 0, 720, 540);
- this.plugin.SetCropArea(0, 0, w, h);
+// this.plugin.SetDisplayArea(120, 0, 720, 540);
+// this.plugin.SetCropArea(0, 0, w, h);
+ Player.AVPlayerObj.setDisplayArea({left: 120, top:0, width:720, height:540 });
+ Player.AVPlayerObj.setCropArea(Player.onCropSuccess, Player.onError, {left: 0, top:0, width:w, height:h });
// 4/3 = x/540
- Main.logToServer("Player.toggleAspectRatio: 4 by 3 Now");
+ Main.logToServer("Player.setFullscreen: 4 by 3 Now");
break;
case this.eASPcrop16to9:
// it is cropped 16 to 9
var z = Math.ceil(w*w*27 /(h*64));
- Main.logToServer("Player.toggleAspectRatio: Crop 16 by 9 Now: z= " + z);
- this.plugin.SetDisplayArea(0, 0, 960, 540);
- this.plugin.SetCropArea(0, Math.round((h-z)/2), w, z);
+ Main.logToServer("Player.setFullscreen: Crop 16 by 9 Now: z= " + z);
+// this.plugin.SetDisplayArea(0, 0, 960, 540);
+// this.plugin.SetCropArea(0, Math.round((h-z)/2), w, z);
+ Player.AVPlayerObj.setDisplayArea({left: 0, top:0, width:960, height:540 });
+ Player.AVPlayerObj.setCropArea(Player.onCropSuccess, Player.onError, {left: 0, top:Math.round((h-z)/2), width:w, height:z });
break;
}
-/* if (this.aspectRatio == this.eASP16to9) {
- // Do 4 to 3
- this.plugin.SetDisplayArea(120, 0, 720, 540);
- // 4/3 = x/540
- this.aspectRatio = this.eASP4to3;
- Main.logToServer("Player.toggleAspectRatio: 4 by 3 Now");
- }
- else {
- // do 16 to 9
- Player.setFullscreen();
- this.aspectRatio = this.eASP16to9;
- Main.logToServer("Player.toggleAspectRatio: 16 by 9 Now");
- }
- */
};
+//successcallback
+//function onAVPlayObtained(avplay) {
+Player.onAVPlayObtained = function (avplay) {
+ Player.AVPlayerObj = avplay;
+ Player.AVPlayerObj.hide();
+ Main.logToServer("onAVPlayObtained: sName= " + avplay.sName+ " sVersion: " + avplay.sVersion);
+ var cb = new Object();
+ cb.containerID = 'webapiplayer';
+ cb.zIndex = 0;
+ cb.bufferingCallback = new Object();
+ cb.bufferingCallback.onbufferingstart= Player.onBufferingStart;
+ cb.bufferingCallback.onbufferingprogress = Player.onBufferingProgress;
+ cb.bufferingCallback.onbufferingcomplete = Player.onBufferingComplete;
+
+ cb.playCallback = new Object;
+ cb.playCallback.oncurrentplaytime = Player.OnCurrentPlayTime;
+ cb.playCallback.onresolutionchanged = Player.onResolutionChanged;
+ cb.playCallback.onstreamcompleted = Player.OnRenderingComplete;
+ cb.playCallback.onerror = Player.onError;
+
+ cb.displayRect= new Object();
+ cb.displayRect.top = 0;
+ cb.displayRect.left = 0;
+ cb.displayRect.width = 960;
+ cb.displayRect.height = 540;
+ cb.autoRatio = false;
+
+ try {
+ Player.AVPlayerObj.init(cb);
+ }
+ catch (e) {
+ Main.log("Player: Error during init: " + e.message);
+ Main.logToServer("Player: Error during init: " + e.message);
+ };
+};
+
+//errorcallback
+//function onGetAVPlayError(error) {
+Player.onGetAVPlayError = function (error) {
+ Main.log('Player.onGetAVPlayError: ' + error.message);
+ Main.logToServer('Player.onGetAVPlayError: ' + error.message);
+};
+
+
Player.init = function() {
var success = true;
Main.log("success vale : " + success);
this.state = this.STOPPED;
+
+ try {
+ var custom = webapis.avplay;
+ Main.logToServer("webapis.ver= " + webapis.ver);
+ custom.getAVPlay(Player.onAVPlayObtained, Player.onGetAVPlayError);
+ }
+ catch(exp) {
+ Main.log('Player.init: getAVplay Exception :[' +exp.code + '] ' + exp.message);
+ }
+
- this.plugin = document.getElementById("pluginPlayer");
- this.pluginBD = document.getElementById("pluginBD");
- try {
- this.pluginBD.DisplayVFD_Show(0101); // Stop
- }
- catch (e) {
-
- }
-
-/* var pl_version = "";
- try {
- pl_version = this.plugin.GetPlayerVersion();
- }
- catch (e) {
- Main.logToServer("Error while getting player version: " +e);
- }
- Main.logToServer("PlayerVersion= " + pl_version);
-*/
- if (!this.plugin)
- {
- Main.log("success vale this.plugin : " + success);
- success = false;
- }
this.skipDuration = Config.skipDuration; // Use Config default also here
-
-// var vermsg = this.plugin.GetPlayerVersion();
-// Main.log ("player plugin version: " +vermsg);
-
- this.plugin.OnCurrentPlayTime = 'Player.OnCurrentPlayTime';
- this.plugin.OnStreamInfoReady = 'Player.OnStreamInfoReady';
- this.plugin.OnBufferingStart = 'Player.onBufferingStart';
- this.plugin.OnBufferingProgress = 'Player.onBufferingProgress';
- this.plugin.OnBufferingComplete = 'Player.onBufferingComplete';
- this.plugin.OnConnectionFailed = 'Player.OnConnectionFailed'; // fails to connect to the streaming server
- this.plugin.OnStreamNotFound = 'Player.OnStreamNotFound'; // 404 file not found
- 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';
-
+
Main.log("success= " + success);
return success;
};
-Player.deinit = function()
-{
- Main.log("Player deinit !!! " );
-
- if (this.plugin)
- {
- this.plugin.Stop();
- }
+Player.deinit = function() {
+ Main.log("Player deinit !!! " );
+
+ if (Player.AVPlayerObj != null) {
+ Player.AVPlayerObj.stop();
+ }
+};
+
+Player.getNumOfAudioTracks = function () {
+ return (Player.AVPlayerObj.totalNumOfAudio != null) ? Player.AVPlayerObj.totalNumOfAudio : "Unknown";
+};
+
+Player.getNumOfSubtitleTracks = function () {
+ return (Player.AVPlayerObj.totalNumOfSubtitle != null) ? Player.AVPlayerObj.totalNumOfSubtitle : "Unknown";
+};
+
+Player.nextAudioTrack = function () {
+
+ Player.curAudioTrack = (Player.curAudioTrack +1 ) % Player.AVPlayerObj.totalNumOfAudio;
+
+ try {
+ if (Player.AVPlayerObj.setAudioStreamID(Player.curAudioTrack) == false) {
+ Main.logToServer("Player.nextAudioTrack: Failed to set audio track to " + Player.curAudioTrack);
+ Display.showPopup("Player.nextAudioTrack: Failed to set audio track to " + Player.curAudioTrack);
+ }
+ else {
+ Main.logToServer("Player.nextAudioTrack: Track= " + Player.curAudioTrack);
+ Notify.showNotify("Audio Track " + Player.curAudioTrack, true);
+ }
+
+ }
+ catch (e) {
+ Main.logToServer("Player.nextAudioTrack: Caught Error: " + e.message);
+ Display.showPopup("Player.nextAudioTrack: Caught Error: " + e.message);
+ }
};
+Player.nextSubtitleTrack = function () {
+ if (!Player.AVPlayerObj.getSubtitleAvailable() ) {
+ return;
+ }
+
+ Player.curSubtitleTrack = (Player.curSubtitleTrack +1 ) % (Player.AVPlayerObj.totalNumOfSubtitle +1);
-Player.setBuffer = function (){
- var res = true;
+ try {
+ if (Player.AVPlayerObj.setSubtitleStreamID(Player.curSubtitleTrack) == false) {
+ Main.logToServer("Player.nextSubtitleTrack: Failed to set subtitle track to " + Player.curSubtitleTrack);
+ Display.showPopup("Player.nextSubtitleTrack: Failed to set subtitle track to " + Player.curSubtitleTrack);
+ }
+ else {
+ Main.logToServer("Player.nextSubtitleTrack: Track= " + Player.curSubtitleTrack);
+ Notify.showNotify("Subtitle " + Player.curSubtitleTrack, true);
+ }
+
+ }
+ catch (e) {
+ Main.logToServer("Player.nextSubtitleTrack: Caught Error: " + e.message);
+ Display.showPopup("Player.nextSubtitleTrack: Caught Error: " + e.message);
+ }
+
+};
+
+Player.getBuffer = function (){
+ var res = {};
var buffer_byte = (Config.totalBufferDuration * Config.tgtBufferBitrate) / 8.0;
var initial_buf = Config.initialBuffer;
if (Player.isLive == true)
initial_buf = initial_buf *4;
- Main.logToServer("Seting TotalBufferSize to " + Math.round(buffer_byte) +"Byte dur= " +Config.totalBufferDuration + "sec init_buffer_perc= " +initial_buf +"% 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.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 * initial_buf/ 100.0));
- if (res == false) {
- Display.showPopup("SetInitialBuffer(" + Math.round(buffer_byte * initial_buf/ 100.0) +") returns error");
- Main.logToServer("SetInitialBuffer(" + Math.round(buffer_byte * initial_buf/ 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.logToServer("SetInitialTimeOut(" + 2 +") returns error");
- }
+ res.totalBufferSize = Math.round(buffer_byte);
+ res.initialBufferSize = Math.round( buffer_byte * initial_buf/ 100.0);
+ res.pendingBufferSize = Math.round(buffer_byte * Config.pendingBuffer /100.0);
- // 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.logToServer("SetPendingBuffer(" + Math.round(buffer_byte * Config.pendingBuffer /100.0) +") returns error");
- }
+ Main.logToServer("Setting totalBufferSize= " + res.totalBufferSize +"Byte initialBufferSize= " +res.initialBufferSize + "byte pendingBufferSize= " +res.pendingBufferSize +"byte " );
+
+ return res;
};
Player.setVideoURL = function(url) {
@@ -282,6 +313,19 @@ Player.setCurrentPlayTimeOffset = function(val) { // Display.showPopup("CurrentPlayTimeOffset= " + this.cptOffset);
};
+Player.setDuration = function () {
+ Player.totalTime = Data.getCurrentItem().childs[Main.selectedVideo].payload.dur * 1000;
+ Player.totalTimeStr =Display.durationString(Player.totalTime / 1000.0);
+};
+
+Player.getDuration = function () {
+ return Player.totalTime;
+};
+
+Player.getDurationStr = function () {
+ return Player.totalTimeStr;
+};
+
Player.playVideo = function(resume_pos) {
if (Config.deviceType != 0) {
Display.showPopup ("Only supported for TVs");
@@ -291,23 +335,20 @@ Player.playVideo = function(resume_pos) { Main.log("No videos to play");
}
else {
- Player.setFullscreen();
Player.bufferState = 0;
Display.bufferUpdate();
+ Player.AVPlayerObj.show();
Spinner.show();
-// Player.curPlayTime = 0;
Display.updatePlayTime();
Display.status("Play");
Display.hideStatus();
-// Display.showStatus();
Display.showProgress();
this.state = this.PLAYING;
-// Player.setBuffer();
Player.ResetTrickPlay();
Player.skipDuration = Config.skipDuration; // reset
@@ -315,35 +356,43 @@ Player.playVideo = function(resume_pos) { this.requestStartTime = new Date().getTime();
if (Player.isRecording == false) {
- if (resume_pos == -1) {
-// this.plugin.Play( this.url );
- this.plugin.InitPlayer(this.url);
- Player.setBuffer();
- this.plugin.StartPlayback();
- }
- else {
- Main.logToServer ("Player.playVideo: resume_pos= " +resume_pos);
- Player.setBuffer();
- this.plugin.ResumePlay(this.url, resume_pos);
- }
+ if (resume_pos == -1)
+ resume_pos = 0;
+
+ try {
+ // Player.AVPlayerObj.open (this.url, Player.getBuffer());
+ Player.AVPlayerObj.open (this.url);
+ Player.AVPlayerObj.play(Player.onPlaySuccess, Player.onError, resume_pos);
+ }
+ catch (e) {
+ Main.log("Player.play: Error caugth " + e.msg);
+ Main.logToServer("Player.play: Error caugth " + e.msg);
+ Display.showPopup("Player.play: Error caugth " + e.msg);
+ }
+
}
else {
if (resume_pos == -1)
resume_pos = 0;
Player.setCurrentPlayTimeOffset(resume_pos * 1000.0);
-// this.plugin.Play( this.url+ "?time=" + resume_pos );
- this.plugin.InitPlayer(this.url+ "?time=" + resume_pos );
- Player.setBuffer();
- this.plugin.StartPlayback();
+ try {
+// Player.AVPlayerObj.open(this.url+ "?time=" + resume_pos, Player.getBuffer() );
+ Player.AVPlayerObj.open(this.url+ "?time=" + resume_pos );
+ Player.AVPlayerObj.play(Player.onPlaySuccess , Player.onError);
+ }
+ catch(e) {
+ Main.log("Player.play: Error: " + e.message);
+ Main.logToServer("Player.play: Error: " + e.message);
+ Display.showPopup("Player.play: Error: " + e.message);
+ };
Main.logToServer("Player.play with ?time=" + resume_pos);
}
if ((this.mFormat == this.eHLS) && (this.isLive == false)){
Notify.showNotify("No Trickplay", true);
}
- Audio.plugin.SetSystemMute(false);
- pluginObj.setOffScreenSaver();
- this.pluginBD.DisplayVFD_Show(0100); // Play
+// Audio.plugin.SetSystemMute(false);
+// pluginObj.setOffScreenSaver();
}
};
@@ -354,21 +403,32 @@ Player.pauseVideo = function() { this.state = this.PAUSED;
Display.status("Pause");
Display.showStatus();
- var res = this.plugin.Pause();
+ var res = false;
+ try {
+ res = Player.AVPlayerObj.pause();
+ }
+ catch(e) {
+ Main.log("Player.pause: Error " + e.message);
+ Main.logToServer("Player.pause: Error " + e.message);
+ Display.showPopup("Player.pause: Error " + e.message);
+ }
if (res == false)
Display.showPopup("pause ret= " + ((res == true) ? "True" : "False"));
- pluginObj.setOnScreenSaver();
- this.pluginBD.DisplayVFD_Show(0102); // Pause
+// pluginObj.setOnScreenSaver();
};
Player.stopVideo = function() {
if (this.state != this.STOPPED) {
+
this.state = this.STOPPED;
Display.status("Stop");
- this.plugin.Stop();
-
-// Display.setTime(0);
+ Player.AVPlayerObj.hide();
+ try {
+ Player.AVPlayerObj.stop();
+ }
+ catch (e) {
+ }
if (this.stopCallback) {
Main.log(" StopCallback");
this.stopCallback();
@@ -378,8 +438,7 @@ Player.stopVideo = function() { Display.resetAtStop();
Spinner.hide();
- pluginObj.setOnScreenSaver();
- this.pluginBD.DisplayVFD_Show(0101); // Stop
+// pluginObj.setOnScreenSaver();
}
else {
Main.log("Ignoring stop request, not in correct state");
@@ -392,11 +451,15 @@ Player.resumeVideo = function() { this.state = this.PLAYING;
Display.status("Play");
Display.hideStatus();
- var res = this.plugin.Resume();
+ var res = false;
+ try {
+ res = Player.AVPlayerObj.resume();
+ }
+ catch (e){
+ }
if (res == false)
Display.showPopup("resume ret= " + ((res == true) ? "True" : "False"));
- pluginObj.setOffScreenSaver();
- this.pluginBD.DisplayVFD_Show(0100); // Play
+// pluginObj.setOffScreenSaver();
};
Player.jumpToVideo = function(percent) {
@@ -413,7 +476,7 @@ Player.jumpToVideo = function(percent) { //TODO: the totalTime should be set already
if (this.totalTime == -1 && this.isLive == false)
- this.totalTime = this.plugin.GetDuration();
+ this.totalTime = Player.AVPlayerObj.getDuration();
var tgt = Math.round(((percent-2)/100.0) * this.totalTime/ 1000.0);
var res = false;
@@ -421,34 +484,26 @@ Player.jumpToVideo = function(percent) { if (Player.isRecording == false) {
if (tgt > (Player.curPlayTime/1000.0))
- res = this.plugin.JumpForward(tgt - (Player.curPlayTime/1000.0));
+ res = Player.AVPlayerObj.jumpForward(tgt - (Player.curPlayTime/1000.0));
else
- res = this.plugin.JumpBackward( (Player.curPlayTime/1000.0)- tgt);
+ res = Player.AVPlayerObj.jumpBackward( (Player.curPlayTime/1000.0)- tgt);
}
else {
- this.plugin.Stop();
+ Player.AVPlayerObj.stop();
var old = Player.curPlayTime;
Player.setCurrentPlayTimeOffset(tgt * 1000.0);
-// res = this.plugin.Play( this.url+ "?time=" + tgt );
- this.plugin.InitPlayer(this.url+ "?time=" + tgt );
- res = this.plugin.StartPlayback();
+// Player.AVPlayerObj.open(this.url+ "?time=" + tgt, Player.getBuffer() );
+ Player.AVPlayerObj.open(this.url+ "?time=" + tgt);
+ res = Player.AVPlayerObj.play(Player.onPlaySuccess , Player.onError);
Main.logToServer("Player.play with ?time=" + tgt);
if (res == false)
Player.setCurrentPlayTimeOffset(old);
-
- // set currentPlayTimeOffsert to tgt
- // set new url with time
- // play
}
Main.logToServer("Player.jumpToVideo: jumpTo= " + percent + "% of " + (this.totalTime/1000) + "sec tgt = " + tgt + "sec cpt= " + (this.curPlayTime/1000) +"sec" + " res = " + res);
-// Display.showPopup("jumpToVideo= " + percent + "% of " + (this.totalTime/1000) + "sec<br>--> tgt = " + tgt + "sec curPTime= " + (this.curPlayTime/1000)+"sec");
-// Display.showStatus();
- // this.plugin.Stop();
-// var res = this.plugin.ResumePlay(this.url, tgt );
if (res == false)
Display.showPopup("ResumePlay ret= " + ((res == true) ? "True" : "False"));
};
@@ -458,17 +513,17 @@ Player.skipForwardVideo = function() { Display.showProgress();
var res = false;
if (Player.isRecording == false)
- res = this.plugin.JumpForward(Player.skipDuration);
+ res = Player.AVPlayerObj.jumpForward(Player.skipDuration);
else {
Spinner.show();
this.bufferState = 0;
- this.plugin.Stop();
+ Player.AVPlayerObj.stop();
var old = Player.curPlayTime;
var tgt = (Player.curPlayTime/1000.0) + Player.skipDuration;
Player.setCurrentPlayTimeOffset(tgt * 1000.0);
-// res = this.plugin.Play( this.url+ "?time=" + tgt );
- this.plugin.InitPlayer(this.url+ "?time=" + tgt );
- res = this.plugin.StartPlayback();
+// Player.AVPlayerObj.open(this.url+ "?time=" + tgt, Player.getBuffer());
+ Player.AVPlayerObj.open(this.url+ "?time=" + tgt);
+ res = Player.AVPlayerObj.play(Player.onPlaySuccess , Player.onError);
Main.logToServer("Player.skipForwardVideo with ?time=" + tgt);
if (res == false)
@@ -484,18 +539,18 @@ Player.skipBackwardVideo = function() { Display.showProgress();
var res = false;
if (Player.isRecording == false)
- res = this.plugin.JumpBackward(Player.skipDuration);
+ res = Player.AVPlayerObj.jumpBackward(Player.skipDuration);
else {
Spinner.show();
this.bufferState = 0;
- this.plugin.Stop();
+ Player.AVPlayerObj.stop();
var tgt = (Player.curPlayTime/1000.0) - Player.skipDuration;
if (tgt < 0)
tgt = 0;
Player.setCurrentPlayTimeOffset(tgt * 1000.0);
-// res = this.plugin.Play( this.url+ "?time=" + tgt );
- this.plugin.InitPlayer(this.url+ "?time=" + tgt );
- res = this.plugin.StartPlayback();
+// Player.AVPlayerObj.open(this.url+ "?time=" + tgt, Player.getBuffer());
+ Player.AVPlayerObj.open(this.url+ "?time=" + tgt);
+ res = Player.AVPlayerObj.play(Player.onPlaySuccess , Player.onError);
Main.logToServer("Player.skipBackwardVideo with ?time=" + tgt);
if (res == false)
@@ -548,7 +603,6 @@ Player.fastForwardVideo = function() { this.trickPlaySpeed = 1;
this.trickPlayDirection = 1;
}
-
}
if (Player.isRecording == true) {
if (this.trickPlaySpeed > 2)
@@ -566,7 +620,7 @@ Player.fastForwardVideo = function() { Main.log("FastForward: Direction= " + ((this.trickPlayDirection == 1) ? "Forward": "Backward") + "trickPlaySpeed= " + this.trickPlaySpeed);
Main.logToServer("FastForward: Direction= " + ((this.trickPlayDirection == 1) ? "Forward": "Backward") + "trickPlaySpeed= " + this.trickPlaySpeed);
- if (this.plugin.SetPlaybackSpeed(this.trickPlaySpeed * this.trickPlayDirection) == false) {
+ if (Player.AVPlayerObj.setSpeed(this.trickPlaySpeed * this.trickPlayDirection) == false) {
Display.showPopup("trick play returns false. Reset Trick-Play" );
Player.ResetTrickPlay();
// this.trickPlaySpeed = 1;
@@ -575,11 +629,9 @@ Player.fastForwardVideo = function() { };
Player.RewindVideo = function() {
-
if ((this.trickPlayDirection == 1) && (this.trickPlaySpeed == 1)){
this.trickPlayDirection = -1;
- this.trickPlaySpeed = this.trickPlaySpeed * 2;
-
+ this.trickPlaySpeed = this.trickPlaySpeed * 2;
}
else if (this.trickPlayDirection == 1) {
// I am in fast forward mode, so decrease
@@ -588,7 +640,6 @@ Player.RewindVideo = function() { this.trickPlaySpeed = 1;
this.trickPlayDirection = -1;
}
-
}
else
this.trickPlaySpeed = this.trickPlaySpeed * 2;
@@ -597,7 +648,6 @@ Player.RewindVideo = function() { if (this.trickPlayDirection <0 )
Player.ResetTrickPlay();
return;
-// this.trickPlayDirection = 1;
}
if (this.trickPlaySpeed != 1) {
@@ -610,23 +660,15 @@ Player.RewindVideo = function() { Main.log("Rewind: Direction= " + ((this.trickPlayDirection == 1) ? "Forward": "Backward") + "trickPlaySpeed= " + this.trickPlaySpeed);
- if (this.plugin.SetPlaybackSpeed(this.trickPlaySpeed * this.trickPlayDirection) == false) {
+ if (Player.AVPlayerObj.setSpeed(this.trickPlaySpeed * this.trickPlayDirection) == false) {
Display.showPopup("trick play returns false. Reset Trick-Play" );
Player.ResetTrickPlay();
-// this.trickPlaySpeed = 1;
-// this.trickPlayDirection = 1;
}
Main.log("Rewind: Direction= " + ((this.trickPlayDirection == 1) ? "Forward": "Backward") + "trickPlaySpeed= " + this.trickPlaySpeed);
Main.logToServer("Rewind: Direction= " + ((this.trickPlayDirection == 1) ? "Forward": "Backward") + "trickPlaySpeed= " + this.trickPlaySpeed);
- /* if (this.plugin.SetPlaybackSpeed(this.trickPlaySpeed * this.trickPlayDirection) == false) {
- Display.showPopup("trick play returns false. Reset Trick-Play" );
- this.trickPlaySpeed = 1;
- this.trickPlayDirection = 1;
- }
-*/
};
Player.ResetTrickPlay = function() {
@@ -634,7 +676,7 @@ Player.ResetTrickPlay = function() { this.trickPlaySpeed = 1;
this.trickPlayDirection = 1;
Main.log("Reset Trickplay " );
- if (this.plugin.SetPlaybackSpeed(this.trickPlaySpeed * this.trickPlayDirection) == false) {
+ if (Player.AVPlayerObj.setSpeed(this.trickPlaySpeed * this.trickPlayDirection) == false) {
Display.showPopup("trick play returns false. Reset Trick-Play" );
this.trickPlaySpeed = 1;
this.trickPlayDirection = 1;
@@ -656,30 +698,44 @@ Player.getState = function() { // ------------------------------------------------
// Global functions called directly by the player
//------------------------------------------------
+Player.onResolutionChanged = function () {
+ Main.log('Player.onResolutionChanged : ');
+};
+
+Player.onError = function () {
+ Main.log('Player.onError: ' );
+ Main.logToServer('Player.onError: ' );
+};
+
+
+Player.onPlaySuccess = function () {
+ Player.OnStreamInfoReady();
+};
+
+Player.onCropSuccess = function () {
+ Main.log('Player.onCropSuccess: ');
+// Main.logToServer('Player.onCropSuccess: ');
+};
+
Player.onBufferingStart = function() {
- Main.logToServer("Buffer Start: cpt= " + (Player.curPlayTime/1000.0) +"sec");
+// Main.logToServer("Buffer Start: cpt= " + (Player.curPlayTime/1000.0) +"sec");
+ Main.log("Buffer Start: cpt= " + (Player.curPlayTime/1000.0) +"sec");
Player.bufferStartTime = new Date().getTime();
if (this.requestStartTime != 0) {
- Main.logToServer("Player.onBufferingStart Server RTT= " + (Player.bufferStartTime -this.requestStartTime ) + "ms");
this.requestStartTime = 0;
}
Spinner.show();
Player.bufferState = 0;
Display.bufferUpdate();
- // should trigger from here the overlay
+
Display.showProgress();
Display.status("Buffering...");
-// Display.showStatus();
};
-Player.onBufferingProgress = function(percent)
-{
- // should trigger from here the overlay
-// Display.status("Buffering:" + percent + "%");
-
+Player.onBufferingProgress = function(percent) {
Player.bufferState = percent;
Display.bufferUpdate();
Display.showProgress();
@@ -691,6 +747,7 @@ Player.onBufferingComplete = function() { Spinner.hide();
Main.logToServer("onBufferingComplete cpt= " +(Player.curPlayTime/1000.0) +"sec - Buffering Duration= " + (new Date().getTime() - Player.bufferStartTime) + " ms");
+ Main.log("onBufferingComplete cpt= " +(Player.curPlayTime/1000.0) +"sec - Buffering Duration= " + (new Date().getTime() - Player.bufferStartTime) + " ms");
Player.bufferState = 100;
Display.bufferUpdate();
@@ -700,14 +757,16 @@ Player.onBufferingComplete = function() { // or I should set it according to the aspect ratio
Display.hide();
-// Main.logToServer("onBufferingComplete ");
-/* Player.pauseVideo();
- window.setTimeout(Player.resumeVideo, 1000); */
};
Player.OnCurrentPlayTime = function(time) {
- Player.curPlayTime = parseInt(time) + parseInt(Player.cptOffset);
+ Main.log ("Player.OnCurrentPlayTime " + time.millisecond);
+
+ if (typeof time == "number")
+ Player.curPlayTime = parseInt(time) + parseInt(Player.cptOffset);
+ else
+ Player.curPlayTime = parseInt(time.millisecond) + parseInt(Player.cptOffset);
// Update the Current Play Progress Bar
Display.updateProgressBar();
@@ -715,24 +774,23 @@ Player.OnCurrentPlayTime = function(time) { if (Player.isRecording == true) {
Display.updateRecBar(Player.startTime, Player.duration);
}
+ Main.log ("Player.OnCurrentPlayTime: curPlayTimeStr= " + Player.curPlayTimeStr);
Player.curPlayTimeStr = Display.durationString(Player.curPlayTime / 1000.0);
+
Display.updatePlayTime();
};
Player.OnStreamInfoReady = function() {
Main.log("*** OnStreamInfoReady ***");
+// Main.logToServer("*** OnStreamInfoReady ***");
Player.setFullscreen();
-// Main.logToServer("GetCurrentBitrates= " + Player.plugin.GetCurrentBitrates());
if ((Player.isLive == false) && (Player.isRecording == false)) {
- Player.totalTime = Player.plugin.GetDuration();
+ Player.totalTime = Player.AVPlayerObj.getDuration();
}
-// Player.curPlayTimeStr = Display.durationString(Player.totalTime / 1000.0);
Player.totalTimeStr =Display.durationString(Player.totalTime / 1000.0);
+ Main.log("Player.totalTimeStr= " + Player.totalTimeStr);
-// var height = Player.plugin.GetVideoHeight();
-// var width = Player.plugin.GetVideoWidth();
-// Main.logToServer("Resolution= " + width + " x " + height );
};
Player.OnRenderingComplete = function() {
diff --git a/smarttv-client/Javascript/Server.js b/smarttv-client/Javascript/Server.js index ec969b8..77b8cff 100755 --- a/smarttv-client/Javascript/Server.js +++ b/smarttv-client/Javascript/Server.js @@ -7,6 +7,7 @@ var Server = { XHRObj : null
};
+
Server.init = function()
{
var success = true;
@@ -90,8 +91,8 @@ Server.updateVdrStatus = function (){ type : "GET",
success : function(data, status, XHR){
var free = $(data).find('free').text() / 1024.0;
- var used = $(data).find('used').text() / 1024.0;
- var percent = $(data).find('percent').text();
+// var used = $(data).find('used').text() / 1024.0;
+// var percent = $(data).find('percent').text();
var unit = "GB";
var free_str = free.toFixed(2);
@@ -107,7 +108,7 @@ Server.updateVdrStatus = function (){ Main.log("VdrStatus: Error");
}
});
-}
+};
Server.getResume = function (guid) {
@@ -179,3 +180,45 @@ Server.deleteRecording = function(guid) { }
});
};
+
+
+Server.notifyServer = function (state) {
+ Main.log("Server.notifyServer state="+state +"&mac=" + Network.ownMac + "&ip=" + Network.ownIp);
+ $.ajax({
+ url: Config.serverUrl + "/clients?state="+state +"&mac=" + Network.ownMac + "&ip=" + Network.ownIp,
+ type : "GET",
+ success : function(data, status, XHR ) {
+ Main.log("Config.notifyServer OK" ) ;
+ },
+ error : function (XHR, status, error) {
+ Main.log("Config.notifyServer failed" ) ;
+ }
+ });
+};
+
+var HeartbeatHandler = {
+ timeoutObj : null,
+ isActive : false
+};
+
+
+HeartbeatHandler.start = function(){
+ if (this.isActive ==true)
+ window.clearTimeout(this.timeoutObj);
+
+ this.isActive = true;
+ HeartbeatHandler.update();
+};
+
+HeartbeatHandler.update = function() {
+ Server.notifyServer("running");
+ this.timeoutObj = window.setTimeout(function() {HeartbeatHandler.update(); }, (60*1000)); // once every 1min
+};
+
+HeartbeatHandler.stop = function(){
+ if (this.isActive == false )
+ return;
+
+ window.clearTimeout(this.timeoutObj);
+ this.isActive = false;
+};
diff --git a/smarttv-client/Javascript/Urls.js b/smarttv-client/Javascript/Urls.js new file mode 100644 index 0000000..f7c2e36 --- /dev/null +++ b/smarttv-client/Javascript/Urls.js @@ -0,0 +1,257 @@ +var UrlsFetcher = {
+ qualities : {17 : "144p", 36 : "240p", 18 : "360p", 22 : "720p", 37 : "1080p" },
+ preference : [36, 18, 22, 37],
+ usable : [],
+ curQuality : 2,
+ fv : "",
+ urls : {},
+ guids : [],
+ guidDict :{},
+ issuedRequests : 0,
+ caughtResponses : 0,
+ dataReceivedCallback : null,
+ autoplay : ""
+ };
+
+UrlsFetcher.resetCurQuality = function () {
+ UrlsFetcher.curQuality = 2;
+ if ((Config.preferredQuality > 0) && (Config.preferredQuality < UrlsFetcher.preference.length)) {
+ UrlsFetcher.curQuality = Config.preferredQuality;
+ Main.log("Setting UrlsFetcher.curQuality= " + UrlsFetcher.curQuality);
+ }
+};
+
+UrlsFetcher.fetchUrlList = function() {
+ Main.log(" --- UrlsFetcher.fetchUrlList --- ");
+
+ UrlsFetcher.resetCurQuality();
+
+ Data.sort = true;
+ Data.createAccessMap = true;
+ UrlsFetcher.issuedRequests = 0;
+ UrlsFetcher.caughtResponses = 0;
+ UrlsFetcher.guids = [];
+ UrlsFetcher.fetchUrls(Config.serverUrl + "/urls.xml");
+};
+
+UrlsFetcher.fetchUrls = function(url) {
+ Main.log("UrlsFetcher.fetchUrls url= " + url);
+
+ $.ajax({
+ url: url,
+ type : "GET",
+ success : function(data, status, XHR ) {
+ Main.log("UrlsFetcher.fetchUrls Success Response - status= " + status + " mime= " + XHR.responseType + " data= "+ data);
+
+ $(data).find("item").each(function () {
+ var guid = $(this).find('guid').text();
+ Main.log("UrlsFetcher.fetchUrls : guid= " + guid );
+ UrlsFetcher.guids.push(guid);
+// UrlsFetcher.getYtDescription(guid);
+ }); // each
+ // Done
+ UrlsFetcher.getAllDescription();
+ },
+ error : function (jqXHR, status, error) {
+ Main.log("UrlsFetcher.fetchUrls Error Response - status= " + status + " error= "+ error);
+ },
+ parsererror : function () {
+ Main.log("UrlsFetcher.fetchUrls parserError " );
+
+ }
+ });
+
+};
+
+UrlsFetcher.appendGuid = function (guid) {
+ Main.log("UrlsFetcher.appendGuid guid= " + guid + " UrlsFetcher.guids.length= " + UrlsFetcher.guids.length);
+
+ UrlsFetcher.guids.push(guid);
+ UrlsFetcher.guidDict[guid] = {};
+ UrlsFetcher.guidDict[guid]["num"] = (UrlsFetcher.guids.length);
+ UrlsFetcher.guidDict[guid]["start"] = (UrlsFetcher.guids.length);
+ UrlsFetcher.getYtDescription(guid);
+ Main.logToServer("Data.getVideoCount= " + Data.getVideoCount());
+};
+
+
+
+UrlsFetcher.getAllDescription = function () {
+ Main.log("UrlsFetcher.getAllDescription guids.length= " + UrlsFetcher.guids.length);
+ for (var i = 0; i < UrlsFetcher.guids.length; i++) {
+ Main.log("Calling " + UrlsFetcher.guids[i]);
+ var guid = UrlsFetcher.guids[i];
+ UrlsFetcher.guidDict[guid] = {};
+ UrlsFetcher.guidDict[guid]["num"] = (i+1);
+ UrlsFetcher.guidDict[guid]["start"] = (i+1);
+
+ UrlsFetcher.getYtDescription(guid);
+// UrlsFetcher.getYtDescription(UrlsFetcher.guids[i]);
+ }
+ Main.log("UrlsFetcher.getAllDescription Done" );
+};
+
+UrlsFetcher.handleResponse = function (success) {
+ UrlsFetcher.caughtResponses++;
+ Main.log("UrlsFetcher.handleResponse caughtResponses= " + UrlsFetcher.caughtResponses);
+
+ if (UrlsFetcher.caughtResponses >= UrlsFetcher.issuedRequests) {
+ //Done
+ Main.logToServer("UrlsFetcher.handleResponse - Done: " + UrlsFetcher.caughtResponses);
+
+ if (UrlsFetcher.autoplay == "") {
+ Data.completed(false);
+ if (UrlsFetcher.dataReceivedCallback) {
+ UrlsFetcher.dataReceivedCallback();
+ }
+ }
+ else {
+// Main.logToServer("UrlsFetcher.handleResponse Autoplay " + UrlsFetcher.autoplay);
+ Main.log("UrlsFetcher.handleResponse Autoplay " + UrlsFetcher.autoplay);
+ Spinner.hide();
+
+ // autoplay:
+ if (success == true) {
+// Display.setVideoList(Main.selectedVideo, Main.selectedVideo);
+
+ Main.logToServer("UrlsFetcher.handleResponse play guid= " + UrlsFetcher.autoplay);
+ var num = UrlsFetcher.guidDict[UrlsFetcher.autoplay]["num"];
+ DirectAccess.selectNewChannel(num);
+
+ var first_idx = (Data.getVideoCount() < Display.getNumberOfVideoListItems()) ?0: Data.getVideoCount() - Display.getNumberOfVideoListItems();
+ Display.setVideoList(Main.selectedVideo, first_idx);
+
+ }
+ else {
+ // remove
+ Main.logToServer("Error - UrlsFetcher.handleResponse: remove guid= " + UrlsFetcher.autoplay);
+ delete UrlsFetcher.guidDict[UrlsFetcher.autoplay];
+ }
+
+ UrlsFetcher.autoplay = "";
+
+ }
+ }
+};
+
+UrlsFetcher.getYtDescription = function (vid) {
+ Main.log("UrlsFetcher.getYtDescription vid= " + vid);
+ var url = 'http://gdata.youtube.com/feeds/api/videos/'+vid+'?v=2&alt=json';
+ Main.log("UrlsFetcher.getYtDescription url= " + url);
+ UrlsFetcher.issuedRequests ++;
+
+ $.ajax({
+ url: url,
+ type : "GET",
+ dataType: "json",
+ success: function(data, status, XHR ) {
+ var title = data.entry.title.$t;
+ var description = data.entry.media$group.media$description.$t;
+ var duration = data.entry.media$group.yt$duration.seconds;
+ var guid = data.entry.media$group.yt$videoid.$t;
+
+ var num = UrlsFetcher.guidDict[guid]["num"];
+ var start = UrlsFetcher.guidDict[guid]["start"];
+
+ Data.addItem( [title], {link : "", prog: "", desc: description, guid : guid, start: start,
+ dur: duration, ispes : "false", isnew : "false", fps : 0, num : num});
+ Main.log("UrlsFetcher.getYtDescription: guid= " + guid + "was inserted at= " + Data.directAccessMap[num]);
+ Main.logToServer("UrlsFetcher.getYtDescription: guid= " + guid + "was inserted at= " + Data.directAccessMap[num]);
+ UrlsFetcher.handleResponse(true);
+ //insert into data-base
+ },
+ error : function(jqXHR, status, error) {
+ Main.log("UrlsFetcher.getYtDescription: Error");
+ UrlsFetcher.handleResponse(false);
+ }
+
+ });
+
+};
+
+
+
+UrlsFetcher.getYtVideoUrl = function (vid) {
+ Main.log("UrlsFetcher.getYtVideoUrl: vid= " + vid);
+
+ //Reset
+ UrlsFetcher.fv = "";
+ UrlsFetcher.usable = [];
+ UrlsFetcher.urls = {}; // reset
+ UrlsFetcher.resetCurQuality();
+// UrlsFetcher.curQuality = 2;
+
+ $.get('http://www.youtube.com/get_video_info?video_id=' + vid, function(data) {
+ UrlsFetcher.fv = data;
+ var status = UrlsFetcher.getQueryAttrib(UrlsFetcher.fv, "status");
+ if (status == "fail") {
+ var reason = UrlsFetcher.getQueryAttrib(UrlsFetcher.fv, "reason");
+ Main.log("reason: " + reason);
+ Main.log("fv= "+UrlsFetcher.fv);
+ Display.showPopup(reason);
+ return;
+ }
+
+ UrlsFetcher.extractYtUrl(vid);
+
+ });
+};
+
+
+UrlsFetcher.getQueryAttrib = function (querystring, item) {
+ var filter = new RegExp( item + "=([^&]+)" );
+ return unescape( querystring.match(filter)[1] );
+};
+
+UrlsFetcher.extractYtUrl = function (vid) {
+ var stream_map = UrlsFetcher.getQueryAttrib(UrlsFetcher.fv, "url_encoded_fmt_stream_map").split(",");
+ var itags = [];
+
+ for (var i = 0; i < stream_map.length; i++) {
+ var url =
+ UrlsFetcher.getQueryAttrib(stream_map[i], "url") + "&signature=" +
+ UrlsFetcher.getQueryAttrib(stream_map[i], "sig");
+ var itag= url.match(/itag=(\d+)/)[1];
+ itags.push(itag);
+ if ( itag in UrlsFetcher.qualities) {
+ // store only the wanted itags
+ UrlsFetcher.urls[itag] = url;
+ UrlsFetcher.usable.push(itag);
+ }
+ };
+ if (UrlsFetcher.usable.length == 0) {
+ // Nothing to play
+ Display.showPopup("No supported format found for this clip.");
+ Player.stop();
+ Spinner.hide();
+ Display.resetAtStop();
+ Display.show();
+ }
+ // Done: Play now
+ Main.log(vid+ ": Available Qualities= "+ itags.toString());
+ Main.logToServer(vid+ ": Available Qualities= "+ itags.toString());
+
+ if (UrlsFetcher.usable.length == 0) {
+ Display.showPopup ("Error: No Suitable Formats founds " );
+ return;
+ }
+ var ok = false;
+
+
+ while (!ok) {
+ if (UrlsFetcher.preference[UrlsFetcher.curQuality] in UrlsFetcher.urls) {
+ Player.setVideoURL(UrlsFetcher.urls[UrlsFetcher.preference[UrlsFetcher.curQuality]]);
+ ok = true;
+ Notify.showNotify("Quality: " + UrlsFetcher.qualities[UrlsFetcher.preference[UrlsFetcher.curQuality]], true);
+ }
+ else
+ UrlsFetcher.curQuality --;
+ if (UrlsFetcher.curQuality <0) {
+ Player.setVideoURL(UrlsFetcher.urls[UrlsFetcher.usable[0]]);
+ Notify.showNotify("Quality: " + UrlsFetcher.qualities[UrlsFetcher.usable[0]], true);
+ ok = true;
+ }
+ }
+ Player.playVideo(-1);
+
+};
diff --git a/smarttv-client/config.xml b/smarttv-client/config.xml index cd6d56c..c3f8550 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.92</ver>
+ <ver>0.93</ver>
<mgrver></mgrver>
<fullwidget>y</fullwidget>
<movie>y</movie>
diff --git a/smarttv-client/index.html b/smarttv-client/index.html index 3a2f188..5172cac 100755 --- a/smarttv-client/index.html +++ b/smarttv-client/index.html @@ -16,6 +16,7 @@ <script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/Util/Include.js"></script>
<script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/Util/Language.js"></script>
<script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/Plugin/Define.js"></script>
+ <script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/webapi/1.0/webapis.js"></script>
<!-- Widget code -->
<script language="javascript" type="text/javascript" src="Javascript/Main.js"></script>
@@ -23,7 +24,7 @@ <script language="javascript" type="text/javascript" src="Javascript/Data.js"></script>
<script language="javascript" type="text/javascript" src="Javascript/Player.js"></script>
<script language="javascript" type="text/javascript" src="Javascript/Display.js"></script>
- <script language="javascript" type="text/javascript" src="Javascript/Audio.js"></script>
+<!-- <script language="javascript" type="text/javascript" src="Javascript/Audio.js"></script>-->
<script language="javascript" type="text/javascript" src="Javascript/Network.js"></script>
<script language="javascript" type="text/javascript" src="Javascript/Config.js"></script>
<script language="javascript" type="text/javascript" src="Javascript/Helpbar.js"></script>
@@ -35,13 +36,16 @@ <script language="javascript" type="text/javascript" src="Javascript/DirectAccess.js"></script>
<script language="javascript" type="text/javascript" src="Javascript/Timers.js"></script>
<script language="javascript" type="text/javascript" src="Javascript/Lang.js"></script>
+ <script language="javascript" type="text/javascript" src="Javascript/Urls.js"></script>
+ <script language="javascript" type="text/javascript" src="Javascript/Comm.js"></script>
<!-- Style sheets -->
<link rel="stylesheet" href="CSS/Main.css" type="text/css">
<!-- Plugins -->
- <object id="pluginPlayer" border=0 classid="clsid:SAMSUNG-INFOLINK-PLAYER"></object>
- <object id="pluginAudio" border=0 classid="clsid:SAMSUNG-INFOLINK-AUDIO"></object>
+<!-- <object id="pluginPlayer" border=0 classid="clsid:SAMSUNG-INFOLINK-PLAYER"></object> -->
+
+<!-- <object id="pluginAudio" border=0 classid="clsid:SAMSUNG-INFOLINK-AUDIO"></object>-->
<object id="pluginTime" border=0 classid="clsid:SAMSUNG-INFOLINK-TIME"></object>
<object id="pluginObjectTVMW" border=0 classid="clsid:SAMSUNG-INFOLINK-TVMW"></object>
<object id="pluginObjectVideo" border=0 classid="clsid:SAMSUNG-INFOLINK-VIDEO"></object>
@@ -51,7 +55,6 @@ <object id="pluginNetwork" border=0 classid="clsid:SAMSUNG-INFOLINK-NETWORK"></object>
<object id="pluginTaskmgnt" border=0 classid="clsid:SAMSUNG-INFOLINK-TASKMANAGER"></object>
- <object id="pluginBD" border=0 classid="clsid:SAMSUNG-INFOLINK-FRONTPANEL"></object>
</head>
@@ -61,6 +64,7 @@ <!-- Dummy anchor as focus for key events -->
<a href='javascript:void(0);' id='anchor' onkeydown='Main.keyDown();'></a>
+ <div id="webapiplayer"></div>
<!-- Layout begins -->
<div id="statusPopup"></div>
<div id="notify">
@@ -81,7 +85,8 @@ <div id="selectItem1">1: Live</div>
<div id="selectItem2">2: Recordings</div>
<div id="selectItem3">3: Media</div>
- <div id="selectItem4">4: Options</div>
+ <div id="selectItem4">4: YouTube</div>
+ <div id="selectItem5">5: Options</div>
</div>
</div>
<div id="optionsScreen">
@@ -169,13 +174,16 @@ </div>
<div id="infoOverlay">
- <table style="width: 90%">
- <tr><th id="infoTitle" align="left" style="padding-bottom:5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;">
+ <table height="100%" width="90%">
+ <tr><th id="infoTitle" align="left">
</th></tr>
<tr><td id="infoDuration">
</td></tr>
- <tr><td id="infoDesc" style="padding-top: 5px; overflow:hidden; ">
+ <tr><td id="infoDesc">
+ </td></tr>
+ <tr><td id="infoAudio" >
</td></tr>
+
</table>
</div>
<div id="Spinning">
|