"type", "EXACTLY", "VIDEO");
this.typeFilter = new tizen.CompositeFilter(
"UNION", [this.audioTypeFilter, this.videoTypeFilter]);
-
- this.sortMode = new tizen.SortMode("trackNumber", "ASC");
- this.mediaSource = tizen.mediacontent.getLocalMediaSource();
};
this.scan = function() {
+ this.deferred = new $.Deferred();
this.initialize()
this.mediaItems = [];
this.fetchOffset = 0;
- this.mediaSource.findItems(
- this.findItemsCB.bind(this),
+ tizen.content.find(
+ this.findCB.bind(this),
this.errorCB.bind(this),
null,
this.typeFilter,
- this.sortMode,
+ null,
this.fetchCount,
this.fetchOffset);
+
+ return this.deferred.promise();
};
this.errorCB = function(error) {
console.log("Error: " + error.name);
+ this.deferred.reject();
throw new Error(error.name);
};
- this.findItemsCB = function(items) {
+ this.findCB = function(items) {
var self = this;
items.forEach(function(item, index, items) {
if (items.length == this.fetchCount) {
// There *might* be more items.
this.fetchOffset += this.fetchCount;
- this.mediaSource.findItems(
- this.findItemsCB.bind(this),
+ tizen.content.find(
+ this.findCB.bind(this),
this.errorCB.bind(this),
null,
this.typeFilter,
- this.sortMode,
+ null,
this.fetchCount,
this.fetchOffset);
+ } else {
+ self.deferred.resolve();
}
};
};