Another vi modeline.
[profile/ivi/cowhide.git] / examples / hoofbeats / javascripts / library.js
index 29b887c..6a5d570 100644 (file)
@@ -22,33 +22,34 @@ $(function() {
                 "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) {
@@ -61,14 +62,16 @@ $(function() {
             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();
             }
         };
     };