Skip to content
Browse files

first commit

  • Loading branch information...
0 parents commit cb7d420d93c9c5a48ec1184e684acc81b1e37da4 Gabriel Testa committed Apr 4, 2011
Showing with 4,757 additions and 0 deletions.
  1. +395 −0 app-build.js
  2. +16 −0 app.js
  3. +36 −0 app/assistants/app-assistant.js
  4. +146 −0 app/assistants/dashboard-assistant.js
  5. +803 −0 app/assistants/gridScene-assistant.js
  6. +99 −0 app/assistants/login-assistant.js
  7. +8 −0 app/assistants/main-assistant.js
  8. +357 −0 app/assistants/mixDetailsScene-assistant.js
  9. +909 −0 app/assistants/player-assistant.js
  10. +224 −0 app/assistants/searchScrene-assistant.js
  11. +142 −0 app/assistants/splash-assistant.js
  12. +7 −0 app/assistants/stage-assistant.js
  13. +279 −0 app/assistants/userInfo-assistant.js
  14. +12 −0 app/views/dashboard/dashboard-player.html
  15. +1 −0 app/views/dashboard/dashboard-scene.html
  16. +91 −0 app/views/gridScene/gridScene-chrome.js
  17. 0 app/views/gridScene/gridScene-scene.html
  18. +88 −0 app/views/login/login-chrome.js
  19. 0 app/views/login/login-scene.html
  20. +225 −0 app/views/mixDetailsScene/mixDetailsScene-chrome.js
  21. 0 app/views/mixDetailsScene/mixDetailsScene-scene.html
  22. +130 −0 app/views/player/player-chrome.js
  23. 0 app/views/player/player-scene.html
  24. +107 −0 app/views/searchScrene/searchScrene-chrome.js
  25. 0 app/views/searchScrene/searchScrene-scene.html
  26. +32 −0 app/views/splash/splash-chrome.js
  27. 0 app/views/splash/splash-scene.html
  28. +140 −0 app/views/userInfo/userInfo-chrome.js
  29. 0 app/views/userInfo/userInfo-scene.html
  30. BIN appicon2.png
  31. +13 −0 appinfo.json
  32. +107 −0 ares.js
  33. +4 −0 ares_version.json
  34. +15 −0 dashboard.html
  35. +37 −0 depends.js
  36. +7 −0 framework_config.json
  37. BIN icon.jpg
  38. BIN images/8tracks.png
  39. BIN images/8tracksDash.png
  40. BIN images/8tracksDash2.png
  41. BIN images/8tracks_logo.jpg
  42. BIN images/White_Crystal.jpg
  43. BIN images/blue.jpg
  44. BIN images/check_mark.png
  45. BIN images/dashboard/album-art-overlay.png
  46. BIN images/dashboard/dashboard_buttons.png
  47. BIN images/forward.png
  48. BIN images/greydiant.jpg
  49. BIN images/likedstar.png
  50. BIN images/loading.gif
  51. BIN images/menu-icon-music-pause.png
  52. BIN images/menu-icon-music-play.png
  53. BIN images/mini_icon.png
  54. BIN images/mixlikeheart1.png
  55. BIN images/mixlikeheart2.png
  56. BIN images/mixunlikeheart1.png
  57. BIN images/no_image.png
  58. BIN images/overlay.png
  59. BIN images/pause1.png
  60. BIN images/playselected.png
  61. BIN images/playunselected.png
  62. BIN images/pure.jpg
  63. BIN images/red.png
  64. BIN images/speaker.png
  65. BIN images/tracks_01.png
  66. BIN images/trans-blue.png
  67. BIN images/trans50.png
  68. BIN images/unknownUser.jpg
  69. BIN images/unlikedstar.png
  70. BIN images/user_info.png
  71. BIN images/white-1.jpg
  72. +11 −0 index.html
  73. +77 −0 lib/audio.js
  74. +53 −0 lib/themeManager.js
  75. BIN sounds/error.mp3
  76. BIN sounds/nextmix.mp3
  77. BIN sounds/nextmix2.mp3
  78. +92 −0 sources.json
  79. +56 −0 stylesheets/dashboard.css
  80. +15 −0 stylesheets/list.css
  81. +23 −0 stylesheets/styles
395 app-build.js
395 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
16 app.js
@@ -0,0 +1,16 @@
+opus.depends({
+ paths: {
+ "Ares": "/Ares",
+ "mojo": "/usr/palm/frameworks/mojo/",
+ "opus": "$Ares/foss/opus/opus",
+ "Palm": "$Ares/ide",
+ "controls": "$opus/library/controls/",
+ "AresLib": "$Palm/library/Ares",
+ "MojoLib": "$Palm/library/Mojo/",
+ "Palm-Mojo": "$MojoLib/"
+ },
+ nobuild: [
+ "$mojo/mojo.js",
+ "app-build.js"
+ ]
+});
36 app/assistants/app-assistant.js
@@ -0,0 +1,36 @@
+function AppAssistant() {}
+
+AppAssistant.prototype.setup = function() {
+ this.loadFirstSceneHandler = this.loadFirstScene.bind(this);
+ this.loadDashboardHandler = this.loadDashboard.bind(this);
+ window.document.addEventListener(Mojo.Event.stageDeactivate, this.onDeactivateHandler.bind(this));
+ window.document.addEventListener(Mojo.Event.stageActivate, this.onActivateHandler.bind(this));
+};
+
+AppAssistant.prototype.onDeactivateHandler = function(event) {
+ var dashboardController = this.controller.getStageController('dashboard');
+ if (!dashboardController) {
+ this.controller.createStageWithCallback({
+ name: 'dashboard',
+ lightweight: true,
+ clickableWhenLocked: true
+ },
+ this.loadDashboardHandler, 'dashboard');
+ }
+};
+
+AppAssistant.prototype.onActivateHandler = function(event) {
+ var dashboardController = this.controller.getStageController('dashboard');
+ if (dashboardController) {
+ this.appController = Mojo.Controller.getAppController();
+ this.appController.closeStage('dashboard');
+ }
+};
+
+ AppAssistant.prototype.loadFirstScene = function(stageController) {
+ stageController.pushScene('gridScene');
+ };
+
+ AppAssistant.prototype.loadDashboard = function(stageController) {
+ stageController.pushScene('dashboard', DashPlayerInstance);
+ };
146 app/assistants/dashboard-assistant.js
@@ -0,0 +1,146 @@
+/* Copyright 2009 Palm, Inc. All rights reserved. */
+
+/*globals Mojo PowerManagerService Util Element AppAssistant */
+var DashboardAssistant = function(musicPlayer) {
+ this.musicPlayer = musicPlayer;
+ this.toggle = false;
+ // if there isn't anything in the musicPlayer, don't open up the dashboard
+ if (this.musicPlayer === 0) {
+ Mojo.Controller.getAppController().closeStage('dashboard');
+ }
+
+ this.appController = Mojo.Controller.getAppController();
+ this.locked = false;
+ this.setupListeners = function() {
+ this.musicPlayer.audio().addEventListener('ended', this.trackEnded.bind(this), false);
+ this.musicPlayer.audio().addEventListener('play', this.trackChange.bind(this), false);
+ this.musicPlayer.audio().addEventListener('pause', this.trackPaused.bind(this), false);
+ };
+ this.removeListeners = function() {
+ this.musicPlayer.audio().removeEventListener('ended', this.trackEnded.bind(this), false);
+ this.musicPlayer.audio().removeEventListener('play', this.trackChange.bind(this), false);
+ this.musicPlayer.audio().removeEventListener('pause', this.trackPaused.bind(this), false);
+ };
+};
+
+DashboardAssistant.prototype = {
+ setup: function() {
+ this.controller.get('dashboard-player').addEventListener(Mojo.Event.tap, this.tapHandler.bindAsEventListener(this));
+ if (typeof this.musicPlayer !== "undefined" && this.musicPlayer !== 0) {
+ if (typeof this.musicPlayer.audio() !== "undefined") {
+ this.setupListeners();
+ this.updateSong();
+ }
+ }
+ },
+
+ handleLockEvent: function(event) {
+ this.locked = !!event.locked;
+ },
+ cleanup: function() {
+ this.removeListeners();
+ Ares.cleanupSceneAssistant(this);
+ },
+
+ updateSong: function(arg) {
+ if (typeof arg === "undefined") {
+ Mojo.Log.info("Updating the dashboard");
+ var song = this.musicPlayer.song();
+ var data = {
+ title: song.name,
+ artist: song.artist,
+ pause: this.musicPlayer.isPlaying() ? "pause" : "",
+ unlike: this.musicPlayer.liked() ? "unlike" : ""
+ };
+ var renderedInfo = Mojo.View.render({
+ object: data,
+ template: 'dashboard/dashboard-player'
+ });
+ // Insert the HTML into the DOM, replacing the existing content.
+ this.controller.get('dashboard-player').update(renderedInfo);
+ myNewString = this.musicPlayer.photo().replace("original", "max200");
+ strarray = myNewString.split(".");
+ if (strarray[strarray.length - 1] === "jpeg" || strarray[strarray.length - 1] === "gif") myNewString = Mojo.appPath + "/images/8tracksDash2.png";
+ // the template render doesn't do this properly, doing it manually
+ this.controller.get('dashboard-player-art').style.background = "url(\"" + myNewString + "\") center center no-repeat";
+ }else{
+ Mojo.Log.info("Updating the dashboard");
+ var data = {
+ title: arg,
+ artist: "",
+ pause: this.musicPlayer.isPlaying() ? "pause" : "",
+ unlike: this.musicPlayer.liked() ? "unlike" : ""
+ };
+ var renderedInfo = Mojo.View.render({
+ object: data,
+ template: 'dashboard/dashboard-player'
+ });
+ // Insert the HTML into the DOM, replacing the existing content.
+ this.controller.get('dashboard-player').update(renderedInfo);
+ myNewString = this.musicPlayer.photo().replace("original", "max200");
+ strarray = myNewString.split(".");
+ if (strarray[strarray.length - 1] === "jpeg" || strarray[strarray.length - 1] === "gif") myNewString = Mojo.appPath + "/images/8tracksDash2.png";
+ // the template render doesn't do this properly, doing it manually
+ //var thumbUrl = this.musicPlayer.photo();//Util.albumArtLargeUrlFormatter(song.thumbnails[0]);
+ this.controller.get('dashboard-player-art').style.background = "url(\"" + myNewString + "\") center center no-repeat";
+ }
+ },
+ trackEnded: function(event) {
+ this.musicPlayer = DashPlayerInstance;
+ this.updateSong();
+ },
+ trackChange: function(event) {
+ this.musicPlayer = DashPlayerInstance;
+ this.updateSong();
+ },
+ trackPaused: function(event) {
+ if (!this.musicPlayer.isPlaying()) {
+ this.controller.get('playpause').removeClassName("pause");
+ } else {
+ this.controller.get('playpause').addClassName("pause");
+ }
+ },
+ togglePlay: function() {
+ if (this.musicPlayer.isPlaying()) {
+ this.controller.get('playpause').removeClassName("pause");
+ this.musicPlayer.audio().pause();
+ } else {
+ this.controller.get('playpause').addClassName("pause");
+ this.musicPlayer.audio().play();
+ }
+ },
+
+ toggleLike: function() {
+ if (this.musicPlayer.liked()) {
+ this.controller.get('likeunlike').removeClassName("unlike");
+ this.musicPlayer.toggleLike(false);
+ } else {
+ this.controller.get('likeunlike').addClassName("unlike");
+ this.musicPlayer.toggleLike(true);
+ }
+ },
+
+ updatePausePlayIcon: function() {
+ if (this.musicPlayer.isPlaying()) {
+ this.controller.get('playpause').addClassName("pause");
+ } else {
+ this.controller.get('playpause').removeClassName("pause");
+ }
+ },
+
+ tapHandler: function(event) {
+ var id = event.target.id;
+ if (id === 'playpause') {
+ this.togglePlay();
+ } else if (id === 'next') {
+ this.musicPlayer.skipTrack();
+ this.updateSong("Retrieving Next...");
+ } else if (id === 'likeunlike') {
+ this.toggleLike();
+ } else {
+ if (!this.locked) {
+ //AppAssistant.appManagerService.relaunchMusicPlayer();
+ }
+ }
+ }
+};
803 app/assistants/gridScene-assistant.js
@@ -0,0 +1,803 @@
+function GridSceneAssistant(argFromPusher, pagecount, setid, loggedin, username, password, userid) {
+ this.loggedin = loggedin;
+ this.userid = -1;
+ this.mixCount = 4;
+ if (loggedin) {
+ this.userid = userid;
+ this.username = username;
+ this.password = password;
+ this.mixCount = 7;
+ }
+ this.sCount = 1;
+ this.tracks = argFromPusher;
+ this.setid = setid;
+ this.currentpage = 1;
+ this.type = "recent";
+ this.typelabel = "Latest";
+ this.loaded = false;
+ this.getNextMix = function(count, total) {
+ return count % total;
+ };
+
+ this.pagecount = Math.round(parseInt(pagecount, 0) / 10);
+ this.writeDescription = function() {
+ if (this.typelabel == "My Mixes") {
+ this.$.divider1.setLabel(this.typelabel + " (" + this.currentpage + "/" + this.pagecount + ")"); //Latest Mixes ( 1/10)
+ } else {
+ this.$.divider1.setLabel(this.typelabel + " Mixes (" + this.currentpage + "/" + this.pagecount + ")"); //Latest Mixes ( 1/10)
+ }
+ this.controller.get('scroller2').mojo.revealTop();
+ };
+ this.popUp = function(title, message) {
+ this.controller.showAlertDialog({
+ title: title,
+ message: message,
+ choices: [
+ {
+ label: "OK",
+ value: "",
+ type: 'dismiss'
+ }
+ ]
+ });
+ };
+ this.fillList = function(tracks, setid) {
+ if (typeof setid !== "undefined") {
+ this.setid = setid;
+ }
+ var list = new Array(tracks.length);
+ for (var i = 0; i < tracks.length; i++) {
+ var name = tracks[i].name;
+ var tag = tracks[i].tag_list_cache;
+ if (name !== null) {
+ if (name.length > 30) {
+ name = name.substring(0, 30) + "...";
+ }
+ }
+ if (tag !== null) {
+ if (tag.length > 30) {
+ tag = tag.substring(0, 30) + "...";
+ }
+ }
+ list[i] = {
+ title: name,
+ leftImage: tracks[i].cover_urls.sq56.toString() === "/images/mix_covers/sq56.gif" ? Mojo.appPath + "/images/no_image.png" : tracks[i].cover_urls.sq56,
+ tag: tag,
+ mixInfo: tracks[i],
+ set_id: this.setid,
+ type: "mix"
+ };
+ }
+ listModel = {
+ items: list
+ };
+ return {
+ getList: function() {
+ return listModel;
+ }
+ };
+ };
+ this.fillUserList = function(users) {
+ var list = new Array(users.length);
+ for (var i = 0; i < users.length; i++) {
+ var bio = "No Bio Info";
+ if (users[i].bio_html !== null) {
+ if (users[i].bio_html.indexOf("<p>") >= 0) {
+ bio = users[i].bio_html.split("<p>")[1];
+ bio = bio.split("</p>")[0];
+ if (bio.length > 50) {
+ bio = bio.substring(0, 50) + "...";
+ }
+ }
+ }
+ list[i] = {
+ title: users[i].login,
+ leftImage: users[i].avatar_urls.sq56.toString() === "/images/avatars/sq56.jpg" ? Mojo.appPath + "/images/no_image.png" : users[i].avatar_urls.sq56,
+ tag: bio,
+ mixID: users[i].id,
+ type: "user",
+ userinfo: users[i]
+ //set_id: this.setid
+ };
+ }
+ listModel = {
+ items: list
+ };
+ return {
+ getList: function() {
+ return listModel;
+ }
+ };
+ };
+}
+
+GridSceneAssistant.prototype = {
+ setup: function() {
+ this.cmdMenuModel = {
+ visible: true,
+ items: [
+ {
+ items: [{
+ width: 30
+ }]
+ },
+ {
+ items: [{
+ icon: "back",
+ command: 'back',
+ label: $L("Back"),
+ disabled: this.currentpage === 1
+ },{
+ icon: "forward",
+ command: 'fwd',
+ label: $L("Forward")
+ }]
+ },
+ {
+ items: [{
+ label: 'Latest',
+ command: 'type'
+ }]
+ }]
+ };
+
+ this.controller.setupWidget(Mojo.Menu.commandMenu, {
+ //spacerHeight: 0,
+ menuClass: 'no-fade'
+ },
+ this.cmdMenuModel);
+ this.feedMenuModel = {
+ visible: true,
+ items: [
+ {
+ items: [{
+ width: 0
+ },
+ {
+ label: "8tracks",
+ width: 320
+ }]
+ }]
+ };
+ this.controller.setupWidget(Mojo.Menu.viewMenu, {
+ spacerHeight: 0,
+ menuClass: 'no-fade'
+ },
+ this.feedMenuModel);
+
+ this.cookie2 = new Mojo.Model.Cookie("prefs");
+ var thm = "none";
+ if (this.cookie2.get()) {
+ thm = this.cookie2.get().theme
+ }
+
+ this.appMenuModel = {
+ items: [
+ {
+ label: this.loggedin ? "Logout " + this.username : "Login",
+ command: this.loggedin ? 'logout' : 'login',
+ shortcut: 'l'
+ },
+ {
+ label: "Support",
+ command: 'support'
+ },
+ {
+ label: $L("Themes"),
+ items: [
+ {
+ label: "Dark",
+ command: 'dark',
+ iconPath: thm == 'dark' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ },
+ {
+ label: "Light",
+ command: 'lite',
+ iconPath: thm == 'lite' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ },
+ {
+ label: "Light2",
+ command: 'lite2',
+ iconPath: thm == 'lite2' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ },
+ {
+ label: "Flat White",
+ command: 'flat',
+ iconPath: thm == 'flat' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ },
+ {
+ label: "Blue",
+ command: 'blue',
+ iconPath: thm == 'blue' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ },
+ {
+ label: "Red",
+ command: 'red',
+ iconPath: thm == 'red' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ }
+ ]
+ }
+ ]
+ };
+ this.controller.setupWidget(Mojo.Menu.appMenu, {},
+ this.appMenuModel);
+ this.controller.document.addEventListener("keyup", this.keyupHandler.bind(this), true);
+ Ares.setupSceneAssistant(this);
+ },
+ cleanup: function() {
+ this.controller.document.removeEventListener("keyup", this.keyupHandler.bind(this), true);
+ Ares.cleanupSceneAssistant(this);
+ },
+ activate: function(response, username, password) {
+ this.cookie2 = new Mojo.Model.Cookie("prefs");
+ if (this.cookie2.get()) {
+ props = themeLookup(this.cookie2.get().theme);
+ this.controller.get('gridScene').style.backgroundImage = props.URL;
+ this.$.list1.style.addStyles({
+ textColor: props.textColor
+ });
+ }
+ if (response) {
+ if (typeof response.search === "undefined") {
+ this.loggedin = response.loggedin;
+ this.username = response.username;
+ this.password = response.password;
+ this.userid = response.id;
+ this.appMenuModel.items[0].command = "logout";
+ this.appMenuModel.items[0].label = "Logout " + this.username;
+ this.mixCount = 7;
+ this.controller.modelChanged(this.appMenuModel, this);
+ }
+ }
+ if (!this.loaded) {
+ this.showBanner("Just Type to Search...");
+ this.loaded = true;
+ }
+ if (this.type != "followed") {
+ f = this.fillList(this.tracks);
+ this.controller.setWidgetModel("list1", f.getList());
+ this.writeDescription();
+ } else {
+ var onComplete = function(transport) {
+ if (transport.status === 200) {
+ this.currentpage = 1;
+ this.pagecount = Math.round(parseInt(transport.responseJSON.total_entries, 0) / 10);
+ this.$.divider1.setLabel("Followed Users (" + this.currentpage + "/" + this.pagecount + ")"); //Latest Mixes ( 1/10)
+ this.controller.get('scroller2').mojo.revealTop();
+ this.cmdMenuModel.items[2].items[0].label = this.typelabel;
+ this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1;
+ this.cmdMenuModel.items[2].items[0].label = this.typelabel;
+ //this.cmdMenuModel.items[2].items[0].command = this.type;
+ this.controller.modelChanged(this.cmdMenuModel, this);
+ f = this.fillUserList(transport.responseJSON.users);
+ this.controller.setWidgetModel("list1", f.getList());
+ }
+ this.showSpinner(false);
+ };
+ var onFailure = function(transport) {
+ this.popUp("Oops!", "Couldn't retreive page " + this.currentpage);
+ };
+ url = "http://8tracks.com/users/" + this.userid + "/follows_users.json";
+ this.request(url, onComplete.bind(this), onFailure.bind(this));
+ }
+ this.showSpinner(false);
+ },
+ showBanner: function(message) {
+ Mojo.Controller.getAppController().showBanner(message, {
+ source: 'notification'
+ });
+ },
+ keyupHandler: function(event) {
+ if (Mojo.Char.isValidWrittenChar(event.keyCode) || Mojo.Char.isDigit(event.keyCode)) {
+ if (event.srcElement.innerHTML.indexOf("mojo-scene-gridScene-scene-scroller") > 0 && event.srcElement.innerHTML.indexOf("mojo-scene-gridScene-scene-scroller") < 10) {
+ this.controller.stageController.pushScene('searchScrene', event.keyCode, this.userid);
+ }
+ }
+ },
+ MixChange: function(direction) {
+ this.sCount = this.getNextMix(this.sCount + direction, this.mixCount);
+ if (this.sCount < 1) {
+ this.sCount = this.mixCount;
+ } else if (this.sCount > this.mixCount) {
+ this.sCount = 1;
+ }
+ switch (this.sCount) {
+ case 1:
+ reload = true;
+ if (this.type !== "recent") {
+ this.type = "recent";
+ this.typelabel = "Latest";
+ }
+ break;
+ case 2:
+ if (this.type !== "popular") {
+ reload = true;
+ this.type = "popular";
+ this.typelabel = "Popular";
+ }
+ // popular
+ break;
+ case 3:
+ // hot
+ if (this.type !== "hot") {
+ reload = true;
+ this.type = "hot";
+ this.typelabel = "Hot";
+ }
+ break;
+ case 4:
+ // random
+ if (this.type !== "random") {
+ reload = true;
+ this.type = "random";
+ this.typelabel = "Random";
+ }
+ break;
+ case 5:
+ if (this.type !== "liked") {
+ reload = true;
+ this.type = "liked";
+ this.typelabel = "Liked";
+ }
+ break;
+ case 6:
+ if (this.type !== "mine") {
+ reload = true;
+ this.type = "mine";
+ this.typelabel = "My Mixes";
+ }
+ break;
+ case 7:
+ if (this.type !== "followed") {
+ reload = true;
+ this.type = "followed";
+ this.typelabel = "Following";
+ }
+ break;
+ }
+ if (reload && this.type !== "followed") {
+ var onComplete = function(transport) {
+ this.currentpage = 1;
+ this.controller.modelChanged(this.cmdMenuModel, this);
+ this.tracks = transport.responseJSON.mixes;
+ this.setid = transport.responseJSON.mix_set_id;
+ this.pagecount = Math.ceil(parseInt(transport.responseJSON.total_entries, 0) / 10);
+ this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1;
+ this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount;
+ this.cmdMenuModel.items[2].items[0].label = this.typelabel;
+ //this.cmdMenuModel.items[2].items[0].command = this.type;
+ this.controller.modelChanged(this.cmdMenuModel,this);
+ this.writeDescription();
+ f = this.fillList(this.tracks, transport.responseJSON.mix_set_id);
+ this.controller.setWidgetModel("list1", f.getList());
+ this.showSpinner(false);
+ };
+ var onFailure = function(transport) {
+ this.showSpinner(false);
+ this.popUp("Oops!", "Couldn't retreive page " + this.currentpage);
+ };
+ var url = "";
+ if (this.type === "liked") {
+ url = "http://8tracks.com/users/" + this.userid + "/mixes.json?view=liked";
+ } else if (this.type === "mine") {
+ url = "http://8tracks.com/users/" + this.userid + "/mixes.json";
+ } else {
+ url = "http://8tracks.com/mixes.json?page=1&sort=" + this.type;
+ }
+ this.request(url, onComplete.bind(this), onFailure.bind(this));
+ } else if (reload && this.type === "followed") {
+ var onComplete = function(transport) {
+ if (transport.status === 200) {
+ this.currentpage = 1;
+ this.pagecount = Math.ceil(parseInt(transport.responseJSON.total_entries, 0) / 10);
+ this.$.divider1.setLabel("Followed Users (" + this.currentpage + "/" + this.pagecount + ")"); //Latest Mixes ( 1/10)
+ this.controller.get('scroller2').mojo.revealTop();
+ this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1;
+ this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount;
+ this.cmdMenuModel.items[2].items[0].label = this.typelabel;
+ //this.cmdMenuModel.items[2].items[0].command = this.type;
+ this.controller.modelChanged(this.cmdMenuModel,this);
+ f = this.fillUserList(transport.responseJSON.users);
+ this.controller.setWidgetModel("list1", f.getList());
+ }
+ this.showSpinner(false);
+ };
+ var onFailure = function(transport) {
+ this.popUp("Oops!", "Couldn't retreive page " + this.currentpage);
+ };
+ url = "http://8tracks.com/users/" + this.userid + "/follows_users.json";
+ this.request(url, onComplete.bind(this), onFailure.bind(this));
+ }
+ },
+ showSpinner: function(show) {
+ if (!show) {
+ this.feedMenuModel.items[0].items[1].width = 320;
+ this.feedMenuModel.items[0].items[0].width = 0;
+ this.controller.modelChanged(this.feedMenuModel, this);
+ } else {
+ this.feedMenuModel.items[0].items[1].width = 275;
+ this.feedMenuModel.items[0].items[0].width = 45;
+ this.controller.modelChanged(this.feedMenuModel, this);
+ }
+ this.$.spinner1.setSpinning(show);
+ },
+ popupChoose: function(event) {
+ var reload = false;
+ switch (event) {
+ case "l_mixes":
+ reload = true;
+ this.sCount = 1;
+ if (this.type !== "recent") {
+ this.type = "recent";
+ this.typelabel = "Latest";
+ }
+ break;
+ case 'p_mixes':
+ this.sCount = 2;
+ if (this.type !== "popular") {
+ reload = true;
+ this.type = "popular";
+ this.typelabel = "Popular";
+ }
+ // popular
+ break;
+ case 'h_mixes':
+ // hot
+ this.sCount = 3;
+ if (this.type !== "hot") {
+ reload = true;
+ this.type = "hot";
+ this.typelabel = "Hot";
+ }
+ break;
+ case 'r_mixes':
+ // random
+ this.sCount = 4;
+ if (this.type !== "random") {
+ reload = true;
+ this.type = "random";
+ this.typelabel = "Random";
+ }
+ break;
+ case 'liked':
+ this.sCount = 5;
+ if (this.type !== "liked") {
+ reload = true;
+ this.type = "liked";
+ this.typelabel = "Liked";
+ }
+ break;
+ case 'mine':
+ this.sCount = 6;
+ if (this.type !== "mine") {
+ reload = true;
+ this.type = "mine";
+ this.typelabel = "My Mixes";
+ }
+ break;
+ case 'followed':
+ this.sCount = 7;
+ if (this.type !== "followed") {
+ reload = true;
+ this.type = "followed";
+ this.typelabel = "Following";
+ }
+ break;
+ }
+ if (reload && this.type !== "followed") {
+ var onComplete = function(transport) {
+ this.currentpage = 1;
+ this.tracks = transport.responseJSON.mixes;
+ this.setid = transport.responseJSON.mix_set_id;
+ this.pagecount = Math.ceil(parseInt(transport.responseJSON.total_entries, 0) / 10);
+ this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1;
+ this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount;
+ this.cmdMenuModel.items[2].items[0].label = this.typelabel;
+ // this.cmdMenuModel.items[2].items[0].command = this.type;
+ this.controller.modelChanged(this.cmdMenuModel, this);
+ this.writeDescription();
+ f = this.fillList(this.tracks, transport.responseJSON.mix_set_id);
+ this.controller.setWidgetModel("list1", f.getList());
+ this.showSpinner(false);
+ };
+ var onFailure = function(transport) {
+ this.showSpinner(false);
+ this.popUp("Oops!", "Couldn't retreive page " + this.currentpage);
+ };
+ var url = "";
+ if (this.type === "liked") {
+ url = "http://8tracks.com/users/" + this.userid + "/mixes.json?view=liked";
+ } else if (this.type === "mine") {
+ url = "http://8tracks.com/users/" + this.userid + "/mixes.json";
+ } else {
+ url = "http://8tracks.com/mixes.json?page=1&sort=" + this.type;
+ }
+ this.request(url, onComplete.bind(this), onFailure.bind(this));
+ } else if (reload && this.type === "followed") {
+ var onComplete = function(transport) {
+ if (transport.status === 200) {
+ this.currentpage = 1;
+ this.pagecount = Math.ceil(parseInt(transport.responseJSON.total_entries, 0) / 10);
+ this.$.divider1.setLabel("Followed Users (" + this.currentpage + "/" + this.pagecount + ")"); //Latest Mixes ( 1/10)
+ this.controller.get('scroller2').mojo.revealTop();
+ this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1;
+ this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount;
+ this.cmdMenuModel.items[2].items[0].label = this.typelabel;
+ // this.cmdMenuModel.items[2].items[0].command = this.type;
+ this.controller.modelChanged(this.cmdMenuModel, this);
+ f = this.fillUserList(transport.responseJSON.users);
+ this.controller.setWidgetModel("list1", f.getList());
+ }
+ this.showSpinner(false);
+ };
+ var onFailure = function(transport) {
+ this.popUp("Oops!", "Couldn't retreive page " + this.currentpage);
+ };
+ url = "http://8tracks.com/users/" + this.userid + "/follows_users.json";
+ this.request(url, onComplete.bind(this), onFailure.bind(this));
+ }
+ },
+ request: function(url, onComplete, onFailure) {
+ this.showSpinner(true);
+ var myAjax = new Ajax.Request(url, {
+ method: "get",
+ evalJSON: 'force',
+ contentType: 'application/x-www-form-urlencoded',
+ requestHeaders: {
+ "USER_AGENT": navigator.userAgent
+ },
+ onComplete: onComplete,
+ onFailure: onFailure
+ });
+ },
+ getPreviousPage: function() {
+ if (this.currentpage - 1 > 0) {
+ this.currentpage -= 1;
+ var onComplete = function(transport) {
+ this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1;
+ this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount;
+ this.controller.modelChanged(this.cmdMenuModel, this);
+ this.tracks = transport.responseJSON.mixes;
+ this.writeDescription();
+ f = this.fillList(this.tracks);
+ this.controller.setWidgetModel("list1", f.getList());
+ this.showSpinner(false);
+ };
+ var onFailure = function(transport) {
+ this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1;
+ this.controller.modelChanged(this.cmdMenuModel, this);
+ this.showSpinner(false);
+ this.popUp("Oops!", "Couldn't retreive page " + this.currentpage);
+ };
+ if (this.type === "liked") {
+ url = "http://8tracks.com/users/" + this.userid + "/mixes.json?view=liked&page=" + this.currentpage;
+ } else {
+ url = "http://8tracks.com/mixes.json?page=" + this.currentpage + "&sort=" + this.type;
+ }
+ this.request(url, onComplete.bind(this), onFailure.bind(this));
+ }
+ },
+ getNextPage: function() {
+ this.currentpage += 1;
+ var onComplete = function(transport) {
+ this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1;
+ this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount;
+ this.controller.modelChanged(this.cmdMenuModel, this);
+ this.tracks = transport.responseJSON.mixes;
+ this.writeDescription();
+ f = this.fillList(this.tracks);
+ this.controller.setWidgetModel("list1", f.getList());
+ this.showSpinner(false);
+ };
+ var onFailure = function(transport) {
+ this.cmdMenuModel.items[1].items[0].disabled = this.currentpage === 1;
+ this.cmdMenuModel.items[1].items[1].disabled = this.currentpage === this.pagecount;
+ this.cmdMenuModel.items[2].items[0].label = this.typelabel;
+ this.showSpinner(false);
+ this.popUp("Oops!", "Couldn't retreive page " + this.currentpage);
+ };
+ if (this.type === "liked") {
+ url = "http://8tracks.com/users/" + this.userid + "/mixes.json?view=liked&page=" + this.currentpage;
+ } else {
+ url = "http://8tracks.com/mixes.json?page=" + this.currentpage + "&sort=" + this.type;
+ }
+ this.request(url, onComplete.bind(this), onFailure.bind(this));
+ },
+ list1Listtap: function(inSender, event) {
+ if (event.item.type === "mix") {
+ this.controller.stageController.pushScene('mixDetailsScene', event.item.mixInfo, event.item.set_id, this.userid, this.username, this.password);
+ } else {
+ this.controller.stageController.pushScene('userInfo', event.item.userinfo, this.userid, this.username, this.password);
+ }
+ }
+};
+
+GridSceneAssistant.prototype.handleCommand = function(event) {
+ this.controller = Mojo.Controller.stageController.activeScene();
+ var resetCheck = function(command) {
+ for (i = 0; i < this.appMenuModel.items[2].items.length; i++) {
+ if (this.appMenuModel.items[2].items[i].command == command) {
+ this.appMenuModel.items[2].items[i].iconPath = Mojo.appPath + "/images/check_mark.png";
+ } else {
+ this.appMenuModel.items[2].items[i].iconPath = "none";
+ }
+ }
+ }.bind(this);
+ if (event.type == Mojo.Event.command) {
+ switch (event.command) {
+ case 'fwd':
+ if (this.currentpage < this.pagecount) {
+ this.getNextPage();
+ }
+ break;
+ case 'back':
+ if (this.currentpage !== 1) {
+ this.getPreviousPage();
+ }
+ break;
+ case 'search':
+ this.controller.stageController.pushScene('searchScrene');
+ break;
+ case 'dark':
+ this.cookie = new Mojo.Model.Cookie("prefs");
+ this.cookie.put({
+ theme: event.command
+ });
+ props = themeLookup(event.command);
+ this.controller.get('gridScene').style.backgroundImage = props.URL;
+ this.$.list1.style.addStyles({
+ textColor: props.textColor
+ });
+ resetCheck(event.command);
+ break;
+ case 'lite':
+ this.cookie = new Mojo.Model.Cookie("prefs");
+ this.cookie.put({
+ theme: event.command
+ });
+ props = themeLookup(event.command);
+ this.controller.get('gridScene').style.backgroundImage = props.URL;
+ this.$.list1.style.addStyles({
+ textColor: props.textColor
+ });
+ resetCheck(event.command);
+ break;
+ case 'lite2':
+ this.cookie = new Mojo.Model.Cookie("prefs");
+ this.cookie.put({
+ theme: event.command
+ });
+ props = themeLookup(event.command);
+ this.controller.get('gridScene').style.backgroundImage = props.URL;
+ this.$.list1.style.addStyles({
+ textColor: props.textColor
+ });
+ resetCheck(event.command);
+ break;
+ case 'flat':
+ this.cookie = new Mojo.Model.Cookie("prefs");
+ this.cookie.put({
+ theme: event.command
+ });
+ props = themeLookup(event.command);
+ this.controller.get('gridScene').style.backgroundImage = props.URL;
+ this.$.list1.style.addStyles({
+ textColor: props.textColor
+ });
+ resetCheck(event.command);
+ break;
+ case 'blue':
+ this.cookie = new Mojo.Model.Cookie("prefs");
+ this.cookie.put({
+ theme: event.command
+ });
+ props = themeLookup(event.command);
+ this.controller.get('gridScene').style.backgroundImage = props.URL;
+ this.$.list1.style.addStyles({
+ textColor: props.textColor
+ });
+ resetCheck(event.command);
+ break;
+ case 'red':
+ this.cookie = new Mojo.Model.Cookie("prefs");
+ this.cookie.put({
+ theme: event.command
+ });
+ props = themeLookup(event.command);
+ this.controller.get('gridScene').style.backgroundImage = props.URL;
+ this.$.list1.style.addStyles({
+ textColor: props.textColor
+ });
+ resetCheck(event.command);
+ break;
+ case 'login':
+ this.controller.stageController.pushScene('login');
+ break;
+ case 'logout':
+ this.cookie = new Mojo.Model.Cookie("credentials");
+ this.cookie.put({
+ username: "",
+ password: "",
+ token: 0
+ });
+ this.loggedin = false;
+ this.username = "";
+ this.password = "";
+ this.userid = -1;
+ this.mixCount = 4;
+ this.appMenuModel.items[0].command = "login";
+ this.appMenuModel.items[0].label = "Login";
+ this.controller.modelChanged(this.appMenuModel, this);
+ break;
+ case 'support':
+ this.controller.serviceRequest("palm://com.palm.applicationManager", {
+ method: 'open',
+ parameters: {
+ id: "com.palm.app.email",
+ params: {
+ summary: "8tracks Support Request: v1.2.9",
+ recipients: [{
+ type: "email",
+ role: 1,
+ value: "GTestaSoftware@gmail.com",
+ contactDisplay: "8tracks Support"
+ }]
+ }
+ }
+ });
+ break;
+ case 'type':
+ this.controller.popupSubmenu({
+ onChoose: this.popupChoose,
+ placeNear: event.originalEvent.target,
+ items: [
+ {
+ label: 'Latest',
+ command: 'l_mixes',
+ iconPath: this.type == 'recent' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ },
+ {
+ label: 'Popular',
+ command: 'p_mixes',
+ iconPath: this.type == 'popular' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ },
+ {
+ label: 'Hot',
+ command: 'h_mixes',
+ iconPath: this.type == 'hot' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ },
+ {
+ label: 'Random',
+ command: 'r_mixes',
+ iconPath: this.type == 'random' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ },
+ {
+ label: 'Liked',
+ command: 'liked',
+ disabled: !this.loggedin,
+ iconPath: this.type == 'liked' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ },
+ {
+ label: 'My Mixes',
+ command: 'mine',
+ disabled: !this.loggedin,
+ iconPath: this.type == 'mine' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ },
+ {
+ label: 'Following',
+ command: 'followed',
+ disabled: !this.loggedin,
+ iconPath: this.type == 'followed' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ }]
+ });
+ break;
+ }
+ } else if (event.type === Mojo.Event.back) {
+ event.stop();
+ this.MixChange(-1);
+ } else if (event.type === Mojo.Event.forward) {
+ event.stop();
+ this.MixChange(1);
+
+ }
+};
99 app/assistants/login-assistant.js
@@ -0,0 +1,99 @@
+function LoginAssistant(argFromPusher) {
+ this.popUp = function(title, message) {
+ this.controller.showAlertDialog({
+ title: title,
+ message: message,
+ choices: [
+ {
+ label: "OK",
+ value: "",
+ type: 'dismiss'
+ }
+ ]
+ });
+ };
+}
+
+LoginAssistant.prototype = {
+ setup: function() {
+ Ares.setupSceneAssistant(this);
+ },
+ cleanup: function() {
+ Ares.cleanupSceneAssistant(this);
+ },
+ showSpinner: function(show) {
+ this.controller.get('activityButton1').mojo[(show ? 'activate' : 'deactivate')]();
+ },
+ activate: function(args) {
+ this.cookie2 = new Mojo.Model.Cookie("prefs");
+ if (this.cookie2.get()) {
+ props = themeLookup(this.cookie2.get().theme);
+ this.controller.get('login').style.backgroundImage = props.URL;
+ this.$.textField1.style.addStyles({
+ textColor: props.textColor
+ });
+ this.$.passwordField1.style.addStyles({
+ textColor: props.textColor
+ });
+ }
+ },
+
+ login: function(username, password) {
+ var postdata = "login=" + username + "&password=" + password;
+
+ var myAjax = new Ajax.Request(url, {
+ method: "post",
+ parameters: postdata,
+ onComplete: onComplete,
+ onFailure: onFailure
+ });
+ },
+
+ requestLogin: function(onComplete, onFailure) {
+ url = "http://8tracks.com/sessions.json";
+ this.username = this.controller.get("textField1").mojo.getValue();
+ this.password = this.controller.get("passwordField1").mojo.getValue();
+
+ var postdata = "login=" + this.username + "&password=" + this.password;
+
+ var myAjax = new Ajax.Request(url, {
+ method: "post",
+ parameters: postdata,
+ onComplete: onComplete,
+ onFailure: onFailure
+ });
+ },
+ showBanner: function(message) {
+ Mojo.Controller.getAppController().showBanner(message, {
+ source: 'notification'
+ });
+ },
+ activityButton1Tap: function(inSender, event) {
+ this.showSpinner(true);
+ var onComplete = function(transport) {
+ if (transport.responseJSON.status === "200 OK") {
+ this.cookie = new Mojo.Model.Cookie("credentials");
+ this.cookie.put({
+ username: this.username,
+ password: this.password,
+ token: transport.responseJSON.auth_token
+ });
+ this.showBanner("You are now logged in as " + this.username);
+ var data = {
+ loggedin: true,
+ username: this.username,
+ password: this.password,
+ id: transport.responseJSON.current_user.id
+ };
+ this.controller.stageController.popScene(data);
+ } else {
+ this.popUp(tranport.responseJSON.status, transport.responseJSON.statusText);
+ }
+ };
+ var onFailure = function(transport) {
+ this.popUp(tranport.responseJSON.status, transport.responseJSON.statusText);
+ };
+ this.requestLogin(onComplete.bind(this), onFailure.bind(this));
+ this.showSpinner(false);
+ }
+};
8 app/assistants/main-assistant.js
@@ -0,0 +1,8 @@
+function MainAssistant() {
+}
+
+MainAssistant.prototype.cleanup = function() {
+ // launch the dashboard when the main card scene is discarded
+ Mojo.Controller.getAppController().assistant.handleLaunch({action: 'dashboard'});
+ MainAssistant.prototype.cleanup = function() {}; // changing the cleanup method so that it doesn't launch a dashboard the second time
+}
357 app/assistants/mixDetailsScene-assistant.js
@@ -0,0 +1,357 @@
+function MixDetailsSceneAssistant(argFromPusher, setid, userid, username, password) {
+ this.userid = -1;
+ if (userid !== -1) {
+ this.loggedin = true;
+ this.userid = userid;
+ this.username = username;
+ this.password = password;
+ this.cookie = new Mojo.Model.Cookie("credentials");
+ if (this.cookie.get()) {
+ this.token = this.cookie.get().token;
+ }
+ }
+ this.mixInfo = argFromPusher;
+ this.liked = this.mixInfo.liked_by_current_user;
+ this.setid = setid;
+ this.writeDetails = function(name, description, tags) {
+ this.$.name.setLabel(name);
+ this.$.description.setLabel(description);
+ this.$.tags.setLabel(tags);
+ };
+ this.setPicture = function(picture) {
+ this.$.picture1.setSrc(picture);
+ };
+ this.setUserInfo = function(info) {
+ this.$.creator.setLabel(info);
+ };
+ this.checkBoxState = function(checked) {
+ this.$.checkBox1.setValue(checked);
+ };
+ this.showBanner = function(message) {
+ Mojo.Controller.getAppController().showBanner(message, {
+ source: 'notification'
+ });
+ };
+ this.popUp = function(title, message) {
+ this.showBanner(message);
+ };
+}
+
+MixDetailsSceneAssistant.prototype = {
+ setup: function() {
+ if (this.userid === -1) {
+ this.cmdMenuModel = {
+ visible: true,
+ items: [
+ {
+ items: [{
+ iconPath: 'images/user_info.png',
+ label: $L('Info'),
+ command: 'info'
+ }]
+ },{
+ items: [{
+ label: $L('Listen'),
+ command: 'play'
+ }]
+ }]
+ };
+ } else {
+ if (!this.liked) {
+ this.cmdMenuModel = {
+ visible: true,
+ items: [
+ {
+ items: [{
+ iconPath: 'images/user_info.png',
+ label: $L('Info'),
+ command: 'info'
+ }]
+ },
+ {
+ items: [{
+ iconPath: 'images/mixlikeheart2.png',
+ label: $L('Like'),
+ command: 'like'
+ }]
+ },
+ {
+ items: [{
+ label: $L('Listen'),
+ command: 'play'
+ }]
+ }]
+ };
+ } else {
+ this.cmdMenuModel = {
+ visible: true,
+ items: [
+ {
+ items: [{
+ iconPath: 'images/user_info.png',
+ label: $L('Info'),
+ command: 'info'
+ }]
+ },
+ {
+ items: [{
+ iconPath: 'images/mixunlikeheart1.png',
+ label: $L('Unlike'),
+ command: 'unlike'
+ }]
+ },
+ {
+ items: [{
+ label: $L('Listen'),
+ command: 'play'
+ }]
+ }]
+ };
+ }
+ }
+
+ this.controller.setupWidget(Mojo.Menu.commandMenu, {
+ menuClass: 'no-fade'
+ },
+ this.cmdMenuModel);
+ this.feedMenuModel = {
+ visible: true,
+ items: [
+ {
+ items: [{
+ width: 0
+ },
+ {
+ label: this.mixInfo.name,
+ width: 320
+ }]
+ }
+ ]
+ };
+ this.controller.setupWidget(Mojo.Menu.viewMenu, {
+ spacerHeight: 0,
+ menuClass: 'no-fade'
+ },
+ this.feedMenuModel);
+
+ this.appMenuModel = {
+ items: [
+ {
+ label: "Share Mix...",
+ command: 'share'
+ }
+ ]
+ };
+ this.controller.setupWidget(Mojo.Menu.appMenu, {},
+ this.appMenuModel);
+ Ares.setupSceneAssistant(this);
+ },
+ cleanup: function() {
+ Ares.cleanupSceneAssistant(this);
+ },
+ activate: function(data) {
+ this.cookie2 = new Mojo.Model.Cookie("prefs");
+ if (this.cookie2.get()) {
+ props = themeLookup(this.cookie2.get().theme);
+ this.controller.get('mixDetailsScene').style.backgroundImage = props.URL;
+ this.$.tags.style.addStyles({
+ textColor: props.textColor
+ });
+ this.$.name.style.addStyles({
+ textColor: props.textColor
+ });
+ this.$.description.style.addStyles({
+ textColor: props.textColor
+ });
+ this.$.creator.style.addStyles({
+ textColor: props.textColor
+ });
+ }
+ if (typeof data !== "undefined") {
+ if (data.mixInfo.name != this.mixInfo.name) {
+ this.mixInfo = data.mixInfo;
+ this.feedMenuModel.items[0].items[1].label = this.mixInfo.name;
+ this.controller.modelChanged(this.feedMenuModel, this);
+ }
+ if (this.loggedin && this.liked !== data.likedMix) {
+ response = {
+ responseJSON: {
+ status: "200 OK",
+ bypass: true
+ }
+ };
+ if (data.likedMix) {
+ this.LikedComplete(response);
+ } else {
+ this.UnLikedComplete(response);
+ }
+ if(typeof data.error !== "undefined"){
+ switch(data.error){
+ case 1:
+ break;
+ case 2:
+ break;
+ case 3:
+ break;
+ default:
+ this.showBanner("There was an error playing that last mix!");
+ break;
+ }
+ }
+ }
+ }
+ this.showSpinner(false);
+ this.writeDetails(this.mixInfo.name, this.mixInfo.description, this.mixInfo.tag_list_cache);
+ this.setPicture(this.mixInfo.user.avatar_urls.sq56);
+ this.setUserInfo(this.mixInfo.user.login);
+ },
+
+ showSpinner: function(show) {
+ if (!show) {
+ this.feedMenuModel.items[0].items[1].width = 320;
+ this.feedMenuModel.items[0].items[0].width = 0;
+ this.controller.modelChanged(this.feedMenuModel, this);
+ } else {
+ this.feedMenuModel.items[0].items[1].width = 275;
+ this.feedMenuModel.items[0].items[0].width = 45;
+ this.controller.modelChanged(this.feedMenuModel, this);
+ }
+ this.$.spinner1.setSpinning(show);
+ },
+ request: function(url, onComplete, onFailure) {
+ this.showSpinner(true);
+ var myAjax = new Ajax.Request(url, {
+ method: "get",
+ evalJSON: 'force',
+ contentType: 'application/x-www-form-urlencoded',
+ requestHeaders: {
+ "USER_AGENT": navigator.userAgent
+ },
+ onComplete: onComplete,
+ onFailure: onFailure
+ });
+ },
+ playMix: function() {
+ var onComplete = function(transport) {
+ if (transport.status == 200) {
+ this.showSpinner(false);
+ this.controller.stageController.pushScene('player', this.mixInfo, this.token, transport.responseJSON, this.mixInfo.cover_urls.original, this.setid, this.userid, this.username, this.password, this.cmdMenuModel.items[1].items[0].command);
+ }
+ };
+ var onFailure = function(transport) {
+ this.showSpinner(false);
+ this.popUp(transport.responseJSON.status, transport.responseJSON.notices[0]);
+ };
+ var url = "http://8tracks.com/sets/" + this.token + "/play.json?mix_id=" + this.mixInfo.id;
+ this.request(url, onComplete.bind(this), onFailure.bind(this));
+ },
+ loadPlaylist: function() {
+ var onComplete = function(transport) {
+ if (transport.status == 200) {
+ this.token = transport.responseJSON.play_token;
+ this.playMix();
+ } else {
+ this.popUp("Error", "Didn't Get 200 from json response");
+ }
+ };
+ var onFailure = function() {
+ this.showSpinner(false);
+ this.popUp("Oops", "failed to get play_token");
+ };
+ var url = "http://8tracks.com/sets/new.json";
+ this.request(url, onComplete.bind(this), onFailure.bind(this));
+ },
+ Like: function() {
+ var onFailure = function(transport) {
+ this.popUp("Error", "Could not add mix to your liked mix. Try to login again");
+ };
+
+ var postdata = "login=" + this.username + "&password=" + this.password;
+ var url = "http://8tracks.com/mixes/" + this.mixInfo.id + "/like.json";
+ var myAjax = new Ajax.Request(url, {
+ method: "post",
+ requestHeader: postdata,
+ onComplete: this.LikedComplete.bind(this),
+ onFailure: onFailure.bind(this)
+ });
+ },
+ LikedComplete: function(response) {
+ if (response.responseJSON.status === "200 OK") {
+ if (typeof response.responseJSON.bypass === "undefined") {
+ this.popUp("Success", "Mixed added to your Liked list");
+ }
+ this.liked = true;
+ this.cmdMenuModel.items[1].items[0].iconPath = 'images/mixunlikeheart1.png';
+ this.cmdMenuModel.items[1].items[0].label = "Unlike";
+ this.cmdMenuModel.items[1].items[0].command = "unlike";
+ this.controller.modelChanged(this.cmdMenuModel, this);
+ } else {
+ this.popUp(response.responseJSON.status, response.responseJSON.notices);
+ }
+ },
+ UnLike: function() {
+ var onFailure = function(transport) {
+ this.popUp("Error", "Could not remove mix to your liked mix. Try to login again");
+ };
+ var postdata = "login=" + this.username + "&password=" + this.password;
+ url = "http://8tracks.com/mixes/" + this.mixInfo.id + "/unlike.json";
+ var myAjax = new Ajax.Request(url, {
+ method: "post",
+ requestHeader: postdata,
+ onComplete: this.UnLikedComplete.bind(this),
+ onFailure: onFailure.bind(this)
+ });
+ },
+ UnLikedComplete: function(response) {
+ if (response.responseJSON.status === "200 OK") {
+ if (typeof response.responseJSON.bypass === "undefined") {
+ this.popUp("Success", "Mixed removed from your Liked list");
+ }
+ this.liked = false;
+ this.cmdMenuModel.items[1].items[0].iconPath = 'images/mixlikeheart2.png';
+ this.cmdMenuModel.items[1].items[0].label = "Like";
+ this.cmdMenuModel.items[1].items[0].command = "like";
+ this.controller.modelChanged(this.cmdMenuModel, this);
+ } else {
+ this.popUp(response.responseJSON.status, response.responseJSON.notices);
+ }
+ }
+};
+
+MixDetailsSceneAssistant.prototype.handleCommand = function(event) {
+ this.controller = Mojo.Controller.stageController.activeScene();
+ if (event.type == Mojo.Event.command) {
+ switch (event.command) {
+ case 'play':
+ this.loadPlaylist();
+ break;
+ case 'info':
+ this.controller.stageController.pushScene('userInfo', this.mixInfo.user, this.userid, this.username, this.password);
+ break;
+ case 'like':
+ this.Like();
+ break;
+ case 'unlike':
+ this.UnLike();
+ break;
+ case 'share':
+ this.controller.serviceRequest("palm://com.palm.applicationManager", {
+ method: 'open',
+ parameters: {
+ id: "com.palm.app.email",
+ params: {
+ summary: "Checkout this 8tracks mix!",
+ text: "Checkout this Mix: \n" + this.mixInfo.name + "\nwww.8tracks.com" + this.mixInfo.path
+ }
+ }
+ });
+ break;
+ }
+ } else if (event.type === Mojo.Event.back) {
+ data = {
+ search: true
+ };
+ event.stop();
+ this.controller.stageController.popScene(data);
+ }
+};
909 app/assistants/player-assistant.js
@@ -0,0 +1,909 @@
+function PlayerAssistant(argFromPusher, token, response, mixphoto, setid, userid, username, password, liked) {
+ this.mixID = argFromPusher;
+ this.token = token;
+ this.userid = -1;
+ this.loggedin = false;
+ if (userid !== -1) {
+ this.liked = liked == "unlike";
+ this.userid = userid;
+ this.username = username;
+ this.password = password;
+ this.loggedin = true;
+ }
+ this.toggle = false;
+ this.tracks = new Array();
+ this.tracks.push(response.set.track);
+ this.trackinfo = response;
+ this.mphoto = mixphoto.toString() === "/images/mix_covers/original.gif" ? Mojo.appPath + "/images/tracks_01.png" : mixphoto;
+ this.lastsong = false;
+ this.songProps = new Array(); //skipped durations liked
+ this.toReadableTime = function(duration) {
+ var minutes = parseFloat(duration) / 60.0;
+ var seconds = Math.round((minutes % 1) * 60);
+ var s = (seconds / 100).toFixed(2);
+ var s1 = seconds.toString().split(".");
+ return s1[0].toString().length > 1 ? Math.floor(minutes) + ":" + s1[0] : Math.floor(minutes) + ":0" + s1[0];
+ };
+ this.listindex = 0;
+ this.setid = setid;
+ this.songstate = 1;
+ this.headsetService = undefined;
+ this.setupListeners = function() {
+ this.audio1.addEventListener('ended', this.trackEnded.bind(this), false);
+ this.audio1.addEventListener('play', this.trackPlay.bind(this), false);
+ this.audio1.addEventListener('playing', this.trackPlaying.bind(this), false);
+ this.audio1.addEventListener('pause', this.trackPaused.bind(this), false);
+ this.audio1.addEventListener('timeupdate', this.updateScrubber.bind(this), false);
+ this.audio1.addEventListener('stalled', this.trackStalled.bind(this), false);
+ this.audio1.addEventListener('error', this.trackError.bind(this), false);
+ this.audio1.addEventListener('canplay', this.trackReady.bind(this), false);
+ this.audio1.addEventListener('ratechange', this.trackRateChange.bind(this), false);
+ this.audio1.addEventListener('durationchange', this.trackDurationChanged.bind(this), false);
+ };
+ this.removeListeners = function() {
+ this.audio1.removeEventListener('pause', this.trackPaused.bind(this), false);
+ this.audio1.removeEventListener('play', this.trackPlay.bind(this), false);
+ this.audio1.removeEventListener('playing', this.trackPlaying.bind(this), false);
+ this.audio1.removeEventListener('Ended', this.trackEnded.bind(this), false);
+ this.audio1.removeEventListener('timeupdate', this.updateScrubber.bind(this), false);
+ this.audio1.removeEventListener('stalled', this.trackStalled.bind(this), false);
+ this.audio1.removeEventListener('error', this.trackError.bind(this), false);
+ this.audio1.removeEventListener('canplay', this.trackReady.bind(this), false);
+ this.audio1.removeEventListener('ratechange', this.trackRateChange.bind(this), false);
+ this.audio1.removeEventListener('durationchange', this.trackDurationChanged.bind(this), false);
+ };
+ this.writeDescription = function() {
+ this.$.divider2.setLabel("Tracks(" + this.tracks.length + ")");
+ };
+ this.downloaded = false;
+ if (typeof this.audio1 !== "object") {
+ this.audio1 = new Audio();
+ }
+ this.sound = new Audio();
+ this.sound.autoplay = true;
+ this.downloadImage = function(url, onSuccess, onFailure) {
+ if (!this.downloaded) {
+ split = url.split("/");
+ name = split[split.length - 1];
+ name = name.split(".")[0] + "." + name.split(".")[2];
+ this.controller.serviceRequest('palm://com.palm.downloadmanager/', {
+ method: 'download',
+ parameters: {
+ target: url,
+ targetDir: "/media/internal/files/8tracks",
+ targetFilename: name,
+ keepFilenameOnRedirect: false,
+ subscribe: false
+ },
+ onSuccess: onSuccess,
+ onFailure: onFailure
+ });
+ this.downloaded = true;
+ }
+ };
+ this.fillList = function(tracks) {
+ this.list = new Array(tracks.length);
+ for (var i = 0; i < tracks.length; i++) {
+ if (i !== tracks.length - 1) {
+ if (this.songProps[i].skipped) {
+ this.list[i] = {
+ title: tracks[i].name,
+ currentartist: tracks[i].performer,
+ skipped: tracks[i].name,
+ likeImage: this.songProps[i].liked === true ? "images/likedstar.png" : "images/unlikedstar.png",
+ duration: this.songProps[i].duration.toString() === "NaN:NaN" ? "?" : this.songProps[i].duration,
+ liked: this.songProps[i].liked
+ };
+ } else {
+ this.list[i] = {
+ title: tracks[i].name,
+ currentartist: tracks[i].performer,
+ oldsong: tracks[i].name,
+ likeImage: this.songProps[i].liked === true ? "images/likedstar.png" : "images/unlikedstar.png",
+ duration: this.songProps[i].duration.toString() == "NaN:NaN" ? "?" : this.songProps[i].duration,
+ liked: this.songProps[i].liked
+ };
+ }
+ } else {
+ if (this.songProps[i].set === false) {
+ this.songProps[i].liked = tracks[i].faved_by_current_user;
+ this.songProps[i].set = true;
+ }
+ this.list[i] = {
+ title: tracks[i].name,
+ currentartist: tracks[i].performer,
+ currentsong: tracks[i].name,
+ likeImage: "images/speaker.png",
+ duration: "...",
+ liked: this.songProps[i].liked
+ };
+ }
+ }
+ listModel = {
+ items: this.list.reverse()
+ };
+ return {
+ getList: function() {
+ return listModel;
+ }
+ };
+ };
+ this.populateList = function() {
+ f = this.fillList(this.tracks);
+ this.controller.setWidgetModel("list1", f.getList());
+ };
+ this.banner = function(message) {
+ Mojo.Controller.getAppController().showBanner(message, {
+ source: 'notification'
+ });
+ };
+}
+
+PlayerAssistant.prototype = {
+ setup: function() {
+ this.feedMenuModel = {
+ visible: true,
+ items: [
+ {
+ items: [{
+ width: 0
+ },
+ {
+ label: this.mixID.name,
+ width: 320
+ }]
+ }]
+ };
+ this.controller.setupWidget(Mojo.Menu.viewMenu, {
+ spacerHeight: 0,
+ menuClass: 'no-fade'
+ },
+ this.feedMenuModel);
+ this.cmdMenuModel = {
+ visible: true,
+ items: [
+ {},
+ {
+ items: [{
+ iconPath: 'images/pause1.png',
+ label: $L('Pause'),
+ command: '0'
+ },{
+ iconPath: 'images/forward.png',
+ label: $L('Forward'),
+ command: 'fwd'
+ }]
+ },{}]
+ };
+
+ this.controller.setupWidget(Mojo.Menu.commandMenu, {
+ //spacerHeight: 0,
+ menuClass: 'no-fade'
+ },
+ this.cmdMenuModel);
+ this.cookie3 = new Mojo.Model.Cookie("nmp");
+ if (!this.cookie3.get()) {
+ nmpState = 'autoplay';
+ } else {
+ nmpState = this.cookie3.get().answer;
+ }
+
+ this.appMenuModel = {
+ items: [
+ {
+ label: "Share Mix...",
+ command: 'share'
+ },
+ {
+ label: this.liked ? "Unlike Mix" : "Like Mix",
+ command: this.liked ? 'unlike' : 'like',
+ disabled: !this.loggedin
+ },
+ {
+ label: "Auto-play Next Mix",
+ command: nmpState == 'autoplay' ? "return" : "autoplay",
+ iconPath: nmpState == 'autoplay' ? Mojo.appPath + "/images/check_mark.png" : "none"
+ }
+ ]
+ };
+
+ if (!this.loggedin) {
+ this.appMenuModel.items[1].label = "Like Mix (Login Required)";
+ }
+ this.controller.setupWidget(Mojo.Menu.appMenu, {},
+ this.appMenuModel);
+
+ this.controller.setupWidget("progressbarId", this.attributes = {
+ title: "Progress Bar",
+ image: "images/header-icon.png",
+ modelProperty: "progress"
+ },
+ this.model = {
+ iconPath: "../images/progress-bar-background.png",
+ progress: 0
+ });
+
+ this.headsetService = new Mojo.Service.Request('palm://com.palm.keys/headset', {
+ method: 'status',
+ parameters: {
+ 'subscribe': true
+ },
+ onFailure: function() {
+ Mojo.Log.error("Could not subscribe to headset events");
+ },
+ onSuccess: this.handleheadset.bind(this)
+ });
+
+ if (this.audio1.currentSrc.length > 0) {
+ this.removeListeners();
+ this.audio1.pause();
+ this.audio1 = 0;
+ this.audio1 = new Audio();
+ }
+ this.setupListeners();
+ Ares.setupSceneAssistant(this);
+ },
+ cleanup: function() {
+ this.audio1.pause();
+ this.removeListeners();
+ this.audio1 = 0;
+ if (this.headsetService) {
+ this.headsetService.cancel();
+ }
+ DashPlayerInstance = 0;
+ Ares.cleanupSceneAssistant(this);
+ },
+ activate: function() {
+ this.showSpinner(true);
+ this.cookie2 = new Mojo.Model.Cookie("prefs");
+ if (this.cookie2.get()) {
+ props = themeLookup(this.cookie2.get().theme);
+ this.controller.get('player').style.backgroundImage = props.URL;
+ this.$.list1.style.addStyles({
+ textColor: props.textColor
+ });
+ }
+ this.$.picture1.setSrc(this.mphoto);
+
+ songprop = {
+ skipped: false,
+ duration: 0,
+ liked: false,
+ set: false
+ };
+ this.songProps.push(songprop);
+ this.writeDescription();
+ this.populateList();
+ if (!this.audio1.paused) {
+ this.audio1.pause();
+ }
+ this.audio1.src = this.trackinfo.set.track.url;
+ this.audio1.load();
+
+ DashPlayerInstance = new DashboardPlayer();
+ DashPlayerInstance.setSkipEvent(this.skipTrack.bind(this));
+ DashPlayerInstance.setLikeToggleEvent(this.setLikeStateCurrent.bind(this));
+ DashPlayerInstance.update(this.audio1, this.mphoto, this.trackinfo);
+ },
+ showSpinner: function(show) {
+ if (!show) {
+ this.feedMenuModel.items[0].items[1].width = 320;
+ this.feedMenuModel.items[0].items[0].width = 0;
+ this.controller.modelChanged(this.feedMenuModel, this);
+ } else {
+ this.feedMenuModel.items[0].items[1].width = 275;
+ this.feedMenuModel.items[0].items[0].width = 45;
+ this.controller.modelChanged(this.feedMenuModel, this);
+ }
+ this.$.spinner1.setSpinning(show);
+ },
+
+ showBanner: function(message) {
+ Mojo.Controller.getAppController().showBanner(message, {
+ source: 'notification'
+ });
+ },
+ handleheadset: function(payload) {
+ if (payload.state == "double_click") {
+ this.skipTrack();
+ } else if (payload.state == "single_click") {
+ this.toggleSongState();
+ }
+ },
+ modifyListElementDuration: function() {
+ if (this.audio1.duration.toString() !== "Infinity" || this.audio1.duration.toString() !== "undefined") {
+ if (this.list[0].duration === "...") {
+ this.list[0].duration = this.toReadableTime(this.audio1.duration);
+ listModel = {
+ items: this.list.reverse()
+ };
+ this.controller.modelChanged("list1", listModel);
+ }
+ }
+ },
+ updateScrubber: function(event) {
+ if (this.audio1.duration.toString() !== "NaN") {
+ var time = (parseFloat(this.audio1.currentTime) / parseFloat(this.audio1.duration));
+ this.model.progress = time;
+ this.controller.modelChanged(this.model, this);
+ if (this.audio1.currentTime + 2 > this.audio1.buffered.end()) {
+ if (Math.ceil(this.audio1.buffered.end()) != Math.ceil(this.audio1.duration)) {
+ this.songState(0);
+ this.load();
+ }
+ }
+ }
+ },
+
+ requestNext: function(url, onComplete, onFailure) {
+ this.showSpinner(true);
+ this.model.progress = 0;
+ this.controller.modelChanged(this.model, this);
+ var myAjax = new Ajax.Request(url, {
+ method: "get",
+ evalJSON: 'force',
+ contentType: 'application/x-www-form-urlencoded',
+ requestHeaders: {
+ "USER_AGENT": navigator.userAgent
+ },
+ onComplete: onComplete,
+ onFailure: onFailure
+ });
+ },
+ loadNextMix2: function() {
+ this.cookie3 = new Mojo.Model.Cookie("nmp");
+ if (this.cookie3.get()) {
+ if (this.cookie3.get().answer === 'autoplay') {
+ this.loadNextMix();
+ } else {
+ this.controller.stageController.popScene("finished");
+ }
+ } else {
+ this.askForNMPref();
+ }
+ },
+ loadNextMix: function() {
+ var onComplete = function(transport) {
+ if (transport.status == 200) {
+ this.showBanner(" New Mix: " + transport.responseJSON.next_mix.name);
+ this.mphoto = transport.responseJSON.next_mix.cover_urls.original;
+ this.$.picture1.setSrc(this.mphoto);
+ this.model.progress = 0;
+ this.controller.modelChanged(this.model, this);
+ this.mixID = transport.responseJSON.next_mix;
+ this.feedMenuModel.items[0].items[1].label = this.mixID.name;
+ this.controller.modelChanged(this.feedMenuModel, this);
+ this.setid = this.mixID.id;
+ var onComplete = function(transport) {
+ if (transport.status == 200) {
+ this.audio1.pause();
+ this.audio1.src = transport.responseJSON.set.track.url;
+ this.audio1.load();
+ var response = transport.responseJSON;
+ this.tracks = [];
+ this.tracks = new Array();
+ this.tracks.push(response.set.track);
+ this.trackinfo = response;
+ DashPlayerInstance.update(this.audio1, this.mphoto, this.trackinfo);
+ this.lastsong = false;
+ this.songProps = [];
+ this.songProps = new Array();
+ songprop = {
+ skipped: false,
+ duration: 0,
+ liked: false,
+ set: false
+ };
+ this.songProps.push(songprop);
+ this.listindex = 0;
+ this.songstate = 1;
+ this.showBanner("Now Playing: " + transport.responseJSON.set.track.performer + " - " + transport.responseJSON.set.track.name);
+ this.populateList();
+ this.writeDescription();
+ }
+ };
+ var onFailure = function(transport) {
+ this.showSpinner(false);
+ this.popUp("", "");
+ };
+ var url = "http://8tracks.com/sets/" + this.token + "/play.json?mix_id=" + this.mixID.id;
+ this.requestNext(url, onComplete.bind(this), onFailure.bind(this));
+ }
+ };
+ var onFailure = function(transport) {
+ this.controller.stageController.popScene(true);
+ };
+ url = "http://8tracks.com/sets/" + this.token + "/play_next_mix.json?mix_id=" + this.mixID.id;
+ this.requestNext(url, onComplete.bind(this), onFailure.bind(this));
+ },
+ skipTrack: function() {
+ var onComplete = function(transport) {
+ if (transport.status == 200) {
+ this.lastsong = transport.responseJSON.set.at_end;
+ if (!this.lastsong) {
+ this.model.progress = 0;
+ this.controller.modelChanged(this.model, this);
+ if (typeof this.audio1 !== "undefined") {
+ dur = this.toReadableTime(this.audio1.duration);
+ } else {
+ dur = 0;
+ }
+ this.songProps[this.songProps.length - 1].skipped = true;
+ this.songProps[this.songProps.length - 1].duration = dur;
+ props = {
+ skipped: false,
+ duration: 0,
+ liked: false
+ };
+ this.songProps.push(props);
+ this.audio1.pause();
+ this.lastsong = transport.responseJSON.set.at_end;
+ this.track = transport.response;
+ this.audio1.src = transport.responseJSON.set.track.url;
+ this.showBanner("Now Playing: " + transport.responseJSON.set.track.performer + " - " + transport.responseJSON.set.track.name);
+ this.audio1.load();
+ this.tracks.push(transport.responseJSON.set.track);
+ this.trackinfo = transport.responseJSON;
+ DashPlayerInstance.update(this.audio1, this.mphoto, this.trackinfo);
+ this.populateList();
+ this.writeDescription();
+ } else {
+ this.loadNextMix2();
+ }
+ } else if (transport.status === "403 Forbidden") {
+ this.sound.src = Mojo.appPath + "/sounds/error.mp3";
+ this.sound.play();
+ this.Popup("Oops!", "Can't skip anymore");
+ }
+ };
+ var onFailure = function(transport) {
+ this.showSpinner(false);
+ this.Popup("Oops", "No more skips allowed...");
+ };
+ var url = "http://8tracks.com/sets/46048603/skip.json?mix_id=" + this.mixID.id;
+ this.requestNext(url, onComplete.bind(this), onFailure.bind(this));
+ },
+ askForNMPref: function() {
+ this.controller.showAlertDialog({
+ onChoose: this.setMixPref.bind(this),
+ title: "Nex Mix Preference",
+ message: "What do you want to do now?",
+ choices: [
+ {
+ label: "Auto Play",
+ value: "autoplay",
+ type: 'affirmative'
+ },{
+ label: "Back to Mix Details",
+ value: "return",
+ type: 'negative'
+ }
+ ]
+ });
+ },
+ setMixPref: function(response, noskip) {
+ switch (response) {
+ case 'autoplay':
+ this.cookie3 = new Mojo.Model.Cookie("nmp");
+ this.cookie3.put({
+ answer: 'autoplay'
+ });
+ // this.appMenuModel.items[2].label = "Auto-play Next Mix";
+ this.appMenuModel.items[2].command = 'return';
+ this.appMenuModel.items[2].iconPath = Mojo.appPath + "/images/check_mark.png";//false;
+ this.controller.modelChanged(this.appMenuModel, this);
+ if (typeof noskip === "undefined") {
+ this.showBanner("Selection Saved");
+ this.loadNextMix();
+ }
+ break;
+ case 'return':
+ this.cookie3 = new Mojo.Model.Cookie("nmp");
+ this.cookie3.put({
+ answer: 'return'
+ });
+ //this.appMenuModel.items[2].label = "Auto-play Next Mix: Off";
+ this.appMenuModel.items[2].command = 'autoplay';
+ this.appMenuModel.items[2].iconPath = "";
+ //this.appMenuModel.items[2].iconPath = Mojo.appPath + "images\check_mark.png";//false;
+ this.controller.modelChanged(this.appMenuModel, this);
+ if (typeof noskip === "undefined") {
+ this.showBanner("Selection Saved");
+ this.controller.stageController.popScene("finished");
+ }
+ break;
+ }
+ },
+ nextTrack: function() {
+ var onComplete = function(transport) {
+ if (transport.status == 200) {
+ this.lastsong = transport.responseJSON.set.at_end;
+ if (!this.lastsong) {
+ this.model.progress = 0;
+ this.controller.modelChanged(this.model, this);
+ if (typeof this.audio1 !== "undefined") {
+ dur = this.toReadableTime(this.audio1.duration);
+ } else {
+ dur = 0;
+ }
+ this.songProps[this.songProps.length - 1].duration = dur;
+ props = {
+ skipped: false,
+ duration: 0,
+ liked: false
+ };
+ this.songProps.push(props);
+ this.audio1.pause();
+ this.track = transport.response;
+ this.audio1.src = transport.responseJSON.set.track.url;
+ this.showBanner("Now Playing: " + transport.responseJSON.set.track.performer + " - " + transport.responseJSON.set.track.name);
+ this.audio1.load();
+ this.tracks.push(transport.responseJSON.set.track);
+ this.trackinfo = transport.responseJSON;
+ DashPlayerInstance.update(this.audio1, this.mphoto, this.trackinfo);