Adding a listener for DriverMode. If it receives a value > 0 it will pause playing... 89/9989/2 accepted/tizen/20130913.012038 accepted/tizen/20130913.012515 submit/tizen/20130913.011212
authorbrianjjones <brian.j.jones@intel.com>
Fri, 13 Sep 2013 00:35:21 +0000 (17:35 -0700)
committerbrianjjones <brian.j.jones@intel.com>
Fri, 13 Sep 2013 00:45:04 +0000 (17:45 -0700)
Change-Id: Iaecffe058d4fcd4640003669ceff23f3dd568eff
Signed-off-by: brianjjones <brian.j.jones@intel.com>
js/main.js
packaging/MediaPlayer.changes

index 46c3cdd..5c9776d 100644 (file)
@@ -42,7 +42,7 @@ var mediaNameCanvas;
 var mediaNameCTX;
 var speechObj;
 var nightMode = false;
-
+var waitingToResumeVideo = false;              //Media has been paused by exterior forces.  If set to true, resume previous media when given the signal.
 
 var mainMenuTitleTemplateLandscape = {"font" : "oblique bolder 30pt arial", "lineWidth" : 9.5, "fillStyle" : "black", "strokeStyle" : "white", "textAlign" : "left",
                "largeShadow" : 8, "shadowOffsetX" : 0, "shadowOffsetY" : 0, "shadowBlur" : 45, "shadowColor" : "rgba(255, 187, 0, 0.4)"};
@@ -84,6 +84,7 @@ function setupSpeech()
        console.log("MediaPlayer in setupSpeech");
 
        speechObj = tizen.speech;
+       speechObj.vocalizeString(" ");
 
        try
        {
@@ -572,6 +573,7 @@ function changeMenu(menuButtonId)
        switch(menuButtonId)
        {
        case ("mainMusicButton"):
+               speechObj.vocalizeString("Music player");
                currentMenu = "audio";
                currentPlayer = $("#audioPlayer");
                currentPlayerControls = document.getElementById("audioPlayer");
@@ -581,6 +583,7 @@ function changeMenu(menuButtonId)
        break;
 
        case ("mainVideoButton"):
+               speechObj.vocalizeString("Video player");
                currentMenu = "video";
                currentPlayer = $("#videoPlayer");
                currentPlayerControls = document.getElementById("videoPlayer");
@@ -590,6 +593,7 @@ function changeMenu(menuButtonId)
        break;
 
        case ("mainImageButton"):
+               speechObj.vocalizeString("Picture viewer");
                currentMenu = "image";
                currentPlayer = $("#imagePlayer");
                currentPlayerControls = imageControls;
@@ -950,7 +954,7 @@ function resizeAll()
 
 function swipe(direction, object)
 {
-console.log("MediaPlayer in swipe");
+       console.log("MediaPlayer in swipe");
        switch (object)
        {
        case "mediaName":
@@ -970,16 +974,45 @@ function init()
        console.log("MediaPlayer in init");
         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)
+               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;
+                }
+
+        });
+
+
        musicIcon.src = "images/musicIcon.png";
        vidIcon.src = "images/videoIcon.png";
        imgIcon.src = "images/imageIcon.png";
@@ -1000,7 +1033,10 @@ function init()
                console.log("MediaPlayer: No DLNA server running, using local media only...");
 
        //Setup voice control
-       setupSpeech();
+       if (tizen.speech)
+               setupSpeech();
+       else
+               console.log("MediaPlayer: Speech Recognition not running, voice control will be unavailable");
 
        //Get local media
        getMedia(contentType);
index 65805a7..05349ad 100644 (file)
@@ -1,3 +1,6 @@
+* Thu Sep 12 2013 brianjjones <brian.j.jones@intel.com> submit/tizen/20130909.164827@ee8af51
+- Adding a listener for DriverMode.  If it receives a value > 0 it will pause playing video.
+
 * Fri Sep 06 2013 brianjjones <brian.j.jones@intel.com> submit/tizen/20130830.191004@b8fe9bb
 - Use all available space for videos and images
 - Remove background image