2 var library = function() {
4 this.initialized = false;
9 this.initialize = function() {
13 if (window.tizen === undefined) {
14 throw Error("You need the Tizen web API to run Hoofbeats.");
17 this.audioTypeFilter = new tizen.AttributeFilter(
18 "type", "EXACTLY", "AUDIO");
19 this.videoTypeFilter = new tizen.AttributeFilter(
20 "type", "EXACTLY", "VIDEO");
21 this.typeFilter = new tizen.CompositeFilter(
22 "UNION", [this.audioTypeFilter, this.videoTypeFilter]);
24 this.sortMode = new tizen.SortMode("trackNumber", "ASC");
25 this.mediaSource = tizen.mediacontent.getLocalMediaSource();
28 this.scan = function() {
34 this.mediaSource.findItems(
35 this.findItemsCB.bind(this),
36 this.errorCB.bind(this),
44 this.errorCB = function(error) {
45 console.log("Error: " + error.name);
46 throw new Error(error.name);
49 this.findItemsCB = function(items) {
52 items.forEach(function(item, index, items) {
53 self.mediaItems.push(item);
54 console.log("Item added to the library: " + item.title);
57 if (items.length == this.fetchCount) {
58 // There *might* be more items.
59 this.fetchOffset += this.fetchCount;
60 this.mediaSource.findItems(
61 this.findItemsCB.bind(this),
62 this.errorCB.bind(this),
73 set initialized(value) {this._initialized = value; },
74 get initialized() { return this._initialized; }
77 window.HoofbeatsLibrary = library;