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 function convertMediaServerContent(item)
12 console.log(">>> MediaObject2 >>> " + JSON.stringify(item));
13 var content = { id: item.Path, title: item.DisplayName };
15 if (item.Type.indexOf("container") == 0)
17 content.directoryURI = "";
18 content.storageType = "EXTERNAL";
22 content.editableAttributes = [];
23 content.name = content.title;
24 content.contentURI = item.URLs[0];
25 content.mimeType = item.MIMEType;
26 content.size = item.Size;
28 if (item.Type.indexOf("video") == 0)
30 content.type = "VIDEO";
31 content.artists = new Array();
32 content.artists[0] = "Unknown";
33 content.duration = item.Duration;
34 content.width = item.Width;
35 content.height = item.Height;
38 else if (item.Type.indexOf("audio") == 0 ||
39 item.Type.indexOf("music") == 0)
41 content.type = "AUDIO";
42 content.album = item.Album ? item.Album : "Unknown";
43 content.coverArt = musicIcon;
44 content.artists = new Array();
45 content.artists[0] = item.Artist ? item.Artist : "Unknown";
46 content.bitrate = item.SampleRate;
47 content.duration = item.Duration;
50 if (item.Type.indexOf("image") == 0)
52 content.type = "IMAGE";
53 content.width = item.Width;
54 content.height = item.Height;
55 content.orientation = "NORMAL";
62 function browseCallback(medias)
64 console.log("MediaPlayer: MediaServer has called browseCallback");
65 console.log("found " + medias.length + " medias.");
67 for (var i=0; i<medias.length; i++)
68 convertMediaServerContent(medias[i]);
71 function findAllCallback(medias)
73 console.log("MediaServer findAllCallback");
74 console.log("found " + medias.length + " medias.");
78 for (var i=0; i < medias.length; i++)
80 var current = convertMediaServerContent(medias[i]);
87 console.log("MediaPlayer: Remote server found audio " + current);
88 audioContent.push(current);
89 console.log("MediaPlayer: Remote added audiocontent now = " + audioContent);
93 console.log("MediaPlayer: Remote server found video " + current);
94 videoContent.push(current);
95 console.log("MediaPlayer: Remote added videocontent now = " + videoContent);
99 console.log("MediaPlayer: Remote server found image " + current);
100 imageContent.push(current);
101 console.log("MediaPlayer: Remote added imagecontent now = " + imageContent);
105 console.log("MediaPlayer: Remote media failed to push content, not == AUDIO/VIDEO/IMAGE");
112 function foundMediaServer(srv)
114 console.log("MediaPlayer: New MediaServer Found");
115 console.log("MediaServer id: " + srv.id);
116 console.log("MediaServer friendlyName: " + srv.friendlyName);
120 console.log("MediaPlayer: MediaServer root folder: " + srv.root.id);
121 srv.browse(srv.root.id, "+DisplayName", 0, 0, browseCallback);
122 srv.find(srv.root.id, "*", "+DisplayName", 0, 0, findAllCallback);
125 console.log("MediaServer not browsable");