/*!
- Ripple Mobile Environment Emulator v0.9.8 :: Built On Tue Jan 06 2015 14:03:17 GMT+0800 (CST)
+ Ripple Mobile Environment Emulator v0.9.8 :: Built On Tue Jan 13 2015 18:18:15 GMT+0800 (CST)
Apache License
Version 2.0, January 2004
_data.mediaServer.containers = containers;
_data.mediaServer.items = items;
_data.mediaServer.onserverfound = null;
+ _data.mediaServer.onserverlost = null;
}
function _setRoot() {
"Artists", "Width", "Height", "SampleRate"];
order = sortMode.match(/[+|-]/g);
- if (order.length > 1) {
+ if (order === null || order.length > 1) {
return null;
}
return;
}
- if (mediaserver.onserverfound == null) {
- return;
+ if (mediaserver.onserverfound != null) {
+ mediaserver.onserverfound(new MediaServer(_data.mediaServer.server));
+ }
+
+ if (mediaserver.onserverlost != null) {
+ mediaserver.onserverlost(new MediaServer({'id':_data.mediaServer.server.id}));
}
- mediaserver.onserverfound(new MediaServer(_data.mediaServer.server));
}, 1);
}
}
});
+ mediaserver.__defineGetter__("onserverlost", function () {
+ return _data.mediaServer.onserverlost;
+ });
+
+ mediaserver.__defineSetter__("onserverlost", function (val) {
+ try {
+ _data.mediaServer.onserverlost = t.Callback(val, "?");
+ } catch (e) {
+ }
+ });
+
return mediaserver;
};
this.cancel = function () {
// cancel
+ return {
+ then: function(successCallback, errorCallback) {
+ successCallback();
+ }
+ };
};
this.browse = function (containerId, sortMode, count, offset,
};
this.find = function (containerId, searchFilter, sortMode, count,
- offset, successCallback, errorCallback) {
+ offset, errorCallback) {
t.MediaServer("find", arguments);
- window.setTimeout(function () {
- var i, j, results, container = "", mediaFiles = [],
- paths = _data.mediaServer.containers,
- medias = _data.mediaServer.items,
- sort = _formatSortMode(sortMode);
-
- if (!containerId) {
- if (errorCallback)
- errorCallback(new WebAPIError(errorcode.UNKNOWN));
- return;
- }
+ var i, j, results, container = "", mediaFiles = [],
+ paths = _data.mediaServer.containers,
+ medias = _data.mediaServer.items,
+ sort = _formatSortMode(sortMode);
- for (i = 0; i < paths.length; i++) {
- if (paths[i].id === containerId) {
- container = paths[i].Path;
- continue;
- }
+ if (!containerId) {
+ if (errorCallback)
+ errorCallback(new WebAPIError(errorcode.UNKNOWN));
+ return;
+ }
- if ((paths[i].Path.indexOf(containerId) === 0) &&
- (paths[i].Path !== containerId)) {
- mediaFiles.push(new MediaFactory(paths[i].type,
- paths[i]));
- }
+ for (i = 0; i < paths.length; i++) {
+ if (paths[i].id === containerId) {
+ container = paths[i].Path;
+ continue;
}
- if (!container) {
- if (errorCallback)
- errorCallback(new WebAPIError(errorcode.UNKNOWN));
- return;
+ if ((paths[i].Path.indexOf(containerId) === 0) &&
+ (paths[i].Path !== containerId)) {
+ mediaFiles.push(new MediaFactory(paths[i].type,
+ paths[i]));
}
+ }
- for (i = 0; i < paths.length; i++) {
- if ((paths[i].Path.indexOf(container) === 0) &&
- (paths[i].Path !== container)) {
- mediaFiles.push(new MediaFactory(paths[i].type,
- paths[i]));
- }
+ if (!container) {
+ if (errorCallback)
+ errorCallback(new WebAPIError(errorcode.UNKNOWN));
+ return;
+ }
+
+ for (i = 0; i < paths.length; i++) {
+ if ((paths[i].Path.indexOf(container) === 0) &&
+ (paths[i].Path !== container)) {
+ mediaFiles.push(new MediaFactory(paths[i].type,
+ paths[i]));
}
+ }
- for (j = 0; j < medias.length; j++) {
- if (medias[j].Path.indexOf(container) === 0) {
- mediaFiles.push(new MediaFactory(medias[j].type,
- medias[j]));
- }
+ for (j = 0; j < medias.length; j++) {
+ if (medias[j].Path.indexOf(container) === 0) {
+ mediaFiles.push(new MediaFactory(medias[j].type,
+ medias[j]));
}
+ }
- mediaFiles = _filter(searchFilter, mediaFiles);
- if (mediaFiles === null) {
- if (errorCallback)
- errorCallback(new WebAPIError(errorcode.UNKNOWN));
- return;
+ mediaFiles = _filter(searchFilter, mediaFiles);
+ if (mediaFiles === null) {
+ if (errorCallback)
+ errorCallback(new WebAPIError(errorcode.UNKNOWN));
+ return;
+ }
+
+ results = ivi_utils.query(_filter(searchFilter, mediaFiles), false,
+ sort, count, offset);
+
+ return {
+ then: function (callback) {
+ callback(results);
}
+ };
- results = ivi_utils.query(_filter(searchFilter, mediaFiles), false,
- sort, count, offset);
- successCallback(results);
- }, 1);
+ };
+
+ this.oncontainerchanged = function () {
+ //oncontainerchanged
};
};
2: _t.DOMString,
3: _t.unsigned_long,
4: _t.unsigned_long,
- 5: _t.MediaServerBrowseFindCallback,
- 6: _t.MediaServerErrorCallback,
+ 5: _t.MediaServerErrorCallback,
_optional: {
// nullable
- 6: true
+ 5: true
}
};
devices = require('ripple/devices'),
constants = require('ripple/constants'),
vibration = require('ripple/platform/tizen/2.0/vibration'),
+ platform = require('ripple/platform'),
+ builder = require('ripple/platform/builder'),
_self = {};
(function () {
return obj[key].apply(obj, Array.prototype.slice.call(arguments));
};
}
+ //this is a temporary work around method
+ var sandbox = {};
+ builder.build(platform.current().objects).into(sandbox);
+ nav.vehicle = sandbox.navigator.vehicle;
+ nav.mediaServer = sandbox.navigator.mediaserver;
for (key in nav) {
_self[key] = _handle(nav, key);