2 * Copyright (c) 2013, Intel Corporation.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 var currentMenu = "main";
12 var resizeCB = resizeMainMenu;
15 var screenOrientation;
18 var contentType = "AUDIO";
19 var audioContent = new Array();
20 var videoContent = new Array();
21 var imageContent = new Array();
24 var currentPlayerType = "AUDIO";
25 var currentMediaList = $("#audioMediaList");
26 var currentMediaListItems = $("#audioMediaListItems");
27 var currentPlayerControls;
28 var audioMediaListLoaded = false;
29 var videoMediaListLoaded = false;
30 var imageMediaListLoaded = false;
36 var vidIcon = new Image();
37 var imgIcon = new Image();
38 var musicIcon = new Image();
39 var imagesLoaded = false;
43 var loadAndPlay = false;
44 var currentFileLoaded = false;
48 var nightMode = false;
49 var waitingToResumeVideo = false; //Media has been paused by exterior forces. If set to true, resume previous media when given the signal.
52 var mainMenuTitleTemplateLandscape = {"font" : "oblique bolder 30pt arial", "lineWidth" : 9.5, "fillStyle" : "black", "strokeStyle" : "white", "textAlign" : "left",
53 "largeShadow" : 8, "shadowOffsetX" : 0, "shadowOffsetY" : 0, "shadowBlur" : 45, "shadowColor" : "rgba(255, 187, 0, 0.4)"};
55 var mainMenuTitleTemplate = {"font" : "oblique bolder 40pt arial", "lineWidth" : 9.5, "fillStyle" : "black", "strokeStyle" : "white", "textAlign" : "left",
56 "largeShadow" : 8, "shadowOffsetX" : 0, "shadowOffsetY" : 0, "shadowBlur" : 45, "shadowColor" : "rgba(255, 187, 0, 0.4)"};
58 var mainTrackTemplateLandscape = {"font" : "bold 20pt Arial", "lineWidth" : 7.5, "fillStyle" : "black", "strokeStyle" : "white", "textAlign" : "left",
59 "largeShadow" : 8, "shadowOffsetX" : 0, "shadowOffsetY" : 0, "shadowBlur" : 45, "shadowColor" : "rgba(255, 187, 0, 0.5))"};
61 var mainTrackTemplate = {"font" : "bold 30pt Arial", "lineWidth" : 7.5, "fillStyle" : "black", "strokeStyle" : "white", "textAlign" : "left",
62 "largeShadow" : 8, "shadowOffsetX" : 0, "shadowOffsetY" : 0, "shadowBlur" : 45, "shadowColor" : "rgba(255, 187, 0, 0.5))"};
64 var mediaTextTemplate2 = {"font" : "bold 20pt Arial", "lineWidth" : 10.0, "fillStyle" : "white", "strokeStyle" : "rgba(0, 0, 0, 1.0)", "textAlign" : "left",
65 "shadowOffsetX" : 0, "shadowOffsetY" : 0, "shadowBlur" : 0, "shadowColor" : "rgba(0, 0, 0, 1.0)"};
67 var mediaTextTemplate3 = {"font" : "bold 20pt Arial", "lineWidth" : 3.0, "fillStyle" : "white", "strokeStyle" : "rgba(100, 0, 0, 1.0)", "textAlign" : "left"};
69 var trackTextTemplate = {"font" : "bold 16pt Arial", "lineWidth" : 3.0, "fillStyle" : "white", "strokeStyle" : "black", "textAlign" : "left"};
71 var mediaTextTemplate2Landscape = {"font" : "bold 15pt Arial", "lineWidth" : 10.0, "fillStyle" : "white", "strokeStyle" : "rgba(0, 0, 0, 1.0)", "textAlign" : "left",
72 "shadowOffsetX" : 0, "shadowOffsetY" : 0, "shadowBlur" : 0, "shadowColor" : "rgba(0, 0, 0, 1.0)"};
74 var mediaTextTemplate3Landscape = {"font" : "bold 15pt Arial", "lineWidth" : 3.0, "fillStyle" : "white", "strokeStyle" : "rgba(100, 0, 0, 1.0)", "textAlign" : "left"};
76 var trackTextTemplateLandscape = {"font" : "bold 11pt Arial", "lineWidth" : 3.0, "fillStyle" : "white", "strokeStyle" : "black", "textAlign" : "left"};
79 var mediaTextTemplate = {"font" : "bold 20pt Arial", "fillStyle" : "", "textAlign" : "left",
80 "shadowOffsetX" : 0, "shadowOffsetY" : 0, "shadowBlur" : 12, "shadowColor" : "red"};
84 console.log("Content discovery failed");
87 function setupSpeech()
89 console.log("MediaPlayer in setupSpeech");
91 speechObj = tizen.speech;
92 speechObj.vocalizeString(" ");
96 var speechEventListener = {
97 onaudiostart: function(){console.log("MediaPlayer: onaudiostart received");},
98 onsoundstart: function(){console.log("MediaPlayer: onsoundstart received");},
99 onspeechstart: function(){console.log("MediaPlayer: onspeechstart received");},
100 onspeechend: function(){console.log("MediaPlayer: onspeechend received");},
101 onsoundend: function(){console.log("MediaPlayer: onsoundend received");},
102 onaudioend: function(){console.log("MediaPlayer: onaudioend received");},
103 onresult: function(result){
105 console.log("MediaPlayer: onresult received");
107 for (var i = 0; i < result.length; i++)
109 console.log("MediaPlayer: forloop, command = " + result[i]);
110 var commandFound = false;
139 onnomatch: function(result){console.log("MediaPlayer: onnomatch received ");},
140 onerror: function(error){console.log("MediaPlayer: onerror received");},
141 onstart: function(){console.log("MediaPlayer: onstart received");},
142 onend: function(){console.log("MediaPlayer: onend received");}
145 speechObj.setCBListener(speechEventListener);
150 console.log("MediaPlayer setupSpeech FAILED + " + err.message);
155 function updateMediaName(newArtist, newTitle, newCover)
157 if (currentMenu === "audio")
159 var playBarHeight = mediaNameCanvas.height;
160 var boxWidth = playBarHeight * 0.75;
161 mediaNameCTX.clearRect(0,0,mediaNameCanvas.width, mediaNameCanvas.height);
163 if (currentPlayerType === "AUDIO")
166 var alphaJump = 0.01;
170 mediaNameCTX.fillStyle="rgba(30,30,30,0.5)";
171 mediaNameCTX.strokeStyle="rgba(130,130,130,1)";
172 mediaNameCTX.lineWidth = 5;
173 mediaNameCTX.fillRect(0,0,mediaNameCanvas.width, playBarHeight);
174 mediaNameCTX.strokeRect(-20,0,mediaNameCanvas.width + 40, playBarHeight);
176 if (newCover === undefined || newCover.naturalWidth === undefined || newCover.naturalWidth <= 0)
178 newCover = musicIcon;
181 mediaNameCTX.drawImage(newCover, 20, (playBarHeight - boxWidth) / 2, boxWidth, boxWidth);
183 if (screenOrientation === "portrait")
185 var textStartX = boxWidth + 50;
187 var trackText = new TextObject(mediaNameCTX,{"text" : newTitle, "xLoc" : textStartX, "yLoc" : 70 , "zLoc" : 0,
188 "width" : mediaNameCanvas.width - textStartX, "height" : 50, "lineHeight" : 65, "wordWrap" : true});
189 trackText.applyTemplate(mainMenuTitleTemplate);
191 var artistText = new TextObject(mediaNameCTX,{"text" : newArtist, "xLoc" : textStartX, "yLoc" : 70, "zLoc" : 0,
192 "width" : mediaNameCanvas.width - textStartX, "height" : 50, "lineHeight" : 50, "wordWrap" : true});
193 artistText.applyTemplate(mainTrackTemplate);
197 var textStartX = boxWidth + 50;
198 var trackText = new TextObject(mediaNameCTX,{"text" : newTitle, "xLoc" : textStartX, "yLoc" : 50 , "zLoc" : 0,
199 "width" : mediaNameCanvas.width - textStartX, "height" : 30, "lineHeight" : 30, "wordWrap" : true});
200 trackText.applyTemplate(mainMenuTitleTemplateLandscape);
201 var artistText = new TextObject(mediaNameCTX,{"text" : newArtist, "xLoc" : textStartX, "yLoc" : 50, "zLoc" : 0,
202 "width" : mediaNameCanvas.width - textStartX, "height" : 30, "lineHeight" : 30, "wordWrap" : true});
203 artistText.applyTemplate(mainTrackTemplateLandscape);
207 trackText.drawLargeShadow();
209 artistText.yLoc += trackText.height;
210 artistText.drawObj();
215 function onContentItemArraySuccess(content)
217 console.log("MediaPlayer in onContentItemArraySuccess");
218 var emptyContent = true;
220 if (!content || content === undefined || content.length <= 0)
221 console.log("Invalid content for " + contentType);
224 emptyContent = false;
235 audioContent = audioContent.concat(content);
237 $("#audioSrc").attr("src", audioContent[0].contentURI);
241 for (var i = 0; i < audioContent.length; i++)
243 var iconURI = (audioContent[i].thumbnailURIs !== undefined && audioContent[i].thumbnailURIs !== null) ? audioContent[i].thumbnailURIs[0] : "images/musicIcon.png";
244 audioContent[i].coverArtURI = iconURI;
249 audioMediaListLoaded = true;
250 currentMediaListItems = $("#audioMediaListItems");
251 fillMediaList(audioContent);
256 console.log("Error when parsing audioContent");
260 contentType = "VIDEO";
266 videoContent = videoContent.concat(content);
267 $("#videoSrc").attr("src", videoContent[0].contentURI);
269 contentType = "IMAGE";
275 imageContent = imageContent.concat(content);
276 $("#imagePlayer").css("background", "url(" + imageContent[0].contentURI + ") no-repeat center");
277 $("#imagePlayer").css("background-size", "contain");
279 contentType = undefined;
283 console.log("Undefined content search type");
284 nextContentType = undefined;
288 if (contentType !== undefined)
289 getMedia(contentType);
292 function getMedia(mediaType)
294 console.log("MediaPlayer in getMedia");
295 var manager = tizen.content;
297 var filter = new tizen.AttributeFilter("type", "EXACTLY", mediaType);
298 manager.find(onContentItemArraySuccess, onError, null, filter);
301 function showMediaMenu()
303 console.log("MediaPlayer in showMediaMenu");
304 $(".navButton").fadeIn(800);
306 switch(currentPlayerType)
312 if (audioContent.length > 0)
313 updateMediaName(audioContent[audioIndex].artists[0], audioContent[audioIndex].title, audioContent[audioIndex].coverArt);
317 console.log("updateMediaName failed for showMediaMenu (audio) : " + err.message);
320 $("#mediaName").fadeIn(800);
321 $(".sortButton").fadeIn(800);
322 currentPlayer.fadeIn(800);
324 if (screenOrientation === "landscape" )
325 $("#audioMediaList").addClass("landscape");
327 $("#audioMediaList").removeClass("landscape");
329 $("#audioMediaList").fadeIn(800);
334 setTimeout(function(){currentPlayer.show()}, 800); //The video element can't be faded, so wait a moment before showing
339 currentPlayer.fadeIn(800);
343 console.log("Invalid player type");
348 function showMediaList()
350 console.log("MediaPlayer in showMediaList");
352 if (currentMediaList.is(":visible"))
353 currentMediaList.fadeOut(300);
356 currentMediaList.fadeIn(300);
360 function changeMenu(menuButtonId)
362 console.log("MediaPlayer in changeMenu");
363 var clickedButton = $("#" + menuButtonId);
364 var buttonWidth = clickedButton.width();
365 var buttonHeight = clickedButton.height();
366 var buttonBottom = clickedButton.css("bottom");
367 var buttonRight = clickedButton.css("right");
369 //Animate the clicked button slightly
370 clickedButton.animate({
371 bottom: screenOrientation === "portrait" ? "+=0" : "+=50",
372 right: screenOrientation === "portrait" ? "+=50" : "+=0",
376 //Reset the size once done
378 clickedButton.width(buttonWidth);
379 clickedButton.height(buttonHeight);
381 if (screenOrientation === "portrait")
382 clickedButton.css({"right": buttonRight});
384 clickedButton.css({"bottom": buttonBottom});
388 $(".mainButton").fadeOut(300);
392 case ("mainMusicButton"):
393 speechObj.vocalizeString("Music player");
394 currentMenu = "audio";
395 currentPlayer = $("#audioPlayer");
396 currentPlayerControls = document.getElementById("audioPlayer");
397 currentPlayerType = "AUDIO";
398 currentMediaList = $("#audioMediaList");
399 currentMediaListItems = $("#audioMediaListItems");
400 currentContent = audioContent;
402 if (!audioMediaListLoaded)
403 fillMediaList(currentContent);
408 case ("mainVideoButton"):
409 speechObj.vocalizeString("Video player");
410 currentMenu = "video";
411 currentPlayer = $("#videoPlayer");
412 currentPlayerControls = document.getElementById("videoPlayer");
413 currentPlayerType = "VIDEO";
414 currentMediaList = $("#videoMediaList");
415 currentMediaListItems = $("#videoMediaListItems");
416 currentContent = videoContent;
418 if (!videoMediaListLoaded)
419 fillMediaList(currentContent);
424 case ("mainImageButton"):
425 speechObj.vocalizeString("Picture viewer");
426 currentMenu = "image";
427 currentPlayer = $("#imagePlayer");
428 currentPlayerControls = imageControls;
429 currentPlayerType = "IMAGE";
430 currentMediaList = $("#imageMediaList");
431 currentMediaListItems = $("#imageMediaListItems");
432 currentContent = imageContent;
434 if (!imageMediaListLoaded)
435 fillMediaList(currentContent);
440 console.log("Error: No menu by that name");
445 function showMainMenu()
447 console.log("MediaPlayer in showMainMenu");
448 currentMenu = "main";
449 currentPlayerControls.pause();
451 //If the media list is showing, hide it. Remove the mediaListAudioList class if it exists so that it will resize properly
452 if (currentMediaList.is(":visible"))
453 currentMediaList.fadeOut(300);
455 $(".navButton").fadeOut(300);
456 $(".sortButton").fadeOut(300);
457 $("#mediaName").fadeOut(300);
459 if (currentPlayerType !== "VIDEO")
460 currentPlayer.fadeOut(300);
462 currentPlayer.hide();
465 $(".mainButton").css({"opacity": "100"});
466 $(".mainButton").fadeIn(800);
469 function sortByAlpha(contentToSort)
471 console.log("MediaPlayer in sortByAlpha");
473 if (currentPlayerType === "AUDIO")
476 //If contentToSort is undefined it's because the request came from the sortBy buttons
477 if (contentToSort === undefined)
478 contentToSort = audioContent;
480 contentToSort.sort(function (a,b) {
481 var first = a.title.toLowerCase();
482 var second = b.title.toLowerCase();
492 fillMediaList(contentToSort);
495 function sortByArtist(contentToSort)
497 console.log("MediaPlayer in sortByArtist");
499 if (currentPlayerType === "AUDIO")
502 if (contentToSort === undefined)
503 contentToSort = audioContent;
505 contentToSort.sort(function (a,b) {
506 var first = a.artists[0].toLowerCase();
507 var second = b.artists[0].toLowerCase();
517 fillMediaList(contentToSort);
520 function sortByAlbum(contentToSort)
522 if (currentPlayerType === "AUDIO")
525 console.log("MediaPlayer in sortByAlbum");
526 if (contentToSort === undefined)
527 contentToSort = audioContent;
529 contentToSort.sort(function (a,b) {
530 var first = a.album.toLowerCase();
531 var second = b.album.toLowerCase();
541 fillMediaList(contentToSort);
544 /**************************************** NAVIGATION FUNCTIONS *******************************************/
546 // This function is called once a file being loaded is ready to play
547 function playLoadedMedia()
549 console.log("MediaPlayer in playLoadedMedia");
550 currentFileLoaded = true;
554 currentPlayerControls.play();
559 function playButtonClick()
561 console.log("MediaPlayer in playButtonClick");
562 if (currentPlayerType !== "AUDIO" || currentFileLoaded)
564 if (currentPlayerControls.paused)
566 currentPlayerControls.play();
570 currentPlayerControls.pause();
574 console.log(audioContent[audioIndex].artists[0] + " : " + audioContent[audioIndex].title + " can't play yet, it hasn't loaded");
577 function pauseButtonClick()
579 console.log("MediaPlayer in pauseButtonClick");
580 if (!currentPlayerControls.paused)
582 currentPlayerControls.pause();
586 function backButtonClick()
588 console.log("MediaPlayer in backButtonClick");
589 switch (currentPlayerType)
597 audioIndex = audioContent.length - 1;
602 $("#audioSrc").attr("src", audioContent[audioIndex].contentURI);
603 updateMediaName(audioContent[audioIndex].artists[0], audioContent[audioIndex].title, audioContent[audioIndex].coverArt);
614 videoIndex = videoContent.length - 1;
617 $("#videoSrc").attr("src", videoContent[videoIndex].contentURI);
628 imageIndex = imageContent.length - 1;
630 $("#imagePlayer").css("background", "url(" + imageContent[imageIndex].contentURI + ") no-repeat center");
631 $("#imagePlayer").css("background-size", "contain");
636 console.log("Content failure");
642 function nextButtonClick()
644 console.log("MediaPlayer in nextButtonClick");
645 switch (currentPlayerType)
650 if (audioContent.length > (audioIndex + 1))
658 $("#audioSrc").attr("src", audioContent[audioIndex].contentURI);
659 updateMediaName(audioContent[audioIndex].artists[0], audioContent[audioIndex].title, audioContent[audioIndex].coverArt);
667 if (videoContent.length > (videoIndex + 1))
673 $("#videoSrc").attr("src", videoContent[videoIndex].contentURI);
681 if (imageContent.length > (imageIndex + 1))
686 $("#imagePlayer").css("background", "url(" + imageContent[imageIndex].contentURI + ") no-repeat center");
687 $("#imagePlayer").css("background-size", "contain");
692 console.log("Content failure");
697 /**************************************** END NAVIGATION FUNCTIONS *******************************************/
699 function resizeMainMenu()
701 console.log("MediaPlayer in resizeMainMenu");
703 currentMediaList.fadeOut(0);
704 screenWidth = window.innerWidth;
705 screenHeight = window.innerHeight;
706 screenOrientation = screenWidth < screenHeight ? "portrait" : "landscape";
707 iconWidth = screenOrientation === "portrait" ? screenHeight / 4 : screenWidth / 4;
710 $(".mainButton").width(iconWidth + "px");
711 $(".mainButton").height(iconWidth + "px");
713 var iconsTop = screenOrientation === "portrait" ? ((screenHeight - (iconWidth * 3)) / 2) - (padding * 3) : (screenHeight - iconWidth) / 2;
715 if (screenOrientation === "portrait")
716 $("#mainMenuButtons").css({"top": iconsTop + "px", "left" : (screenWidth / 2) - (iconWidth /2) - padding + "px", "width" : "50%"});
719 $("#mainMenuButtons").css({"top": iconsTop + "px", "left" : ((iconWidth / 2) - (padding * 3)) + "px", "width" : "100%"});
720 $("#sortButtons").addClass("landscape");
724 function resizePlayerPage()
726 console.log("MediaPlayer in resizePlayerPage");
728 audioPlayer = document.getElementById("audioPlayer");
729 videoPlayer = document.getElementById("videoPlayer");
730 screenWidth = window.innerWidth;
731 screenHeight = window.innerHeight;
734 var buttonWidth = screenOrientation === "portrait" ? screenHeight * 0.05 : screenWidth * 0.05;
736 $("#backButton").css({"width": buttonWidth + "px", "height": buttonWidth + "px", "top": padding + "px", "left": ((screenWidth / 2) - (buttonWidth *3)) + "px"});
737 $("#nextButton").css({"width": buttonWidth + "px", "height": buttonWidth + "px", "top": padding + "px", "left": ((screenWidth / 2) + (buttonWidth *2)) + "px"});
738 $("#returnButton").css({"width": buttonWidth + "px", "height": buttonWidth + "px", "top": padding + "px", "left": padding + "px"});
739 $("#listButton").css({"width": buttonWidth + "px", "height": buttonWidth + "px", "top": padding + "px", "left": (screenWidth - buttonWidth - padding * 2) + "px"});
740 $("#playButton").css({"width": buttonWidth * 1.15 + "px", "height": buttonWidth * 1.15 + "px", "top": padding * 0.3 + "px", "left": (screenWidth / 2) - (buttonWidth / 2) + "px"});
742 mediaNameCanvas.width = (screenWidth);
743 mediaNameCanvas.height = (screenHeight * 0.34) - (buttonWidth + (2 * padding));
744 mediaNameCanvas.style.top = (buttonWidth + (2 * padding) ) + "px";
745 mediaNameCanvas.style.left = "0px";
747 var sortButtonTop = (buttonWidth + (2 * padding) ) + mediaNameCanvas.height - (buttonWidth * 1.3);
748 var sortButtonWidth = buttonWidth * 2.5;
749 var buttonSpacing = screenWidth / 5;
751 mediaListItemW = $("#videoMediaList").width() * 0.92;
752 mediaListItemH = $("#videoMediaList").height() / 10;
757 console.log("MediaPlayer in resizeAll");
763 * swipe - Handles swipe events. Currently it just acts as another way to hit the next / back buttons, but
764 * it could be expanded to other things in the future.
767 function swipe(direction, object)
769 console.log("MediaPlayer in swipe");
773 if (direction === "right")
775 else if (direction === "left")
784 function toggleNightMode(nightModeValue)
786 if (nightMode !== nightModeValue)
788 Array.prototype.forEach.call (document.querySelectorAll ('*'), function (el) {el.classList.toggle('night');});
789 nightMode = nightModeValue;
795 console.log("MediaPlayer in init");
796 var vehicle = tizen.vehicle;
799 /* Subscribe to AMB NightMode signal, and switch colors
800 * upon receipt of the signal
803 if (vehicle && vehicle !== undefined)
805 var getVal = vehicle.get("NightMode");
807 //Check that NightMode returned a value before trying to hook up to it
810 toggleNightMode(getVal.nightMode);
813 /* Subscribe to AMB NightMode signal, and switch colors
814 * upon receipt of the signal
817 vehicle.subscribe("NightMode",function(value) {
818 console.log("MediaPlayer: Day / Night mode changed to " + value.nightMode);
819 toggleNightMode(value.nightMode);
823 /* Subscribe to AMB DrivingMode signal, and pause video
824 * upon receipt of the signal
828 vehicle.subscribe("DrivingMode",function(value) {
829 console.log("MediaPlayer: DrivingMode changed to " + value.drivingMode);
831 if (value.drivingMode > 0 && currentPlayerType === "VIDEO" && !currentPlayerControls.paused)
833 console.log("MediaPlayer: pausing video due to vehicle motion");
834 currentPlayerControls.pause();
835 waitingToResumeVideo = true;
837 else if (value.drivingMode === 0 && currentPlayerType === "VIDEO" && waitingToResumeVideo)
839 console.log("MediaPlayer: vehicle has stopped, resuming video");
840 currentPlayerControls.play();
841 waitingToResumeVideo = false;
846 musicIcon.src = "images/musicIcon.png";
847 vidIcon.src = "images/videoIcon.png";
848 imgIcon.src = "images/imageIcon.png";
849 imageControls = new ImageControls();
851 mediaNameCanvas = document.getElementById("mediaName");
852 mediaNameCTX = mediaNameCanvas.getContext("2d");
854 //Resize all items and search for local media
857 //Check if DLNA plugin is installed. If so, scan for media.
858 if (tizen.mediaserver)
860 //Currently no success signal, so continue trying until a server is found. Once that
861 //happens, clear the stopServerSearch interval
863 stopServerSearch = setInterval(function(){console.log("MediaPlayer searching for remote media..."); tizen.mediaserver.scanNetwork(foundMediaServer);}, 5000);
866 console.log("MediaPlayer: No DLNA server running, using local media only...");
868 //Setup voice control
872 console.log("MediaPlayer: Speech Recognition not running, voice control will be unavailable");
875 setTimeout(function(){getMedia(contentType);}, 500);
877 //Prevent highlighting
878 window.ondragstart = function() { return false; }
880 $(window).bind('resize', resizeAll);
882 //Simple swipe detection
883 $("#mediaName").mousedown(function(e){mouseDownEvent = e;});
884 $("#mediaName").mouseup(function(e){
885 if (Math.abs(mouseDownEvent.clientY - e.clientY) < 100)
887 if (Math.abs(mouseDownEvent.clientX - e.clientX) > 100)
889 if (mouseDownEvent.clientX > e.clientX)
890 swipe("left", "mediaName");
892 swipe("right", "mediaName");
897 document.getElementById('videoPlayer').addEventListener("playing", function() {
898 $("#playButton").toggleClass('playing', true);
899 $("#navigationButtons").hide();
901 document.getElementById('videoPlayer').addEventListener("pause", function() {
902 $("#playButton").toggleClass('playing', false);
903 $("#navigationButtons").show();
905 document.getElementById('videoPlayer').addEventListener("ended", function() {
906 $("#playButton").toggleClass('playing', false);
907 $("#navigationButtons").show();
909 document.getElementById('audioPlayer').addEventListener("playing", function() {
910 $("#playButton").toggleClass('playing', true);
912 document.getElementById('audioPlayer').addEventListener("pause", function() {
913 $("#playButton").toggleClass('playing', false);
915 document.getElementById('audioPlayer').addEventListener("ended", function() {
916 $("#playButton").toggleClass('playing', false);
918 document.getElementById('imagePlayer').addEventListener("click", function() {
919 if (imageControls.paused)
926 // pause the slideshow and fade in the controls
927 imageControls.pause();
928 $("#navigationButtons").show();
933 $(document).ready(function () {