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");
27 this.mediaSource = tizen.mediacontent.getLocalMediaSource();
30 this.scan = function() {
36 this.mediaSource.findItems(
37 this.findItemsCB.bind(this),
38 this.errorCB.bind(this),
46 this.errorCB = function(error) {
47 console.log("Error: " + error.name);
48 throw new Error(error.name);
51 this.findItemsCB = function(items) {
54 items.forEach(function(item, index, items) {
55 self.mediaItems.push(item);
56 window.MusicBrainz.getArtist(item.name).done(function(data) {
61 if (items.length == this.fetchCount) {
62 // There *might* be more items.
63 this.fetchOffset += this.fetchCount;
64 this.mediaSource.findItems(
65 this.findItemsCB.bind(this),
66 this.errorCB.bind(this),
77 set initialized(value) {this._initialized = value; },
78 get initialized() { return this._initialized; }
81 window.HoofbeatsLibrary = library;