Adding DLNA browsing support. MediaPlayer will now show files found on remote servers 20/10020/1 accepted/tizen/20130913.223251 accepted/tizen/20130913.223306 submit/tizen/20130913.223432
authorbrianjjones <brian.j.jones@intel.com>
Fri, 13 Sep 2013 22:29:12 +0000 (15:29 -0700)
committerbrianjjones <brian.j.jones@intel.com>
Fri, 13 Sep 2013 22:29:49 +0000 (15:29 -0700)
Change-Id: Ibf8f28e67e61869fb22fe9709f0dcc449a7f3dd1
Signed-off-by: brianjjones <brian.j.jones@intel.com>
js/dlna.js
js/main.js
packaging/MediaPlayer.changes

index d2f01d0..2a22bb8 100644 (file)
@@ -28,6 +28,8 @@ function convertMediaServerContent(item)
                if (item.Type.indexOf("video") == 0)
                {
                        content.type = "VIDEO";
+                       content.artists = new Array();
+                       content.artists[0] = "Unknown";
                        content.duration = item.Duration;
                        content.width = item.Width;
                        content.height = item.Height;
@@ -37,6 +39,10 @@ function convertMediaServerContent(item)
                item.Type.indexOf("music") == 0)
                {
                        content.type = "AUDIO";
+                       content.album = item.Album ? item.Album : "Unknown";
+                       content.coverArt = musicIcon;
+                       content.artists = new Array();
+                       content.artists[0] = item.Artist ? item.Artist : "Unknown";
                        content.bitrate = item.SampleRate;
                        content.duration = item.Duration;
                }
@@ -48,19 +54,14 @@ function convertMediaServerContent(item)
                        content.height = item.Height;
                        content.orientation = "NORMAL";
                }
-
        }
 
-       console.log(">>> Tizen Content >>> " + JSON.stringify(content));
        return content;
 }
 
-/* example below displays the first picture found on the first media player available */
-/************************************** DLNA sample code ****************************************/
-
 function browseCallback(medias)
 {
-       console.log("MediaServer browseCallback");
+       console.log("MediaPlayer: MediaServer has called browseCallback");
        console.log("found " + medias.length + " medias.");
 
        for (var i=0; i<medias.length; i++)
@@ -71,31 +72,53 @@ function findAllCallback(medias)
 {
        console.log("MediaServer findAllCallback");
        console.log("found " + medias.length + " medias.");
-       var content = [];
+
+       var itemsAdded = 0;
 
        for (var i=0; i < medias.length; i++)
        {
                var current = convertMediaServerContent(medias[i]);
 
-               if (current.type == "IMAGE")
-                       content.push(current);
-               else
-                       console.log("BJONES failed to push content, not == IMAGE");
+               if (current)
+               {
+               switch(current.type)
+               {
+                       case "AUDIO":
+                               console.log("MediaPlayer: Remote server found audio " + current);
+                               audioContent.push(current);
+                               console.log("MediaPlayer: Remote added audiocontent now = " + audioContent);
+                               itemsAdded += 1;
+                               break;
+                       case "VIDEO":
+                               console.log("MediaPlayer: Remote server found video " + current);
+                               videoContent.push(current);
+                               console.log("MediaPlayer: Remote added videocontent now = " + videoContent);
+                               itemsAdded += 1;
+                               break;
+                       case "IMAGE":
+                               console.log("MediaPlayer: Remote server found image " + current);
+                               imageContent.push(current);
+                               console.log("MediaPlayer: Remote added imagecontent now = " + imageContent);
+                               itemsAdded += 1;
+                               break;
+                       default:
+                               console.log("MediaPlayer: Remote media failed to push content, not == AUDIO/VIDEO/IMAGE");
+               }
+               }
        }
 
-       imageContent = content;
-       console.log("MediaPlayer image content changed, added " + content.length + " new items");
+       fillMediaList(audioContent);
 }
 
 function foundMediaServer(srv)
 {
-       console.log("New MediaServer Found");
+       console.log("MediaPlayer: New MediaServer Found");
        console.log("MediaServer id: " + srv.id);
        console.log("MediaServer friendlyName: " + srv.friendlyName);
 
        if (srv.root)
        {
-               console.log("MediaServer root folder: " + srv.root.id);
+               console.log("MediaPlayer: MediaServer root folder: " + srv.root.id);
                srv.browse(srv.root.id, "+DisplayName", 0, 0, browseCallback);
                srv.find(srv.root.id, "*", "+DisplayName", 0, 0, findAllCallback);
        }
index 5c9776d..a66d956 100644 (file)
@@ -16,9 +16,9 @@ var screenOrientation;
 var iconWidth;
 var padding;
 var contentType = "AUDIO";
-var audioContent;
-var videoContent;
-var imageContent;
+var audioContent = new Array();
+var videoContent = new Array();
+var imageContent = new Array();
 var currentContent;
 var currentPlayer;
 var currentPlayerType = "AUDIO";
@@ -360,11 +360,17 @@ function fillMediaList(contentList)
                {
                case "AUDIO":
                        currentCTX.drawImage(audioContent[i].coverArt, 0, 0, canvasH, canvasH );
+                       console.log("contentList[i] = " + contentList[i]);
+                       console.log("title = " + contentList[i].title);
+                       console.log("artist = " + contentList[i].artists[0]);
                        var trackText = new TextObject(currentCTX,{"text" : contentList[i].title, "xLoc" : canvasH + 20, "yLoc" : canvasH / 2.5 , "zLoc" : 0});
                        var artistText = new TextObject(currentCTX,{"text" : contentList[i].artists[0], "xLoc" : canvasH + 20, "yLoc" : canvasH / 1.1 , "zLoc" : 0});
 
                        break;
                case "VIDEO":
+                        console.log("contentList[i] = " + contentList[i]);
+                        console.log("title = " + contentList[i].title);
+                        console.log("artist = " + contentList[i].artists[0]);
                        currentCTX.drawImage(vidIcon, 0, 0, canvasH, canvasH );
                        var artistText = new TextObject(currentCTX,{"text" : contentList[i].artists[0], "xLoc" : canvasH + 20, "yLoc" : canvasH / 2.5 , "zLoc" : 0});
                        var trackText = new TextObject(currentCTX,{"text" : contentList[i].title, "xLoc" : canvasH + 20, "yLoc" : canvasH / 1.1 , "zLoc" : 0});
@@ -416,7 +422,8 @@ function onContentItemArraySuccess(content)
                        {
                                try
                                {
-                                       audioContent = content;
+                                       audioContent = audioContent.concat(content);
+                                       console.log("MediaPlayer: AudioContent added local, now has = " + audioContent);
                                        sortByAlpha(audioContent);
 
                                        $("#audioSrc").attr("src", audioContent[0].contentURI);
@@ -445,7 +452,8 @@ function onContentItemArraySuccess(content)
        case "VIDEO":
                if (!emptyContent)
                {
-                       videoContent = content;
+                       videoContent = videoContent.concat(content);
+                       console.log("MediaPlayer: VideoContent added local, now has = " + videoContent);
                        $("#videoSrc").attr("src", videoContent[0].contentURI);
                }
                contentType = "IMAGE";
@@ -454,7 +462,8 @@ function onContentItemArraySuccess(content)
        case "IMAGE":
                if (!emptyContent)
                {
-                       imageContent = content;
+                       imageContent = imageContent.concat(content);
+                       console.log("MediaPlayer: ImageContent added local, now has = " + imageContent);
                        $("#imagePlayer").css("background", "url(" + imageContent[0].contentURI + ") no-repeat center");
                        $("#imagePlayer").css("background-size", "contain");
                }
@@ -535,7 +544,6 @@ function showMediaList()
                $("#mediaList").fadeOut(300);
        else
        {
-               fillMediaList(currentContent);
                $("#mediaList").fadeIn(300);
        }
 }
@@ -579,6 +587,7 @@ function changeMenu(menuButtonId)
                currentPlayerControls = document.getElementById("audioPlayer");
                currentPlayerType = "AUDIO";
                currentContent = audioContent;
+               fillMediaList(currentContent);
                showMediaMenu();
        break;
 
@@ -589,6 +598,7 @@ function changeMenu(menuButtonId)
                currentPlayerControls = document.getElementById("videoPlayer");
                currentPlayerType = "VIDEO";
                currentContent = videoContent;
+               fillMediaList(currentContent);
                showMediaMenu();
        break;
 
@@ -599,6 +609,7 @@ function changeMenu(menuButtonId)
                currentPlayerControls = imageControls;
                currentPlayerType = "IMAGE";
                currentContent = imageContent;
+               fillMediaList(currentContent);
                showMediaMenu();
        break;
        default:
index 05349ad..92def62 100644 (file)
@@ -1,3 +1,6 @@
+* 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
+
 * 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.