Fix for NightMode, shrinking play button slightly to avoid overlap 95/10095/4 accepted/tizen/20130918.185209 accepted/tizen/20130918.214538 submit/tizen/20130918.001234
authorbrianjjones <brian.j.jones@intel.com>
Tue, 17 Sep 2013 22:56:00 +0000 (15:56 -0700)
committerbrianjjones <brian.j.jones@intel.com>
Tue, 17 Sep 2013 23:54:56 +0000 (16:54 -0700)
Change-Id: I0d288d1313891057f295d0b92bd1cd57fe380112
Signed-off-by: brianjjones <brian.j.jones@intel.com>
js/main.js
packaging/MediaPlayer.changes

index a66d956..467c698 100644 (file)
@@ -246,7 +246,7 @@ function fillMediaList(contentList)
 {
        console.log("MediaPlayer in fillMediaList");
        //Don't try and fill an empty content list or an audio list that hasn't finished loading the thumbnails
-       if (contentList === undefined || contentList === null || contentList.length <=0 || (contentList === audioContent && !imagesLoaded))
+       if (contentList === undefined || contentList === null || contentList.length <=0)
                return false;
 
        var iconURI;
@@ -359,7 +359,14 @@ function fillMediaList(contentList)
                switch (currentPlayerType)
                {
                case "AUDIO":
-                       currentCTX.drawImage(audioContent[i].coverArt, 0, 0, canvasH, canvasH );
+                       try
+                       {
+                               currentCTX.drawImage(audioContent[i].coverArt, 0, 0, canvasH, canvasH );
+                       }
+                       catch(err)
+                       {
+                               console.log("MediaPlayer: drawImage failed - " + err);
+                       }
                        console.log("contentList[i] = " + contentList[i]);
                        console.log("title = " + contentList[i].title);
                        console.log("artist = " + contentList[i].artists[0]);
@@ -936,7 +943,7 @@ function resizePlayerPage()
        $("#nextButton").css({"width": buttonWidth + "px", "height": buttonWidth + "px", "top": padding + "px", "left": ((screenWidth / 2) + (buttonWidth *2)) + "px"});
        $("#returnButton").css({"width": buttonWidth + "px", "height": buttonWidth + "px", "top": padding + "px", "left": padding + "px"});
        $("#listButton").css({"width": buttonWidth + "px", "height": buttonWidth + "px", "top": padding + "px", "left": (screenWidth - buttonWidth - padding * 2) + "px"});
-       $("#playButton").css({"width": buttonWidth * 1.3 + "px", "height": buttonWidth * 1.3 + "px", "top": padding * 0.3 + "px", "left": (screenWidth / 2) - (buttonWidth / 2) + "px"});
+       $("#playButton").css({"width": buttonWidth * 1.15 + "px", "height": buttonWidth * 1.15 + "px", "top": padding * 0.3 + "px", "left": (screenWidth / 2) - (buttonWidth / 2) + "px"});
 
        mediaNameCanvas.width = (screenWidth);
        mediaNameCanvas.height = (screenHeight * 0.34) - (buttonWidth + (2 * padding));
@@ -980,49 +987,67 @@ function swipe(direction, object)
        }
 }
 
+function toggleNightMode(nightModeValue)
+{
+       if (nightMode !== nightModeValue)
+       {
+               Array.prototype.forEach.call (document.querySelectorAll ('*'), function (el) {el.classList.toggle('night');});
+               nightMode = nightModeValue;
+       }
+}
+
 function init()
 {
        console.log("MediaPlayer in init");
-        var vehicle = tizen.vehicle;
+       var vehicle = tizen.vehicle;
 
 
        /* Subscribe to AMB NightMode signal, and switch colors
         * upon receipt of the signal
         */
 
-        vehicle.subscribe("NightMode",function(value) {
-                console.log("MediaPlayer: Day / Night mode changed to " + value.nightmode);
-
-               if (nightMode !== value.nightmode)
-                {
-                       Array.prototype.forEach.call (document.querySelectorAll ('*'), function (el) {el.classList.toggle('night');});
-                       nightMode = value.nightmode
-                }
-        });
-
-        /* Subscribe to AMB DrivingMode signal, and pause video
-         * upon receipt of the signal
-         */
-
-
-       vehicle.subscribe("DrivingMode",function(value) {
-                console.log("MediaPlayer: DrivingMode changed to " + value.drivingMode);
-
-                if (value.vehicleSpeed > 0 && currentPlayerType === "VIDEO" && !currentPlayerControls.paused)
-                {
-                        console.log("MediaPlayer: pausing video due to vehicle motion");
-                        currentPlayerControls.pause();
-                         waitingToResumeVideo = true;
-                }
-                else if (value.vehicleSpeed === 0 && currentPlayerType === "VIDEO" && waitingToResumeVideo)
-                {
-                        console.log("MediaPlayer: vehicle has stopped, resuming video");
-                        currentPlayerControls.play();
-                        waitingToResumeVideo = false;
-                }
+       if (vehicle && vehicle !== undefined)
+       {
+               var getVal = vehicle.get("NightMode");
 
-        });
+               //Check that NightMode returned a value before trying to hook up to it
+               if (getVal)
+               {
+                       toggleNightMode(getVal.nightMode);
+               }
 
+               /* Subscribe to AMB NightMode signal, and switch colors
+               * upon receipt of the signal
+               */
+
+               vehicle.subscribe("NightMode",function(value) {
+                                console.log("MediaPlayer: Day / Night mode changed to " + value.nightMode);
+                               toggleNightMode(value.nightMode);
+                });
+
+
+               /* Subscribe to AMB DrivingMode signal, and pause video
+                * upon receipt of the signal
+                */
+
+
+               vehicle.subscribe("DrivingMode",function(value) {
+                       console.log("MediaPlayer: DrivingMode changed to " + value.drivingMode);
+
+                       if (value.drivingMode > 0 && currentPlayerType === "VIDEO" && !currentPlayerControls.paused)
+                       {
+                               console.log("MediaPlayer: pausing video due to vehicle motion");
+                               currentPlayerControls.pause();
+                               waitingToResumeVideo = true;
+                       }
+                       else if (value.drivingMode === 0 && currentPlayerType === "VIDEO" && waitingToResumeVideo)
+                       {
+                               console.log("MediaPlayer: vehicle has stopped, resuming video");
+                               currentPlayerControls.play();
+                               waitingToResumeVideo = false;
+                       }
+               });
+       }
 
        musicIcon.src = "images/musicIcon.png";
        vidIcon.src = "images/videoIcon.png";
index 92def62..e87701d 100644 (file)
@@ -1,3 +1,6 @@
+* Tue Sep 17 2013 brianjjones <brian.j.jones@intel.com> submit/tizen/20130913.223432@5b6e998
+- Fix for NightMode, shrinking play button slightly to avoid overlap
+
 * Fri Sep 13 2013 brianjjones <brian.j.jones@intel.com> submit/tizen/20130913.011212@023d5e5
 - Adding DLNA browsing support. MediaPlayer will now show files found on remote servers