1 /* vi: set et sw=4 ts=4 si: */
3 var library = function() {
5 this.initialized = false;
11 this.initialize = function() {
15 if (window.tizen === undefined) {
16 throw Error("You need the Tizen web API to run Hoofbeats.");
19 this.audioTypeFilter = new tizen.AttributeFilter(
20 "type", "EXACTLY", "AUDIO");
21 this.videoTypeFilter = new tizen.AttributeFilter(
22 "type", "EXACTLY", "VIDEO");
23 this.typeFilter = new tizen.CompositeFilter(
24 "UNION", [this.audioTypeFilter, this.videoTypeFilter]);
26 this.sortMode = new tizen.SortMode("trackNumber", "ASC");
29 this.scan = function() {
36 this.findCB.bind(this),
37 this.errorCB.bind(this),
45 this.errorCB = function(error) {
46 console.log("Error: " + error.name);
47 throw new Error(error.name);
50 this.findCB = function(items) {
53 items.forEach(function(item, index, items) {
54 self.mediaItems.push(item);
55 window.MusicBrainz.getArtist(item.name).done(function(data) {
60 if (items.length == this.fetchCount) {
61 // There *might* be more items.
62 this.fetchOffset += this.fetchCount;
64 this.findCB.bind(this),
65 this.errorCB.bind(this),
76 set initialized(value) {this._initialized = value; },
77 get initialized() { return this._initialized; }
80 window.HoofbeatsLibrary = library;