{
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;
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]);
$("#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));
}
}
+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";