var _this = this; var body = document.body, html = document.documentElement; this.ticking = false; window.addEventListener('scroll', function(e) { _this._x = window.scrollX; _this._y = window.scrollY; // console.log('scroll', _this._x, _this._y) if (_this._y !== _this.y) { var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight); _this._atbottom = (_this._y + window.innerHeight) >= height; } _this.ticking = true; }); if (! this.ticking) return; if (this._atbottom !== this.atbottom) this.setAttribute('atbottom', this._atbottom); if (this._x !== this.x) this.setAttribute('x', this._x); if (this._y !== this.y) this.setAttribute('y', this._y); this.ticking = false; if (! localStorage.emtdata) { localStorage.emtdata = JSON.stringify(this._data); } else { this._data = JSON.parse(localStorage.emtdata); } for (key in this._data) { var val = this._data[key]; // console.log('restored', key, val) this.setAttribute(key, val); } var _this = this; window.addEventListener('unload', function() { localStorage.emtdata = JSON.stringify(_this._data); }); this._data[name] = value; this.setAttribute(name, value); // console.log('persisted', name, value, this._data) this._data = {paused: true}; delete localStorage.emtdata; var parts = duration.split(':'); var secs = 0; if (parts.length === 1) { secs = parts[0] * 1; } else if (parts.length === 2) { secs = (parts[0] * 60) + (parts[1] * 1) } // console.log('secs', secs) return humanized_duration(secs * 1000) this.setAttribute('volume', persist.volume) persist.set('volume', volume); // if (loadprogress == 1) trackEvent('player', 'loadfinished', this.pid) // if (this.pid) trackEvent('player', 'playing', this.pid, this.time) if (this.pid) { // trackEvent('player', 'loaded', this.pid) this.firstload = true } // console.log('paused', this, this.paused, this.playing) if (this.playing) { this.setAttribute('paused', ! this.paused); persist.set('paused', this.paused); } else { // console.log('play', true) this.setAttribute('playing', true); persist.set('paused', false); } if (url !== this.url) { var args = {url: url, pid: pid} this.setAttributes(args); // trackEvent('player', 'loading', this.pid) } if (loggedin) { this.setAttribute('playlistoffset', this.playlistoffset) this.setAttribute('trackoffset', this.trackoffset) } if (! this.playlist.data) return; var tracks = this.playlist.data.tracks; if (! tracks) return; if (playlistoffset >= tracks.length) { // we reached the end, reset to zero to keep playing playlistoffset = 0; } var track = tracks[playlistoffset]; // console.log('onplaylistoffset', playlistoffset, track) if (track && track.id !== this.productid) { this.play(track); } if (data && data.tracks) { data.tracks.map(function(track) { if (! track.tracks) { track.tracks = [JSON.parse(JSON.stringify(track))] } }); } return data; // console.log('onend', audio.paused) if (! audio.paused) { this.next(); } // TODO: figure out why I'm getting called with null if (! product) return var productid = product.id; this.setAttribute('productid', productid) if (this.playlist.data) { var tracks = this.playlist.data.tracks; // look through playlist for matching productid for (var i = 0, l = tracks.length; i < l; i++) { var track = tracks[i]; if (track.id == productid && this.playlistoffset != i) { // console.log('set playlistoffset to match', track.id, i); this.setAttribute('playlistoffset', i); } } } // Not found in playlist, load album instead this.trackoffset = trackoffset || 0; this.album.setAttribute('data', product) this.setAttribute('trackoffset', this.trackoffset) // skip if the first track wasn't a match var firsttrack = this.album.data.tracks[0]; if (firsttrack && firsttrack.found === false) { // console.log('play next', firsttrack) // this.next(); } // console.log('product', this.album.data, this.playlist.data) var tracks = [] if (this.album.data) { tracks = this.album.data.tracks; } if (tracks.length > 1 && this.trackoffset + 1 < tracks.length && ((! this.currenttrackonly) || (playerui.drawer.open))) { this.currenttrackonly = false; // store history var track = tracks[this.trackoffset]; track.trackoffset = this.trackoffset; this._history.push(track); if (track.found) { var foundoffset = 1; var wasfound = false; // marked to only play some tracks, find the offset of the one to be played while ((this.trackoffset + foundoffset) < tracks.length) { track = tracks[this.trackoffset + foundoffset] if (track.found) { wasfound = true; // console.info('found next track', track, track.keywords) this.setAttribute('trackoffset', this.trackoffset + foundoffset) return; } foundoffset++; } // failed to find marked track, set track offset to 0 if (wasfound) { this.setAttribute('trackoffset', 0) } else { // console.info('next next', track, track.found, foundoffset, this.trackoffset) queues.next(); } return; } // play next track in album this.setAttribute('trackoffset', this.trackoffset + 1) } else { // console.info('exception next', track) this.currenttrackonly = false; queues.next(); } // console.log('prev', this._history) if (this._history.length) { var item = this._history.pop(); if (item.isalbum) { player.album.setAttribute('data', item) var track = item.tracks[item.trackoffset] this.setAttribute('playlistoffset', item.playlistoffset); track.trackoffset = item.trackoffset } else { var track = item; } var pid = track.id this.setAttribute('trackoffset', track.trackoffset) songredirect.getURL(pid, function(url) { audio.playTrack(url, pid); }); } // don't add the currently playing product if (product.id == this.productid) return; // don't add the track that's playing to the list for (var i = 0, l = upnext.tracks.length; i < l; i++) { var track = upnext.tracks[i]; if (product.id == track.id) { return; } } var tracks = queues.queue.repl.children; // console.log('add', tracks, this.playlist) for (var i = 0, l = tracks.length; i < l; i++) { var child = tracks[i]; if (product.id == child.data.id) { // move to up next child.upnext(); return; } } // add to the end of the playlist upnext.add(product); // this.playlist.setAttribute('data', this.playlist.data); // if (! this.productid) { // this.setAttribute('playlistoffset', 0); // } buy.show(product); if (! persist.format) { persist.set('format', '320MP3') } var url = EMT + '/product/download/' + product.id + '?type=' + persist.format + '&redirect=true'; trackEvent('product', 'download', product.id, persist.format) //console.log('download', url, product) buy.buywindow.setAttribute('src', url); if (data) { if (! data.tracks) { data.tracks = [JSON.parse(JSON.stringify(data))] } else { data.tracks.map(function(track) { if (! track.tracks) { track.tracks = [JSON.parse(JSON.stringify(track))] } }); } } return data; audio.setAttribute('playing', true) audio.setAttribute('paused', persist.paused) if (err.msg === 4) { // aws timeout, force reload songredirect.cache = null songredirect.getURL(audio.pid, function(url) { // console.log('forcing reload', audio.audio, audio.pid) audio.setAttributes({url: url, pid: audio.pid}); }); } else { console.error('audio load error', err, audio); } if (! this.album.data) return; var tracks = this.album.data.tracks; if (trackoffset < tracks.length) { var track = tracks[trackoffset]; // console.log('loading track', track) // get signed streaming URL var pid = track.id this.setAttribute('audio', track.audio) songredirect.getURL(pid, function(url) { audio.playTrack(url, pid); }); var nexttrack = tracks[trackoffset + 1]; if (nexttrack) { // prefetch URL for next track setTimeout(function() { songredirect.getURL(nexttrack.id, function() { }) },4000) } } var key = id; if (this.cache && this.cache[key]) { // console.log('cache hit', key, this.cache.expires, Date.now()) if (callback) return callback(this.cache[key]); } if (this.callbacks[id]) return; this.callbacks[id] = callback; var url = EMT + '/product/stream/' + id; // console.log('getURL', url, id) this.songredirectds.setAttribute('url', url); // debugger; // console.log('songredirect', data); var key = data.pid; var callback = this.callbacks[key]; if (data.url) { if (! this.cache || (Date.now() >= this.cache.expires)) { this.cache = {}; this.cache.expires = data.expires // console.log('new cache', data) } this.cache[key] = data.url; if (callback) { callback(data.url); this.callbacks[key] = null; } } if (! (product && this.purchased)) return false; // console.log('product', product) if (this.purchased[product.id]) { return true; } if (product.tracks && product.tracks.length > 1) { var ownall = true; for (var i = 0; i < product.tracks.length; i++) { // console.log('checking for ownership of all tracks', product.tracks[i]) if (! this.purchased[product.tracks[i].id]) { ownall = false break } } return ownall } else { return this.purchased[product.id] } if (text === 'Dope') text = 'Recommended' return text.toUpperCase() search.keywords = {}; search.keywords[this.text] = true; taglist.reset(); search.doSearch(); this.repl.setAttribute('data', data) var data = this.features && this.features.data; if (! data) return offset; if (offset >= this.features.data.tracks.length) offset = 0; return offset; if (pid > 0) this.color.setAttribute('url', '/product/colors/' + pid) // console.log('data', data) var color = data[0] this.colorbanner.setAttribute('bgcolor', color.color) this.bg.setAttributes({color: color.dark ? 'white' : 'black', bgcolor: color.color}) if (! visible && (! this.features.url)) { this.features.setAttribute('url', '/features') } if (! searchresultpage.visible) this.features.setAttribute('url', '/features') var _this = this; setInterval(function() { if (! _this.bg.active) _this.setAttribute('offset', _this.offset + 1) }, 10000) this.active = false; if (view && (view === this || view.parent === this || view.parent.parent === this)) { this.active = true; } this.parent.setAttribute('offset', this.parent.offset + 1) var data = this.parent.features.data if (! data) return; this.setAttribute('visible', true) // console.log('update', data) var feature = data.tracks[this.parent.offset]; this.setAttribute('feature', feature); this.parent.setAttribute('pid', feature.id) this.cover.setAttribute('url', feature.imageurl); this.artist.setAttribute('text', feature.artist); this.release.setAttribute('text', feature.release); var tracks = (feature.tracks && feature.tracks.length) || 1; this.labeldate.tracks.setAttribute('text', tracks + ' track' + (tracks > 1 ? 's' : '')); this.labeldate.label.setAttribute('text', feature.label); this.labeldate.released.setAttribute('text', feature.released); this.description.setAttributes({text: feature.description || '', scrolly: 0}); this.rule.setAttribute('visible', feature.description && feature.description.length) this.tags.setAttribute('data', feature.keywords) var product = this.feature; trackEvent('product', 'playingfeature', product.id) // always start at first track when playing an album player.setAttribute('trackoffset', 0) if (! product.tracks) product.tracks = [product] player.play(product); // this.repl.setAttribute('datapath', this.repl.datapath) {"tags": [ {"name":"Ambient"}, {"name":"Beats"}, {"name":"Breakbeat"}, {"name":"Dark"}, {"name":"Downtempo"}, {"name":"Drum & Bass"}, {"name":"Dubstep/grime"}, {"name":"Electro"}, {"name":"Experimental"}, {"name":"Funky"}, {"name":"Glitch Hop"}, {"name":"Glitchy"}, {"name":"Halftime"}, {"name":"Heavy"}, {"name":"Hip Hop"}, {"name":"House"}, {"name":"Idm"}, {"name":"Midtempo"}, {"name":"Organic"}, {"name":"Progressive"}, {"name":"Ragga"}, {"name":"Dope"}, {"name":"Techfunk"}, {"name":"Techno"}, {"name":"Trap"}, {"name":"Tribal"}, {"name":"Vocal"} ] } if (data && data.tracks) { data.tracks.map(function(track) { if (! track.tracks) { track.tracks = [JSON.parse(JSON.stringify(track))] } }); } return data; if (! url) return; if (searchresultpage.visible) return; this.playlist.setAttribute('url', url); if (! visible && (this.playlist.url !== this.url)) { this.playlist.setAttribute('url', this.url) } if (! this.url) return; // console.warn('init playlist', window.location.hash, this.url, window.location.hash.indexOf(this.url) != -1) if (window.location.hash.indexOf(this.url) != -1) { // this.play(); } if (! this.url) return; // console.warn('updateref', window.location.hash, this.url, window.location.hash.indexOf(this.url) != -1) if (window.location.hash.indexOf(this.url) != -1) { if (queues.playlist !== this) { // console.log('setting playlist', this.url) queues.setAttribute('playlist', this); } } var parser = document.createElement('a'); parser.href = url; return parser.pathname; // console.log('playlist.play', this.url) // if (queues.playlist !== this) { if (this.playlist.data) queues.play(this.playlist.data) queues.setAttribute('playlist', this); this.start = 0; if (! skip) window.location.hash = '/playlist' + this.getpath(this.url); // } if (audio.paused) { audio.togglePaused(); } window.location.hash = '/details' + this.getpath(this.url); var size = Infinity; if (this.playlist.data && this.playlist.data.meta) { size = this.playlist.data.meta.size; } // console.log('nextpage', this.start + 25, size) if (this.start + 25 < size) { this.start += 5; window.location.hash = '/playlist' + this.url + '?start=' + this.start } trackEvent('playlist', 'play', this.parent.playlist.data.title) this.parent.play(); this.playlisttitle.setAttribute('data', data.title) this.container.repl.setAttribute('data', data.tracks) this.playbutton.setAttribute('visible', true) for (var i = 0, l = this.subviews.length; i < l; i++) { var view = this.subviews[i]; if (view.url === url) { return view; } } queues.play(search.searchresult.data) queues.setAttribute('playlist', this); this.start = 0; if (! skip) window.location.hash = search.searchresult.url; this.url = search.searchresult.url; queues.setAttribute('playlist', this); this.playlist.setAttributes({data: data, visible: true}) this.setAttribute('size', data.meta.size); this.refresh(); this.refresh(); if (loggedin) { this.refresh(); } if (data && data.tracks) { this.setAttribute('visible', data.tracks.length) cartbutton.setAttribute('color', (data.meta.price > -1) ? '#0c8aeb' : 'black') } var url = '/account/playlists/cart'; if (window.location.hash.indexOf(url) !== -1) { searchresultpage.searchresultpageds.setAttribute('url', EMT + url); } this.setAttribute('url', EMT + url); queues.setAttribute('playlist', this); queues.play(this.playlist.data) if (! skip) window.location.hash = '/playlist/product/purchased'; this.refresh(); if (loggedin) { this.refresh(); } this.setAttribute('url', EMT + '/product/purchased') if (! persist.format) { // ask about preferred download format buy.downloadmenu(product) } else { var url = EMT + '/product/download/' + product.id + '?type=' + persist.format; this.setAttribute('_downloadurl', url) } var url = EMT + '/product/download/redirect/' + encodeURIComponent(data.file) + '/' + encodeURIComponent(data.url) buy.buywindow.setAttribute('src', url); this.parent.setAttribute('_downloadurl', '') if (! data) return; // console.log('ondata', data) this.left.title.setAttribute('text', data.title) if (this.left.artist) this.left.artist.setAttribute('text', data.artist) if (this.left.label) this.left.label.setAttribute('text', data.label) this.left.tags.setAttribute('data', data.keywords) if (this.released) this.released.setAttribute('text', data.released) this.duration.setAttribute('text', data.duration) if (this.cover) this.cover.setAttribute('url', data.imageurl) this.but.setAttribute('visible', true) var owned = player.purchased && player.purchased[this.data && this.data.id] // console.log('onpurchased', owned, purchased) if (owned !== this.owned) this.setAttribute('owned', owned) return humanizer.getDuration(text); var product = this.parent.data; if (this.parent.owned) { trackEvent('product', 'downloadbutton', product.id) this.download.show(product) } else { trackEvent('product', 'buyitbutton', product.id) buy.show(product); } // console.log('play', this.data) trackEvent('product', 'playingsearchresultitem', this.data.id) player.play(this.data); if (type === 'title') { // load specific release instead of title (in case of single tracks) var url = encodeURIComponent(this.data.label) + '/' + encodeURIComponent(this.data.artist) + '/' + encodeURIComponent(this.data.release); window.location.hash = '/details/product/' + url; } else { search.setAttributes({type: type, term: term}) } var product = searchresultpage.data.tracks[0]; // console.log('play', product, this.index) trackEvent('product', 'playingsearchresulttrack', product.tracks[this.index].id) player.play(product); player.setAttribute('trackoffset', this.index) if (audio.paused) audio.togglePaused(); if (! opacity) { var _this = this; clearTimeout(this.tid); this.tid = setTimeout(function() { _this.setAttribute('visible', false); },350); } else { clearTimeout(this.tid); this.setAttribute('visible', true) if (this._results) { this.updateResults(this._results); this._results = null; } } if (data && data.tracks) { this.playlist = playlists.searchresult; this.updateResults(data); } if (data && data.tracks) { this.playlist = playlists.findByUrl(this.searchresultpageds.url) this.updateResults(data); } if (! data) return; if (! this.visible) { this._results = data; return; } // console.log('updateResults', data, data.meta.price, this.price) this.setAttribute('price', data.meta.price > -1 ? data.meta.price : -1); cartbutton.setAttribute('color', (data.meta.price > -1) ? '#0c8aeb' : 'black') data = JSON.parse(JSON.stringify(data)); var firsttrack = data.tracks[0]; if (! firsttrack) return; this.data = data; this.header.setAttribute('url', firsttrack.imageurl) this.colorz.setAttribute('url', '/product/colors/' + firsttrack.id) this.first.setAttribute('data', firsttrack) var therest = data.tracks.slice(1); this.therest.items.setAttribute('data', therest) var showtracks = therest.length === 0; this.therest.tracks.setAttribute('data', showtracks ? firsttrack.tracks : []) this.therest.label.setAttribute('visible', ! showtracks) this.therest.playbutton.setAttribute('visible', ! showtracks) // console.log('searchresult', data) this.start = data.tracks.length; this.therest.label.setAttribute('text', data.title) trackEvent('product', 'playingsearchresult', this.playlist.playlisttitle.text) if (this.playlist.url != playlist.url) { // avoid resetting playlist queues.setAttribute('playlist', this.playlist); } if (this.playlist.data) queues.play(this.playlist.data) queues.setAttribute('playlist', this); queues.start = 0; this.playlist.play(true); this.playlist.details(); if (audio.paused) { audio.togglePaused(); } // console.log('colorz', data) var color = data[0] this.first.setAttributes({color: color.dark ? 'white' : 'black'}) this.first.bg.setAttributes({bgcolor: color.color}); this.colorbanner.setAttribute('bgcolor', color.color) if (! this.playlist) return; if (! atbottom) return; var url = this.playlist.url; var start = this.start || 0; if (this.data.meta.size && (start >= this.data.meta.size)) return; url += '?start=' + start; // console.log('atbottom', atbottom, url, this.data.meta.size) this.setAttribute('loading', true) this.additionalresults.setAttribute('url', url) this.data.tracks = this.data.tracks.concat(data.tracks); this.start = this.data.tracks.length; this.setAttribute('loading', false) // console.log('ondata', data, this.start) this.updateResults(this.data); if (price > -1) { var formatted = price ? accounting.formatMoney(price) : 'FOR FREE' this.setAttributes({visible: true, label: 'BUY ' + formatted, width: this.lab.width + 40}) } else { this.setAttributes({visible: false}) } var data = this.parent.data; trackEvent('product', 'buyplaylistbutton', data.title) buy.show(data.tracks, data.meta.description, this.parent.price) searchresultpage.play(); var pos = Math.max(-4, 58 - scroll.y) if (pos !== this.pos) this.setAttribute('pos', pos) var max = 870; var min = this.width - 560; var delta = max - min; var searchwidth = min + ((pos / 58) * delta) - 150 // console.log('pos', pos, searchwidth) // searchwidth = Math.max(searchwidth, 875) if (searchwidth !== this.searchwidth) this.setAttribute('searchwidth', searchwidth) early release if (login.loggedin) { playlists.downloads.details() } else { login.toggleLogin() } this.keywords = {} this.doSearch(); var _this = this; var readHash = function() { var hash = decodeURI(window.location.hash).substring(1) _this.setAttribute('hash', hash) searchresultpage.setAttribute('opacity', 0) if (hash.indexOf('/search/') === 0) { _this.searchresult.setAttribute('url', hash); searchresultpage.setAttribute('opacity', 1) // console.log('search terms', hash) if (hash.indexOf('keywords') >= 0) { // restore search keywords var keywords = hash.split('=')[1] if (keywords) { var wordlist = keywords.split(',') search.keywords = {}; for (var i = 0; i < wordlist.length; i++) { search.keywords[wordlist[i]] = true; } taglist.reset() } } else { // restore search terms var terms = hash.substring(8); if (terms.indexOf('*?') != 0) { // console.log('terms', terms) var parts = terms.split('/') var term = decodeURIComponent(parts[0]) if (parts.length === 1) { search.setAttributes({type: '', term: term}) } else { term = decodeURIComponent(parts[1]); search.setAttributes({type: parts[0], term: term}) } searchpopover.setAttribute('enabled', false) searchinput.setAttribute('text', term) searchpopover.setAttribute('enabled', true) } } return; } else if (hash.indexOf('/playlist/') === 0) { // load playlist var playlisturl = hash.substring(10, hash.length); if (playlisturl === 'product/purchased') { playlisturl = EMT + '/product/purchased' } // console.log('loading playlist from url', playlisturl) return playlist.setAttribute('url', playlisturl) } else if (hash.indexOf('/details/') === 0) { // show playlist in search results screen searchresultpage.setAttribute('opacity', 1) var playlisturl = hash.substring(8, hash.length); if (playlisturl === '/product/purchased') { playlisturl = EMT + playlisturl } else if (playlisturl === '/account/playlists/cart') { // wait until login and cart is loaded if (! login.loggedin) { return; } else { playlisturl = EMT + playlisturl } } playlist.setAttribute('url', playlisturl) return searchresultpage.searchresultpageds.setAttribute('url', playlisturl) // console.log('playlisturl', playlisturl) } else if (hash.indexOf('/account/') === 0) { login.container.setAttributes({visible: true}) login.container.loginwindow.setAttributes({src: EMT + hash}) } // load features playlist by default window.location.hash = '/playlist/recommended' } $(window).on('hashchange',readHash); readHash(); if ((! this.term) && (Object.keys(this.keywords).length) == 0) return; var url = '' var keywords = []; for (var key in this.keywords) { if (this.keywords[key]) { keywords.push(key) } } if (keywords.length) { var url = '/search/keywords/' + keywords.join(','); } else { if (this.term.length < 2) return; if (this.type) { var url = '/search/' + this.type + '/' + encodeURIComponent(this.term); } else { var url = '/search/' + encodeURIComponent(this.term); } } this.searchresult.setAttribute('url', url) if (data && data.tracks) { data.tracks.map(function(track) { if (! track.tracks) { track.tracks = [JSON.parse(JSON.stringify(track))] } }); } return data; if (! data) return window.location.hash = this.searchresult.url; if (text) { var words = text.split(' '); text = words[words.length - 1]; var url = '/search/suggest/' + text.toLowerCase(); if (url !== this.suggestionds.url) this.suggestionds.setAttribute('url', url) } out = data.map(function(suggestion) { return suggestion[0]; }) return out; // console.log('suggestionds data', data) this.repl.setAttribute('data', data) this.data = data; trackEvent('search', 'suggestion', this.text) // replace last word var words = searchinput.text.split(' '); words[words.length - 1] = this.text; var newtext = words.join(' ') + ' ' searchinput.setAttributes({text: newtext, value: newtext}) return text.toUpperCase(); // console.log('term', term.length, term) if (term.length < 2) return; var url = '/search/' + term.toLowerCase(); if (url !== this.searchpopoverds.url) { this.searchpopoverds.setAttribute('url', url) } this.setAttribute('visible', true) if (! this.enabled) return var text = searchinput.text; if (! text) { this.setAttribute('visible', false) } else { this.setAttribute('term', text); suggestions.setAttribute('text', text) } if (error.readyState !== 4) return; // console.log('onerror', error) // find first suggestion that doesn't match the most recent var terms = suggestionds.data; if (! terms) return; currentterms = this.term.toLowerCase().split(' '); // console.log('terms', terms, currentterms); for (var i = 0; i < terms.length; i++) { var term = terms[i].toLowerCase(); // console.log('term', term, this.term) var newterm = currentterms.splice(0, currentterms.length - 1).join(' ') if (this.term.toLowerCase() !== newterm + ' ' + term) { // console.log('new suggestion', newterm + ' ' + term) this.setAttribute('term', newterm + ' ' + term); return; } } // console.log('ondata', data) // console.log('data', data.meta) var freq = data.meta.freq var tracks = data.tracks var buckets = data.meta.buckets for (key in buckets) { var val = buckets[key].splice(0,2) val.key = key; // console.log('buckets', key, val, this[key + 's']) this[key + 's'].repl.setAttribute('data', val) } this.term = search.term; this.setAttribute('visible', true) // hide if clicked outside if ((! view) || (view !== this && view.parent !== this && view.parent.parent !== this && view.parent.parent.parent !== this && view !== searchinput)) { this.setAttribute('visible', false) } var val = this.labels.label.text; trackEvent('search', 'result', val) search.setAttributes({type: this.type, term: val}) searchinput.setAttributes({text: val, value: val}) searchpopover.setAttribute('visible', false) var product = this.parent.data.product; trackEvent('product', 'playingsearchpopup', product.id) // always start at first track when playing an album player.setAttribute('trackoffset', 0) if (! product.tracks) product.tracks = [product] player.play(product); var type = this.replicator.data.key this.type = type; var color = this.stripcolors[type] // console.log('ondata', data, type) this.cover.setAttribute('url', data.product.imageurl) this.labels.label.setAttribute('text', data.name) this.labels.kind.setAttributes({text: type, color: color}) return text.toUpperCase(); search if (this._tid !== null) { clearTimeout(this._tid); } var keyCode = key.keyCode if (keyCode === 27) { return searchpopover.setAttribute('visible', false) } this._tid = setTimeout(this._update, this.delay); this.setAttribute('value', this.text) this.setAttributes({visible: true}) this.setAttributes({x: view.parent.getAbsolute().x - this.parent.getAbsolute().x + 150}) // console.log('view', view, view.parent.getAbsolute(), this.parent.getAbsolute()) this.active = false; if (view && (view === this || view.parent === this || view.parent.parent === this || view === genrebutton)) { this.active = true; } this.setAttribute('visible', this.active) if (text === 'undefined') return ''; // console.log('format', text) return accounting.formatMoney(text) + ' earned, get csv'; cart.details(); this.parent.showContact(); if (login.loggedin) { trackEvent('user', 'logout') } else { trackEvent('user', 'login') } this.parent.toggleLogin(); this.loggedinds.setAttribute('url', EMT + '/account/loggedIn') var loggedin = data.loggedIn; if (loggedin != this.loggedin) this.setAttribute('loggedin', loggedin) if (data.totalEarned) this.setAttribute('totalEarned', data.totalEarned) if (data.id && window.Rollbar) { Rollbar.configure({ payload: { person: { id: data.id, email: data.email } } }); } if (loggedin) { // trackEvent('user', 'loggedin') this.container.setAttribute('visible', false) songredirect.cache = null } // console.log('toggleLogin', this.loggedin) if (this.loggedin) { window.location = EMT + '/account/logout' } else { this.container.setAttributes({visible: true}) this.container.loginwindow.setAttributes({src: EMT + '/account/login'}) // console.log('loginwindow', this.loginwindow.visible, this.loginwindow.src, this.loginwindow.sprite) } this.container.setAttributes({visible: true}) this.container.loginwindow.setAttributes({src: EMT + '/contact'}) this.setAttribute('url', EMT + '/product/purchased/ids') if (loggedin) { // load purchases this.purchased_ds.reload(); // refresh login details this.refreshLogin(); } // process purchases into a hash for quick lookups var ids = {}; for (var i = 0; i < purchased.length; i++) { var tid = purchased[i] ids[tid] = true; } // console.log('purchased', ids, player.purchased) player.setAttribute('purchased', ids) if (product.free) return 0; var tracks = product.tracks; var price = 1.45; if (tracks && tracks.length > 1) { price = Math.min(1.25 * tracks.length, 13.75); } // console.log('computePrice', price, tracks.length) return price var total = 0; for (var i = 0, l = products.length; i < l; i++) { var product = products[i] total += this.computePrice(product) } return total; if (product.length) { product = product.filter(function(prod) { return ! player.isOwned(prod); }) } // console.log('show', product, description, newprice) var pids = '' var itemname = ''; var price = 0; if (product.length) { // console.log('product.length', product.length) pids = product.map(function (product) { return product.id; }) if (product.length > 1) { itemname += product.length + ' items including '; } price = this.computeTotal(product) product = product[0] } else { pids = product.id; price = this.computePrice(product) } if (product.tracks && product.tracks.length > 1) { var tracklabel = ' (' + product.tracks.length + ' tracks)'; itemname += product.release + tracklabel; } else { itemname += product.title + ' (' + product.release + ')'; } // console.log('product', product, itemname, price) this.setAttribute('data', product); this.cover.setAttribute('url', product.imageurl) this.buywindow.setAttributes({src: EMT + '/product/checkout/' + pids, visible: true, opacity: 1, clickable: true}) this.labels.release.setAttribute('text', description || itemname) var price = (newprice || price); this.labels.price.setAttribute('text', price ? accounting.formatMoney(price) : 'Free') this.setAttribute('open', true) this.failed.setAttribute('visible', false); this.buywindow.setAttributes({'clickable': false, 'opacity': .5}); // reload list of purchases dr.datasets.purchased_ds.reload() trackEvent('product', 'bought', pid) this.buywindow.setAttributes({visible: true, clickable: true, opacity: 1, src: EMT + '/product/download/menu/' + this.data.id}); this.failed.setAttribute('visible', false); login.refreshLogin(); dr.datasets.purchased_ds.reload() this.buywindow.setAttribute('visible', false); // client error trackEvent('product', 'purchaseerror', pid) this.show(this.data); this.failed.setAttributes({visible: true, text: error}); this.buywindow.setAttributes({'clickable': true, 'opacity': 1, visible: true}); // server errpr trackEvent('product', 'purchasefailed', pid) this.show(this.data); this.failed.setAttributes({visible: true, text: error || 'Purchase failed. Please try another payment method:'}); this.setAttribute('open', false) player.download(product) this.show(product) this.buywindow.setAttributes({visible: true, clickable: true, opacity: 1, src: EMT + '/product/download/menu/' + product.id}); this.failed.setAttribute('visible', false); this.buywindow.setAttributes({visible: true, clickable: true, opacity: 1, src: EMT + '/account/playlists/add/cart/' + pid}); setTimeout(function() { cart.refresh(); }, 400); if (! this.data) return; if (! open) { this.buywindow.setAttribute('visible', false) } if (! this.open) return; if (loggingin == false) { this.show(this.data) } var owned = player.purchased && player.purchased[this.data && this.data.id] // console.log('buywindow', owned) this.labels.action.setAttribute('text', owned ? 'You are downloading' : 'You are buying') this.labels.price.setAttribute('visible', ! owned) this.labels.pricelabel.setAttribute('visible', ! owned) this.labels.border.setAttribute('visible', ! owned) this.labels.includes.setAttribute('visible', ! owned) You are buying Price Includes unlimited streaming and MP3, FLAC, and WAV downloads Purchase failed. Please try another payment method: X if (! open && buy.open) { // delay closing until buy drawer closes buy.setAttribute('open', false); var _this = this; setTimeout(function() { _this.setAttribute('open', false); }, 310) return true; } persist.set('draweropen', open); return open; if (! this.container && this.container.tracks) return; var subviews = this.container.tracks.subviews; for (var i = 0; i < subviews.length; i++) { var color = player.trackoffset == i ? '#60BAFF' : 'white'; subviews[i].setAttributes({active: player.trackoffset == i, color: color}); } if (player.album.data) { var track = player.album.data.tracks[player.trackoffset] this.parent.parent.playerui.setAttribute('artisttitle', track.artist) var taglist = track.keywords.sort(); this.tags.repl.setAttribute('data', taglist) } // update tags var taglist = player.album.data.tracks[player.trackoffset].keywords.sort(); this.tags.repl.setAttribute('data', taglist) this.highlightCurrentTrack(); // hide second buy button for single tracks var repl = this.container.tracks.repl; if (repl && repl.children && repl.children[0]) repl.children[0].setAttribute('hidebuttons', repl.data.length === 1); this.setAttribute('owned', player.isOwned(this.buyalbum.product)); var tracks = data.tracks.map(function(track) { track.free = data.free; return track; }) this.container.tracks.repl.setAttribute('data', tracks) var tracks = data.tracks; this.updateTracks(data); var id = this.data.id var trackoffset = false; for (var i = 0; i < tracks.length; i++) { if (tracks[i].id == id) { trackoffset = i; break; } } // console.log('parentproduct', data, trackoffset, id) player.play(data, trackoffset); player.setAttributes({currenttrackonly: true}) this.highlightCurrentTrack(); this.setAttribute('data', data) if (data.parent) { this.parentproduct.setAttribute('url', '/product/' + data.parent) // console.log('found owner', data.parent) return; } this.updateTracks(data); this.buyalbum.setAttribute('price', buy.computePrice(data)) this.buyalbum.setAttribute('product', data) this.update(); if (! this._initopen) { // wait until data is processed before sliding open on initial load this.setAttribute('open', persist.draweropen) this._initopen = true; } var track = player.album.data.tracks[player.trackoffset] this.parent.parent.playerui.setAttribute('artisttitle', track.artist) var taglist = track.keywords.sort(); this.tags.repl.setAttribute('data', taglist) if (purchased && this.buyalbum.product) { this.setAttribute('owned', player.isOwned(this.buyalbum.product)); // console.log('purchased', this.buyalbum.product, this.owned) if (player.album.data) this.updateTracks(player.album.data) this.update(); } var text = this.text//.toLowerCase(); trackEvent('search', 'label', this.text) searchinput.setAttributes({text: text, value: text}) this.setAttribute('owned', player.isOwned(data)); // console.log('track owned', this.owned) var price = data.free ? 0 : 1.45; this.but.setAttribute('price', price) this.setAttribute('active', true) this.duration.setAttribute('opacity', 1) this.setAttribute('active', false) this.duration.setAttribute('opacity', 0) player.setAttribute('trackoffset', this.index); trackEvent('product', 'playing', this.data.id) this.label.setAttribute('text', data.title) if (data.duration) this.duration.setAttribute('text', data.duration) // player.download(this.parent.data) var product = this.parent.data; trackEvent('product', 'downloadbuttontrack', product.id) this.download.show(product) this.parent.setAttribute('active', true) this.parent.setAttribute('active', false) X this.setAttribute('opacity', 0); this.animate({opacity: 1}, 10) switch (this.state) { case 'label': this.state = 'track'; break; case 'track': this.state = 'release'; break; case 'release': this.state = 'title'; break; case 'title': this.state = 'artist'; break; case 'artist': this.state = 'label'; break; } this.updateText() if (this.tid) clearTimeout(this.tid); this.tid = setTimeout(this.update, 4000) this.label.setAttribute('text', this.state.toUpperCase()); this.value.setAttribute('text', this.parent[this.state + 'title']); trackEvent('product', 'buyitbutton', this.parent.data.id) this.parent.parent.drawer.setAttribute('open', true); buy.show(this.parent.data); this.parent.parent.drawer.highlightCurrentTrack(); // player.download(this.parent.data) var product = this.parent.data; trackEvent('product', 'downloadbuttonplayer', product.id) this.download.show(product) this.parent.setAttribute('active', true) this.parent.setAttribute('active', false) this.setAttribute('data', data); // console.log('title', data, player.trackoffset) this.parent.cover.setAttribute('url', data.imageurl) var tracks = data.tracks; var tracklabel = tracks.length + ' track'; if (tracks.length > 1) tracklabel += 's'; this.setAttribute('releasetitle', data.release) this.setAttribute('titletitle', data.title) this.setAttribute('artisttitle', data.artist) this.setAttribute('labeltitle', data.label) this.setAttribute('released', data.released) this.setAttribute('tracks', tracklabel) var track = tracks[player.trackoffset] this.setAttribute('tracktitle', track.title) this.readout.update(); if (this.data) { var track = this.data.tracks[player.trackoffset]; this.setAttribute('tracktitle', track.title) this.setAttribute('artisttitle', track.artist) this.readout.setAttribute('state', 'label'); this.readout.update(); } this.queue.locked = false; this.queue.updateQueue(tracks) this.skiponce = false; setTimeout(function() { queues.next(); },100) if (upnext.tracks.length){ var q = upnext; } else { var q = this.queue; } var children = q.repl.children; var lastchild = children[children.length - 1]; // console.info('next', lastchild, lastchild.inited, lastchild.visible) if (lastchild && lastchild.inited && lastchild.visible) { children.pop(); // console.log('lastchild', lastchild) lastchild.play(); } else { if (this.skiponce) { setTimeout(function() { queues.next(); },100) this.skiponce = false; return; } var next = q.tracks.pop(); // console.info('play', next.id) // this.queue.updateQueue(q.tracks) if (next && next.id == player.productid) { var next2 = q.tracks.pop(); player.play(next2) } player.play(next) } if (this.playlist && this.playlist.nextpage && children.length < 21 && children.length > 0) { // console.warn('length', children.length, this.playlist) this.queue.locked = false; this.skiponce = false; this.playlist.nextpage(); } // lock to prevent updates except when queues.play() is called (from a user) if (this.locked) return; this.locked = true; // console.log('updateQueue', data) // make a copy of the data to mutate var data = JSON.parse(JSON.stringify(data)); var tracks = data.tracks.reverse() if (tracks) { this.tracks = tracks; this.setAttribute('tracks', tracks) if (! (audio.playing && audio.url && audio.loading)) { // play first track of first result, but don't interrupt current audio playback this.parent.next(); } // console.info('data', audio.playing, audio.url, tracks) } // console.log('add', track, arguments) // make a copy of the track to mutate this.tracks.push(JSON.parse(JSON.stringify(track))) this.setAttribute('tracks', this.tracks) var pos = dockalbum.getAbsolute(); // console.log('show', dockalbum, pos) this.setAttributes({url: dockalbum.url, opacity: 1, x: pos.x, height: dockalbum.height}) var cover = target || playerui.cover; var coverpos = cover.getAbsolute() this.animate({height: cover.height, x: coverpos.x, opacity: .4}, 400) var _this = this; if (this.tid) clearTimeout(this.tid) this.tid = setTimeout(function() { _this.animate({opacity: 0}, 200) }, 420); if (persist.welcomed && this.destroyed !== true) this.destroy(); var _this = this; persist.set('welcomed', true); setTimeout(function() { if (_this.destroyed != true) _this.destroy() }, 600)

Welcome to the “Early Release” of the new Addictech.com storefront!

We’ve got some cool things for you to enjoy right away:

  • You can purchase music at a discounted price
  • All resolutions are now the same price!
  • New sample player
  • Instant buy and download
  • All of your historical orders you can now download in any other resolution, for free!

We’re still working on the final details, but we’re functioning and ready for your orders. We will be adding wishlist, subscriptions, custom playlists, streaming and a lot more. Please let us know your thoughts and ideas!

We would appreciate if you were to leave comments and requests in the Contact panel in the upper right hand corner of this site. It is absolutely essential to us that we know what you want so we can bring you the best music service in the universe!

Thank You

The Addictech Crew

X