nuvola-player-devel team mailing list archive
-
nuvola-player-devel team
-
Mailing list archive
-
Message #00139
[Merge] lp:~chase-t/nuvola-player/integration-grooveshark-mobile into lp:nuvola-player
Chase Colman has proposed merging lp:~chase-t/nuvola-player/integration-grooveshark-mobile into lp:nuvola-player.
Requested reviews:
Jiří Janoušek (fenryxo)
Related bugs:
Bug #1175088 in Nuvola Player: "Service Request: Grooveshark HTML5"
https://bugs.launchpad.net/nuvola-player/+bug/1175088
For more details, see:
https://code.launchpad.net/~chase-t/nuvola-player/integration-grooveshark-mobile/+merge/221972
Adds the Grooveshark Mobile HTML5 interface for Grooveshark to the available Nuvola Player services. This does not affect the original Grooveshark service.
--
https://code.launchpad.net/~chase-t/nuvola-player/integration-grooveshark-mobile/+merge/221972
Your team Nuvola Player Development is subscribed to branch lp:nuvola-player.
=== added directory 'data/nuvolaplayer/services/groovesharkmobile'
=== added file 'data/nuvolaplayer/services/groovesharkmobile/description.html'
--- data/nuvolaplayer/services/groovesharkmobile/description.html 1970-01-01 00:00:00 +0000
+++ data/nuvolaplayer/services/groovesharkmobile/description.html 2014-06-03 23:15:58 +0000
@@ -0,0 +1,23 @@
+<p><strong>Grooveshark</strong> is an international online music search engine,
+music streaming service and music recommendation web software application, allowing users
+to search for, stream, and upload music that can be played immediately or added
+to a playlist. An optional paid subscription adds additional functionality and removes
+advertisements.
+</p>
+<p><em>This is the HTML5-based mobile version of <strong>Grooveshark</strong> which does not require Flash.</em></p>
+<p><em>Source:
+<a href="http://en.wikipedia.org/wiki/Grooveshark">Grooveshark on Wikipedia</a>,
+<a href="http://grooveshark.com">Official website</a></em>
+</p>
+
+<h2>Country Availability</h2>
+
+<p><b>Grooveshark</b> is currently unavailable in Germany due to the excessive cost of operation.</p>
+<p><em>Source: <a href="http://help.grooveshark.com/customer/portal/articles/322794-inability-to-access-grooveshark-from-germany">Grooveshark Help - Inability to access Grooveshark from Germany</a></em></p>
+
+<h2>Playback Requirements</h2>
+
+<p><b>Grooveshark Mobile</b> requires <b>HTML5 audio</b> technology to play music.</p>
+<ul>
+<li><a href="https://answers.launchpad.net/nuvola-player/+faq/2277">How to install HTML5 Audio support</a></li>
+</ul>
=== added file 'data/nuvolaplayer/services/groovesharkmobile/integration.js'
--- data/nuvolaplayer/services/groovesharkmobile/integration.js 1970-01-01 00:00:00 +0000
+++ data/nuvolaplayer/services/groovesharkmobile/integration.js 2014-06-03 23:15:58 +0000
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2014 Chase Colman <chase@xxxxxxxxx>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Anonymous function is used not to pollute environment */
+(function(Nuvola){
+ /**
+ * Creates Grooveshark HTML5 integration binded to Nuvola JS API
+ * @param Nuvola Nuvola JS API
+ */
+ var Integration = function(){
+ // Overwrite default commnad function
+ Nuvola.onMessageReceived = Nuvola.bind(this, this.messageHandler);
+
+ // Reset
+ Nuvola.updateSong(null, null, null, null, Nuvola.STATE_NONE);
+
+ // For debug output
+ this.name = "Grooveshark-HTML5";
+
+ // Add local links to globals
+ this.audio = GS.audio;
+ this.queue = GS.models.queue;
+ this.session = GS.models.session;
+ this.radio = GS.views.Radio.prototype;
+
+ this.audio.bind("all", Nuvola.bind(this, this.playerHandler))
+ };
+
+ // Update the song
+ Integration.prototype.updateSong = function(name) {
+ var song = this.audio.model;
+ if (!song || name === "player:stopped") {
+ Nuvola.updateSong(null, null, null, null, Nuvola.STATE_NONE);
+ return;
+ }
+
+ // Broadcasts have a different model for songs
+ if (this.audio.isSubscribedToBroadcast()) {
+ song = song.get("activeSong");
+ }
+
+ var state = this.audio.audio.paused ? Nuvola.STATE_PAUSED : Nuvola.STATE_PLAYING;
+
+ // The song name is either stored in Name or SongName, for some reason.
+ Nuvola.updateSong(song.get("Name") || song.get("SongName"),
+ song.get("ArtistName"),
+ song.get("AlbumName"),
+ song.get("coverURL500"),
+ state);
+ }
+
+ // Update available actions based on context
+ Integration.prototype.updateActions = function(name) {
+ var radioIsVisible = !this.radio.el.hasClass('hidden');
+ var hasAudio = !!this.audio.model;
+ var hasFavorites = !!this.session.favorites;
+ Nuvola.updateAction(Nuvola.ACTION_TOGGLE_PLAY, hasAudio);
+ Nuvola.updateAction(Nuvola.ACTION_PREV_SONG, !!this.queue.getPrev());
+ Nuvola.updateAction(Nuvola.ACTION_NEXT_SONG, !!this.queue.getNext());
+ Nuvola.updateAction(Nuvola.ACTION_THUMBS_UP, radioIsVisible);
+ Nuvola.updateAction(Nuvola.ACTION_THUMBS_DOWN, radioIsVisible);
+ Nuvola.updateAction(Nuvola.ACTION_FAVORITE, hasAudio&&hasFavorites);
+ }
+
+ /**
+ * Handles Grooveshark player events
+ * @param name String namespace prefixed event name
+ * @param event Object event object
+ */
+ Integration.prototype.playerHandler = function(name, event){
+ var verb = name.split(':')[1];
+
+ // Match actions without the namespaces
+ switch (verb) {
+ case 'error':
+ case 'started':
+ case 'play':
+ case 'pause':
+ case 'stopped':
+ this.updateSong(name);
+ this.updateActions(name);
+ break;
+ }
+ }
+
+ /**
+ * Handles Nuvola user action messages
+ * @param cmd command to execute
+ */
+ Integration.prototype.messageHandler = function(cmd){
+ try{
+ switch (cmd) {
+ case Nuvola.ACTION_PLAY:
+ this.audio.play();
+ break;
+ case Nuvola.ACTION_PAUSE:
+ this.audio.audio.pause();
+ break;
+ case Nuvola.ACTION_TOGGLE_PLAY:
+ this.audio.pauseResume();
+ break;
+ case Nuvola.ACTION_PREV_SONG:
+ this.queue.prev()&&this.audio.playNow();
+ break;
+ case Nuvola.ACTION_NEXT_SONG:
+ this.audio.playNext();
+ break;
+ case Nuvola.ACTION_THUMBS_UP:
+ this.radio.smile({target: this.radio.$('.smile')});
+ break;
+ case Nuvola.ACTION_THUMBS_DOWN:
+ this.radio.frown();
+ break;
+ case Nuvola.ACTION_FAVORITE:
+ this.session.favorite(this.audio.model, [null,null]);
+ break;
+ default:
+ // Other commands are not supported
+ throw {"message": "Not supported."};
+ }
+ console.log(this.name + ": comand '" + cmd + "' executed.");
+ } catch(e){
+ // Older API expected exception to be a string
+ throw (this.name + ": " + e.message);
+ }
+ }
+
+ // Store reference
+ Nuvola.integration = new Integration(); // Singleton
+})(this);
=== added file 'data/nuvolaplayer/services/groovesharkmobile/metadata.conf'
--- data/nuvolaplayer/services/groovesharkmobile/metadata.conf 1970-01-01 00:00:00 +0000
+++ data/nuvolaplayer/services/groovesharkmobile/metadata.conf 2014-06-03 23:15:58 +0000
@@ -0,0 +1,10 @@
+name = Grooveshark Mobile
+home_page = https://html5.grooveshark.com/
+sandbox_pattern = (https?://\w*\.?grooveshark\.com/|https?://\w*\.?gs-cdn\.net)
+maintainer_name = Chase Colman
+maintainer_link = https://launchpad.net/~chase-t
+version = 1
+version_minor = 0
+api_major = 2
+flash_plugin = no
+requirements_specified = yes
Follow ups