From cc26cdb5e522efd5004c3138121adbb950c83f6d Mon Sep 17 00:00:00 2001 From: thlo Date: Mon, 31 Dec 2012 14:06:22 +0100 Subject: Several small improvements and bug fixes. --- smarttv-client/CSS/Main.css | 21 ++- smarttv-client/Images/description-bg.png | Bin 0 -> 94116 bytes smarttv-client/Images/leftHalf-bg.png | Bin 0 -> 138277 bytes smarttv-client/Images/main-bg.png | Bin 0 -> 2522 bytes smarttv-client/Images/rightHalf-bg.png | Bin 0 -> 124624 bytes smarttv-client/Images/selectScreen-bg.png | Bin 0 -> 306185 bytes smarttv-client/Images/selectView-bg.png | Bin 0 -> 74541 bytes smarttv-client/Images/videoList-bg.png | Bin 0 -> 106449 bytes smarttv-client/Javascript/Main.js | 232 ++++++++++++++++++++---------- smarttv-client/Javascript/Player.js | 81 ++++++++++- smarttv-client/config.xml | 2 +- smarttv-client/index.html | 11 +- 12 files changed, 253 insertions(+), 94 deletions(-) create mode 100644 smarttv-client/Images/description-bg.png create mode 100644 smarttv-client/Images/leftHalf-bg.png create mode 100644 smarttv-client/Images/main-bg.png create mode 100644 smarttv-client/Images/rightHalf-bg.png create mode 100644 smarttv-client/Images/selectScreen-bg.png create mode 100644 smarttv-client/Images/selectView-bg.png create mode 100644 smarttv-client/Images/videoList-bg.png diff --git a/smarttv-client/CSS/Main.css b/smarttv-client/CSS/Main.css index da91d1f..ae43a9e 100755 --- a/smarttv-client/CSS/Main.css +++ b/smarttv-client/CSS/Main.css @@ -41,10 +41,9 @@ body { 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%); } -/* background: -webkit-linear-gradient(top, rgba(64,150,238,1) 0%,rgba(64,150,238,1) 100%);*/ - #selectView { position: absolute; @@ -57,6 +56,8 @@ body { padding-top:20px; padding-left:20px; padding-right:20px; + background: url("../Images/selectView-bg.png"); + background-size: 100%; background: -webkit-linear-gradient(-45deg, #1e5799 0%,#2989d8 41%,#7db9e8 100%); -webkit-box-shadow:3px 3px 7px 4px rgba(0,0,0, 0.5); } @@ -66,6 +67,7 @@ body { left: 0px; top: 0px; width: 960px; height: 540px; display: none; + 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%); } @@ -80,6 +82,8 @@ body { padding-top:20px; padding-left:20px; padding-right:20px; + background: url("../Images/selectView-bg.png"); + background-size: 100%; background: -webkit-linear-gradient(-45deg, #1e5799 0%,#2989d8 41%,#7db9e8 100%); -webkit-box-shadow:3px 3px 7px 4px rgba(0,0,0, 0.5); } @@ -124,6 +128,8 @@ body { position: absolute; left: 0px; top: 0px; width: 960px; height: 540px; + background: rgba(0, 0, 139, 0.5); + background: url("../Images/main-bg.png"); background: -webkit-linear-gradient(top, rgba(64,150,238,1) 0%,rgba(64,150,238,1) 100%); } @@ -150,10 +156,11 @@ body { -webkit-border-radius: 7px; border-width:1px; + background: url("../Images/rightHalf-bg.png"); + background-size: 100%; background: -webkit-linear-gradient(-45deg, #1e5799 0%,#2989d8 41%,#7db9e8 100%); } -/* background: -webkit-linear-gradient(top, rgba(197,222,234,1) 0%,rgba(138,187,215,1) 31%,rgba(6,109,171,1) 100%); -*/ + #status { position:absolute; @@ -182,6 +189,8 @@ body { text-overflow : ellipsis; -webkit-box-shadow:3px 3px 7px 4px rgba(0,0,0, 0.5); + background: url("../Images/description-bg.png"); + background-size: 100%; background: -webkit-linear-gradient(-45deg, #1e5799 0%,#2989d8 41%,#7db9e8 100%); } @@ -190,6 +199,8 @@ body { position:absolute; left: 10px; top:40px; width:50%; height:90%; + background: url("../Images/leftHalf-bg.png"); + background-size: 100%; background: -webkit-linear-gradient(-45deg, #1e5799 0%,#2989d8 41%,#7db9e8 100%); border-style:solid; border-width:1px; @@ -212,6 +223,8 @@ body { -webkit-border-radius: 7px; -webkit-box-shadow:3px 3px 7px 4px rgba(0,0,0, 0.5); + background: url("../Images/videoList-bg.png"); + background-size: 100%; background: -webkit-linear-gradient(-45deg, #1e5799 0%,#2989d8 41%,#7db9e8 100%); } diff --git a/smarttv-client/Images/description-bg.png b/smarttv-client/Images/description-bg.png new file mode 100644 index 0000000..f1021d4 Binary files /dev/null and b/smarttv-client/Images/description-bg.png differ diff --git a/smarttv-client/Images/leftHalf-bg.png b/smarttv-client/Images/leftHalf-bg.png new file mode 100644 index 0000000..0be1542 Binary files /dev/null and b/smarttv-client/Images/leftHalf-bg.png differ diff --git a/smarttv-client/Images/main-bg.png b/smarttv-client/Images/main-bg.png new file mode 100644 index 0000000..d9743ce Binary files /dev/null and b/smarttv-client/Images/main-bg.png differ diff --git a/smarttv-client/Images/rightHalf-bg.png b/smarttv-client/Images/rightHalf-bg.png new file mode 100644 index 0000000..824f3a8 Binary files /dev/null and b/smarttv-client/Images/rightHalf-bg.png differ diff --git a/smarttv-client/Images/selectScreen-bg.png b/smarttv-client/Images/selectScreen-bg.png new file mode 100644 index 0000000..6d595cc Binary files /dev/null and b/smarttv-client/Images/selectScreen-bg.png differ diff --git a/smarttv-client/Images/selectView-bg.png b/smarttv-client/Images/selectView-bg.png new file mode 100644 index 0000000..084f7d7 Binary files /dev/null and b/smarttv-client/Images/selectView-bg.png differ diff --git a/smarttv-client/Images/videoList-bg.png b/smarttv-client/Images/videoList-bg.png new file mode 100644 index 0000000..d6b7900 Binary files /dev/null and b/smarttv-client/Images/videoList-bg.png differ diff --git a/smarttv-client/Javascript/Main.js b/smarttv-client/Javascript/Main.js index 7103068..7d71e4d 100755 --- a/smarttv-client/Javascript/Main.js +++ b/smarttv-client/Javascript/Main.js @@ -1,9 +1,11 @@ var widgetAPI = null; var tvKey = null; +var pluginObj = null; try { widgetAPI = new Common.API.Widget(); tvKey = new Common.API.TVKeyValue(); + pluginObj = new Common.API.Plugin(); } catch (e) { } @@ -64,9 +66,12 @@ var Main = { }; Main.onLoad = function() { + window.onShow = showHandler; + Network.init(); try { - widgetAPI.sendReadyEvent(); + widgetAPI.sendReadyEvent(); + } catch (e) { Config.deviceType = 1; @@ -77,7 +82,7 @@ Main.onLoad = function() { } Display.init(); - + this.defKeyHndl = new cDefaulKeyHndl; this.playStateKeyHndl = new cPlayStateKeyHndl(this.defKeyHndl); this.livePlayStateKeyHndl = new cLivePlayStateKeyHndl(this.defKeyHndl); @@ -89,11 +94,23 @@ Main.onLoad = function() { Config.init(); }; +showHandler = function() { + NNaviPlugin = document.getElementById("pluginObjectNNavi"); + NNaviPlugin.SetBannerState(2); + + pluginObj.unregistKey(tvKey.KEY_VOL_UP); + pluginObj.unregistKey(tvKey.KEY_VOL_DOWN); + pluginObj.unregistKey(tvKey.KEY_MUTE); + pluginObj.unregistKey(tvKey.KEY_PANEL_VOL_UP); + pluginObj.unregistKey(tvKey.KEY_PANEL_VOL_DOWN); +}; + + // Called by Config, when done // TODO: Send sendReadyEvent early and show a splash screen during startup Main.init = function () { Main.log("Main.init()"); - if ( Player.init() && Audio.init() && Server.init() ) { + if ( Player.init() && Server.init() && Audio.init()) { Display.setVolume( Audio.getVolume() ); // Start retrieving data from server @@ -116,7 +133,16 @@ Main.init = function () { else { Main.log("Failed to initialise"); } - + /* + * + * Fetch JS file + xhttp=new XMLHttpRequest(); + xhttp.open("GET","$MANAGER_WIDGET/Common/API/Plugin.js",false); + xhttp.send(""); + xmlDoc=xhttp.responseText; + Main.logToServer (xmlDoc); +*/ + }; Main.log = function (msg) { @@ -146,6 +172,7 @@ Main.onUnload = function() Player.deinit(); }; + Main.changeState = function (state) { Main.log("change state: new state= " + state); var old_state = this.state; @@ -698,6 +725,65 @@ Main.getKeyCode = function(code) { return res; }; +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 + +}; + + //--------------------------------------------------- // PlayState Key Handler //--------------------------------------------------- @@ -768,20 +854,33 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function () { Player.jumpToVideo(90); break; - case tvKey.KEY_RIGHT: case tvKey.KEY_FF: - Main.log("FF"); + case tvKey.KEY_RIGHT: + Main.log("Right: Skip Forward"); Display.showProgress(); Player.skipForwardVideo(); break; - case tvKey.KEY_LEFT: case tvKey.KEY_RW: - Main.log("RW"); + case tvKey.KEY_LEFT: + Main.log("Left: Skip Backward"); Display.showProgress(); Player.skipBackwardVideo(); break; +/* Works only for progressive streams, not Adaptive HTTP */ +/* case tvKey.KEY_FF: + Main.log("FF"); + Display.showProgress(); + Player.fastForwardVideo(); + + break; + case tvKey.KEY_RW: + Main.log("RW"); + Display.showProgress(); + Player.RewindVideo(); + break; +*/ case tvKey.KEY_ENTER: case tvKey.KEY_PLAY: case tvKey.KEY_PANEL_ENTER: @@ -789,6 +888,7 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function () { if(Player.getState() == Player.PAUSED) { Player.resumeVideo(); } + Player.ResetTrickPlay(); Display.showProgress(); break; case tvKey.KEY_RETURN: @@ -797,13 +897,15 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function () { Main.log("STOP"); // Player.setWindow(); Player.stopVideo(); + widgetAPI.blockNavigation(event); + break; case tvKey.KEY_PAUSE: Main.log("PAUSE"); Player.pauseVideo(); break; - case tvKey.KEY_UP: +/* case tvKey.KEY_UP: case tvKey.KEY_PANEL_VOL_UP: case tvKey.KEY_VOL_UP: Main.log("VOL_UP"); @@ -820,7 +922,7 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function () { if(Main.mute == 0) Audio.setRelativeVolume(1); break; - +*/ default: Main.log("Calling Default Key Hanlder"); this.defaultKeyHandler.handleDefKeyDown(keyCode); @@ -828,64 +930,6 @@ cPlayStateKeyHndl.prototype.handleKeyDown = function () { } }; -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 @@ -945,12 +989,14 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function () { Player.stopVideo(); Display.setVideoList(Main.selectedVideo); Display.show(); + widgetAPI.blockNavigation(event); + break; case tvKey.KEY_PAUSE: Main.log("PAUSE"); break; - case tvKey.KEY_UP: +/* case tvKey.KEY_UP: case tvKey.KEY_PANEL_VOL_UP: case tvKey.KEY_VOL_UP: Main.log("VOL_UP"); @@ -967,7 +1013,7 @@ cLivePlayStateKeyHndl.prototype.handleKeyDown = function () { if(Main.mute == 0) Audio.setRelativeVolume(1); break; - +*/ default: this.defaultKeyHandler.handleDefKeyDown(keyCode); break; @@ -1020,7 +1066,7 @@ cMenuKeyHndl.prototype.handleKeyDown = function () { } break; - case tvKey.KEY_EXIT: +// case tvKey.KEY_EXIT: case tvKey.KEY_RETURN: case tvKey.KEY_PANEL_RETURN: if (Data.isRootFolder() == true) { @@ -1032,9 +1078,9 @@ cMenuKeyHndl.prototype.handleKeyDown = function () { Main.log("folderUp selectedVideo= " + Main.selectedVideo); Display.setVideoList(Main.selectedVideo); } - break; - + widgetAPI.blockNavigation(event); + break; case tvKey.KEY_DOWN: Main.log("DOWN"); Main.selectNextVideo(Main.DOWN); @@ -1069,7 +1115,29 @@ cSelectMenuKeyHndl.prototype.handleKeyDown = function () { Main.log(this.handlerName+": Key pressed: " + Main.getKeyCode(keyCode)); switch(keyCode) { - + case tvKey.KEY_1: + Main.log("KEY_1 pressed"); + this.select = 1; + Main.changeState (this.select); + break; + case tvKey.KEY_2: + Main.log("KEY_2 pressed"); + this.select = 2; + Main.changeState (this.select); + + break; + case tvKey.KEY_3: + Main.log("KEY_3 pressed"); + this.select = 3; + Main.changeState (this.select); + + break; + case tvKey.KEY_4: + Main.log("KEY_4 pressed"); + this.select = 4; + Main.changeState (this.select); + break; + case tvKey.KEY_ENTER: case tvKey.KEY_PLAY: case tvKey.KEY_PANEL_ENTER: @@ -1116,12 +1184,19 @@ cDefaulKeyHndl.prototype.handleDefKeyDown = function (keyCode) { switch(keyCode) { case tvKey.KEY_EXIT: - Main.log(this.handlerName +"Exit"); - Player.stopVideo(); - widgetAPI.sendReturnEvent(); + Main.log(this.handlerName +"Exit"); + if (Main.state != 0) { + Player.stopVideo(); + Main.changeState(0); + widgetAPI.blockNavigation(event); + } + else { + widgetAPI.sendReturnEvent(); + + } break; - case tvKey.KEY_VOL_UP: +/* case tvKey.KEY_VOL_UP: Main.log(this.handlerName + "VOL_UP"); Display.showVolume(); if(Main.mute == 0) @@ -1138,6 +1213,7 @@ cDefaulKeyHndl.prototype.handleDefKeyDown = function (keyCode) { Main.log(this.handlerName + "MUTE"); Main.muteMode(); break; +*/ default: Main.log(this.handlerName + "Unhandled key"); break; diff --git a/smarttv-client/Javascript/Player.js b/smarttv-client/Javascript/Player.js index 77f124c..ffdbf03 100755 --- a/smarttv-client/Javascript/Player.js +++ b/smarttv-client/Javascript/Player.js @@ -24,6 +24,9 @@ var Player = bufferState : 0, // buffer state in % + trickPlaySpeed : 1, // Multiple of 2 only. + trickPlayDirection : 1, + STOPPED : 0, PLAYING : 1, PAUSED : 2, @@ -153,16 +156,17 @@ Player.playVideo = function() { Display.showProgress(); this.state = this.PLAYING; -// if (this.plugin.InitPlayer(this.url) == false) -// Display.showPopup("InitPlayer returns false"); + if (this.plugin.InitPlayer(this.url) == false) + Display.showPopup("InitPlayer returns false"); Player.setBuffer(15000000.0); - + Player.ResetTrickPlay(); + Main.log ("StartPlayback for " + this.url); -// if (this.plugin.StartPlayback() == false) -// Display.showPopup("StartPlayback returns false"); + if (this.plugin.StartPlayback() == false) + Display.showPopup("StartPlayback returns false"); - this.plugin.Play( this.url ); +// this.plugin.Play( this.url ); Audio.plugin.SetSystemMute(false); } }; @@ -243,6 +247,71 @@ Player.skipBackwardVideo = function() { Display.showPopup("Jump Backward ret= " + ((res == true) ? "True" : "False")); }; +Player.fastForwardVideo = function() { + if (this.trickPlayDirection == 1) + this.trickPlaySpeed = this.trickPlaySpeed * 2; + else { + this.trickPlaySpeed = this.trickPlaySpeed / 2; + + if (this.trickPlaySpeed < 1) { + this.trickPlaySpeed = 1; + this.trickPlayDirection = -1; + } + + } + + 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) { + Display.showPopup("trick play returns false. Reset Trick-Play" ); + this.trickPlaySpeed = 1; + this.trickPlayDirection = 1; + } + +}; + +Player.RewindVideo = function() { + if (this.trickPlayDirection == 1) { + this.trickPlaySpeed = this.trickPlaySpeed / 2; + if (this.trickPlaySpeed < 1) { + this.trickPlaySpeed = 1; + this.trickPlayDirection = 1; + } + + } + else + this.trickPlaySpeed = this.trickPlaySpeed * 2; + + if (this.plugin.SetPlaybackSpeed(this.trickPlaySpeed * this.trickPlayDirection) == false) { + Display.showPopup("trick play returns false. Reset Trick-Play" ); + 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() { + if (this.trickPlaySpeed != 1) { + this.trickPlaySpeed = 1; + this.trickPlayDirection = 1; + Main.log("Reset Trickplay " ); + 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.getState = function() { return this.state; }; diff --git a/smarttv-client/config.xml b/smarttv-client/config.xml index e586334..3a5bc44 100755 --- a/smarttv-client/config.xml +++ b/smarttv-client/config.xml @@ -9,7 +9,7 @@ Images/icon/SmartTvWeb_115.png Images/icon/SmartTvWeb_85.png Images/icon/SmartTvWeb_95.png - 0.8 + 0.81 y y diff --git a/smarttv-client/index.html b/smarttv-client/index.html index 757468c..b4fea24 100755 --- a/smarttv-client/index.html +++ b/smarttv-client/index.html @@ -7,9 +7,11 @@ + + - + @@ -27,14 +29,14 @@ - + + - - + @@ -57,7 +59,6 @@
2: Recordings
3: Media
4: Options
-
5: DLNA
-- cgit v1.2.3