1 /******************************************************************************
2 * Copyright 2012 Intel Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
18 * @module MultimediaPlayerApplication
22 * Class providing objects mapping the org.gnome.UPnP MediaObject2 and MediaItem2 interfaces.
26 var mediacontent = window.mediacontent = {};
29 * Generic media object.
32 * @return {Object} MediaObject objects
34 mediacontent.MediaObject = function(proxy) {
39 this.type = proxy.Type;
40 this.title = proxy.DisplayName;
46 * Gets the MediaObject metadata info.
49 * @return {Object} metadata object
51 mediacontent.MediaObject.prototype.getMetaData = function() {
53 return this.proxy.callMethod("org.gnome.UPnP.MediaObject2", "GetMetaData", []);
57 * Mediacontent object of type container.
59 * @class MediaContainer
60 * @param proxy {Object} media source object
61 * @return {Object} MediaContainer object
63 mediacontent.MediaContainer = function(proxy) {
65 mediacontent.MediaObject.call(this, proxy);
66 this.type = "CONTAINER";
67 this.directoryURI = "";
68 this.storageType = "EXTERNAL";
69 this.title = proxy.title;
70 if (this.id === undefined)
76 mediacontent.MediaContainer.prototype = new mediacontent.MediaObject();
77 mediacontent.MediaContainer.prototype.constructor = mediacontent.MediaContainer;
80 * Mediacontent object of type media item. Provides access to properties of media items.
83 * @param proxy {Object} media source object
84 * @return {Object} MediaItem object
86 mediacontent.MediaItem = function(proxy) {
88 mediacontent.MediaObject.call(this, proxy);
90 this.mimeType = proxy.mimeType;
92 this.contentURI = proxy.URLs[0];
94 this.contentURI = proxy.sourceUri;
96 this.size = proxy.fileSize;
97 this.releaseDate = proxy.createDate;
98 this.modifiedDate = null;
99 this.name = proxy.title;
100 this.title = proxy.title;
101 this.editableAttributes = [];
102 this.thumbnailURIs = [];
103 if (!!proxy.AlbumArtURL && proxy.AlbumArtURL !== "") {
104 this.thumbnailURIs.push(proxy.AlbumArtURL);
106 this.description = "Unknown";
113 mediacontent.MediaItem.prototype = new mediacontent.MediaObject();
114 mediacontent.MediaItem.prototype.constructor = mediacontent.MediaItem;
117 * Mediacontent object of type video. Extends a basic media item object with video-specific attributes.
120 * @param proxy {Object} media source object
121 * @return {Object} MediaVideo object
123 mediacontent.MediaVideo = function(proxy) {
125 mediacontent.MediaItem.call(this, proxy);
127 this.duration = proxy.duration * 1000; //Tizen's ContentVideo is in ms
128 this.width = proxy.width;
129 this.height = proxy.height;
131 this.album = proxy.Album;
133 else if (proxy.collection) {
134 this.album = proxy.collection;
137 this.album = "Unknown";
141 this.artists = [ proxy.Artist ];
143 else if (proxy.author) {
144 this.artists = [ proxy.author ];
147 this.artists = [ "Unknown" ];
149 this.geolocation = null;
155 mediacontent.MediaVideo.prototype = new mediacontent.MediaItem();
156 mediacontent.MediaVideo.prototype.constructor = mediacontent.MediaVideo;
159 * Mediacontent object of type audio. Extends a basic media item object with audio-specific attributes.
162 * @param proxy {Object} media source object
163 * @return {Object} MediaAudio object
165 mediacontent.MediaAudio = function(proxy) {
167 mediacontent.MediaItem.call(this, proxy);
169 this.bitrate = proxy.audioSampleRate;
170 this.duration = proxy.duration * 1000; //Tizen's ContentAudio is in ms
172 this.album = proxy.Album;
174 this.album = "Unknown";
177 this.artists = [ proxy.Artist ];
179 else if (proxy.author) {
180 this.artists = [ proxy.author ];
182 this.artists = [ "Unknown" ];
185 this.composers = [ "Unknown" ];
187 this.copyright = "Unknown";
188 if (proxy.trackNumber)
189 this.trackNumber = proxy.trackNumber;
191 this.trackNumber = 0;
197 mediacontent.MediaAudio.prototype = new mediacontent.MediaItem();
198 mediacontent.MediaAudio.prototype.constructor = mediacontent.MediaAudio;
201 * Mediacontent object of type image. Extends a basic media item object with image-specific attributes.
204 * @param proxy {Object} media source object
205 * @return {Object} MediaImage object
207 mediacontent.MediaImage = function(proxy) {
209 mediacontent.MediaItem.call(this, proxy);
211 this.width = proxy.width;
212 this.height = proxy.height;
213 this.orientation = "NORMAL";
219 mediacontent.MediaImage.prototype = new mediacontent.MediaItem();
220 mediacontent.MediaImage.prototype.constructor = mediacontent.MediaImage;
223 * Returns appropriate media object based on the given parameter media type.
225 * @class mediaObjectForProps
226 * @param props {Object} media source object
227 * @return {Object} correct media object by props.type
229 mediacontent.mediaObjectForProps = function(props) {
232 if (props.type.indexOf("container") === 0 || props.type.indexOf("album") === 0 || props.type.indexOf("person") === 0 || props.type.indexOf("genre") === 0){
233 return new mediacontent.MediaContainer(props);
235 if (props.type.indexOf("video") === 0){
236 return new mediacontent.MediaVideo(props);
238 if (props.type.indexOf("audio") === 0 || props.type.indexOf("music") === 0){
239 return new mediacontent.MediaAudio(props);
241 if (props.type.indexOf("image") === 0 || props.type.indexOf("picture") === 0) {
242 return new mediacontent.MediaImage(props);
245 return new mediacontent.MediaItem(props);