Merge lp:~mims-michael/nuvola-player/bugfix1049253 into lp:nuvola-player/2.5.x

Proposed by Michael Mims
Status: Merged
Approved by: Jiří Janoušek
Approved revision: 660
Merged at revision: 658
Proposed branch: lp:~mims-michael/nuvola-player/bugfix1049253
Merge into: lp:nuvola-player/2.5.x
Diff against target: 224 lines (+88/-49)
2 files modified
data/nuvolaplayer/services/rdio/integration.js (+82/-44)
data/nuvolaplayer/services/rdio/metadata.conf (+6/-5)
To merge this branch: bzr merge lp:~mims-michael/nuvola-player/bugfix1049253
Reviewer Review Type Date Requested Status
Jiří Janoušek Approve
Review via email: mp+157699@code.launchpad.net

Description of the change

Updated integration to JSApi 2. Added a hack/fix to toggle playback on the first play to address initial muted playback. The problem appears to be with the AudioFactory of the Rdio client side js and not with WebkitGTK.

To post a comment you must log in.
Revision history for this message
Jiří Janoušek (fenryxo) wrote :

Thanks, Michael, for your work. I'm sorry for a late reply, but I have time for Nuvola Player only during weekends.

=== modified file 'data/nuvolaplayer/services/rdio/integration.js'
8 - Copyright 2012 Stefan Lohmaier <email address hidden>
9 + Copyright 2012 Michael Mims <email address hidden>

Did you rewrite this script from scratch? If not, you cannot remove Stefan's copyright.

-----8<------

=== modified file 'data/nuvolaplayer/services/rdio/integration.js'
36 + * client js side). See Nuvola bug #1049253.

Please use notation "LP:1049253".

-----8<------

=== modified file 'data/nuvolaplayer/services/rdio/metadata.conf'
178 version = 2
179 -version_minor = 4
180 -flash_plugin = no
181 +version_minor = 5

Increase version to 3.0 instead of 2.5.

review: Needs Fixing
Revision history for this message
Michael Mims (mims-michael) wrote :

There's not really anything remaining from Stefan's original code as I also contributed the last major update to this integration (https://code.launchpad.net/~mims-michael/nuvola-player/rdio-fix/+merge/114234) that he did not respond to. However, I will add his credits back in this next commit.

659. By Michael Mims

Added credits for original Rdio maintainer; Changed version to 3.0.

Revision history for this message
Jiří Janoušek (fenryxo) wrote :

> There's not really anything remaining from Stefan's original code as I also contributed the last major update to this integration.

I see, in that case you can remove Stefan's copyright again. Could you also relicense the code under 2-Clause BSD license? You can use license header from /data/nuvolaplayer/services/googleplay/integration.js.

review: Needs Information
660. By Michael Mims

Updated license to 2-Clause BSD.

Revision history for this message
Jiří Janoušek (fenryxo) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/nuvolaplayer/services/rdio/integration.js'
2--- data/nuvolaplayer/services/rdio/integration.js 2012-08-17 17:50:56 +0000
3+++ data/nuvolaplayer/services/rdio/integration.js 2013-04-16 14:00:44 +0000
4@@ -1,25 +1,27 @@
5 /*
6- Nuvola Player :: Cloud music integration
7-
8- This script provides integration of the Rdio streaming service
9- on the JavaScript side. It's executed when Rdio page is completely
10- loaded.
11-
12-
13- Copyright 2012 Stefan Lohmaier <stefan.lohmaier@googlemail.com>
14-
15-This program is free software: you can redistribute it and/or modify it
16-under the terms of the GNU General Public License version 3, as published
17-by the Free Software Foundation.
18-
19-This program is distributed in the hope that it will be useful, but
20-WITHOUT ANY WARRANTY; without even the implied warranties of
21-MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
22-PURPOSE. See the GNU General Public License for more details.
23-
24-You should have received a copy of the GNU General Public License along
25-with this program. If not, see <http://www.gnu.org/licenses/>.
26-*/
27+ * Copyright 2013 Michael Mims <mims.michael@gmail.com>
28+ *
29+ * Redistribution and use in source and binary forms, with or without
30+ * modification, are permitted provided that the following conditions are met:
31+ *
32+ * 1. Redistributions of source code must retain the above copyright notice, this
33+ * list of conditions and the following disclaimer.
34+ * 2. Redistributions in binary form must reproduce the above copyright notice,
35+ * this list of conditions and the following disclaimer in the documentation
36+ * and/or other materials provided with the distribution.
37+ *
38+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
39+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
40+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
42+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
43+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
47+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48+ */
49+
50
51 /* Anonymous function is used not to pollute environment */
52 (function(Nuvola){
53@@ -27,18 +29,43 @@
54 * Creates Rdio integration binded to Nuvola JS API
55 */
56 var Integration = function(){
57- /* Overwrite default commnad function */
58- Nuvola.command = Nuvola.bind(this, this.command);
59+ /* Overwrite default command function */
60+ Nuvola.onMessageReceived = Nuvola.bind(this, this.messageHandler);
61
62 /* For debug output */
63 this.name = "Rdio";
64
65 /* Let's run */
66 this.state = Nuvola.STATE_NONE;
67+ this.firstPlayToggled = false;
68 this.update();
69- this.timeout = setInterval(Nuvola.bind(this, this.update), 500);
70 };
71
72+ /**
73+ * Toggles playback the first time a play action is received
74+ * This is a temporary hack to try to work around a known issue with WebkitGTK
75+ * initial volume levels (although testing seems to indicate it might be on rdio
76+ * client js side). See Nuvola bug LP:1049253.
77+ */
78+ Integration.prototype.firstPlayToggle = function () {
79+ if(this.firstPlayToggled != true) {
80+ try {
81+ var player = R.Services.Player;
82+ player.playPause();
83+
84+ setTimeout(function () {
85+ player.playPause();
86+ console.debug("[firstPlayToggle] First play toggle completed");
87+ }, 750);
88+
89+ console.debug("[firstPlayToggle] First play toggle began");
90+ this.firstPlayToggled = true;
91+ }
92+ catch(e) {
93+ console.debug("[firstPlayToggle] Player service not available");
94+ }
95+ }
96+ }
97
98 /**
99 * Updates current playback state
100@@ -52,10 +79,7 @@
101 var song = null;
102 var can_prev;
103 var can_next;
104- var can_thumbs_up = false;
105- var can_thumbs_down = false;
106- var can_favorite = false;
107-
108+
109 try{
110 var playingTrack = R.Services.Player.model.get("playingTrack").attributes;
111 album_art = playingTrack.icon;
112@@ -64,17 +88,22 @@
113 song = playingTrack.name;
114 }
115 catch(e){
116- //~ console.debug("Unable to obtain song info: " + e.message);
117+ console.debug("Unable to obtain song info: " + e.message);
118 }
119
120 try{
121 var state = Nuvola.STATE_NONE;
122
123- var rdiostate = R.Services.Player.model.attributes.playState;//new
124+ var rdiostate = R.Services.Player.model.attributes.playState;
125
126 switch (rdiostate){
127- case 0: state = Nuvola.STATE_PAUSED; break;
128- case 1: state = Nuvola.STATE_PLAYING; break;
129+ case 0:
130+ state = Nuvola.STATE_PAUSED;
131+ break;
132+ case 1:
133+ state = Nuvola.STATE_PLAYING;
134+ this.firstPlayToggle();
135+ break;
136 }
137
138 if(state != Nuvola.STATE_NONE){
139@@ -86,38 +115,47 @@
140
141 }
142 catch(e){
143+ // console.debug("Unable to obtain state info: " + e.message);
144 can_prev = can_next = false;
145 }
146
147 this.state = state;
148
149 // Submit data to Nuvola backend
150- Nuvola.dataChanged(
151- song, artist, album, album_art,
152- state, can_prev, can_next,
153- can_thumbs_up, can_thumbs_down, can_favorite);
154+ Nuvola.updateSong(song, artist, album, album_art, state);
155+
156+ if(this.can_next !== can_next){
157+ this.can_next = can_next;
158+ Nuvola.updateAction(Nuvola.ACTION_NEXT_SONG, can_next);
159+ }
160+ if(this.can_prev !== can_prev){
161+ this.can_prev = can_prev;
162+ Nuvola.updateAction(Nuvola.ACTION_PREV_SONG, can_prev);
163+ }
164+
165+ setTimeout(Nuvola.bind(this, this.update), 500);
166 }
167
168 /**
169 * Command handler
170 * @param cmd command to execute
171 */
172- Integration.prototype.command = function(cmd){
173+ Integration.prototype.messageHandler = function(cmd){
174 try{
175 switch(cmd){
176- case Nuvola.CMD_PLAY:
177+ case Nuvola.ACTION_PLAY:
178 if(this.state != Nuvola.STATE_PLAYING) R.Services.Player.playPause();
179 break;
180- case Nuvola.CMD_PAUSE:
181+ case Nuvola.ACTION_PAUSE:
182 if(this.state == Nuvola.STATE_PLAYING) R.Services.Player.playPause();
183 break;
184- case Nuvola.CMD_TOGGLE:
185+ case Nuvola.ACTION_TOGGLE_PLAY:
186 R.Services.Player.playPause();
187 break;
188- case Nuvola.CMD_PREV_SONG:
189+ case Nuvola.ACTION_PREV_SONG:
190 R.Services.Player.previous();
191 break;
192- case Nuvola.CMD_NEXT_SONG:
193+ case Nuvola.ACTION_NEXT_SONG:
194 R.Services.Player.next();
195 break;
196 default:
197@@ -135,5 +173,5 @@
198 /* Store reference */
199 Nuvola.integration = new Integration(); // Singleton
200
201-// Call anonymous function with Nuvola object as an argument
202-})(window._Nuvola);
203+// Call anonymous function with JS API object as an argument
204+})(this);
205\ No newline at end of file
206
207=== modified file 'data/nuvolaplayer/services/rdio/metadata.conf'
208--- data/nuvolaplayer/services/rdio/metadata.conf 2013-04-06 12:42:57 +0000
209+++ data/nuvolaplayer/services/rdio/metadata.conf 2013-04-16 14:00:44 +0000
210@@ -1,8 +1,9 @@
211 name = Rdio
212 home_page = http://www.rdio.com/
213 sandbox_pattern = https?://((www\.)?rdio\.com/|ak.rdio\.com|)
214-maintainer_name = Orphaned service
215-maintainer_link = https://answers.launchpad.net/nuvola-player/+faq/2012
216-version = 2
217-version_minor = 4
218-flash_plugin = no
219+maintainer_name = Michael Mims
220+maintainer_link = https://launchpad.net/~mims-michael
221+version = 3
222+version_minor = 0
223+api_major = 2
224+flash_plugin = yes

Subscribers

People subscribed via source and target branches