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

Proposed by Michael Mims
Status: Merged
Approved by: Jiří Janoušek
Approved revision: 602
Merged at revision: 600
Proposed branch: lp:~mims-michael/nuvola-player/bugfix1049253-2.0.x
Merge into: lp:nuvola-player/2.0.x
Diff against target: 243 lines (+95/-52)
3 files modified
data/nuvolaplayer/services/rdio/description.html (+1/-1)
data/nuvolaplayer/services/rdio/integration.js (+88/-46)
data/nuvolaplayer/services/rdio/metadata.conf (+6/-5)
To merge this branch: bzr merge lp:~mims-michael/nuvola-player/bugfix1049253-2.0.x
Reviewer Review Type Date Requested Status
Jiří Janoušek Approve
Review via email: mp+157715@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 :
review: Needs Fixing
601. By Michael Mims

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

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

Subscribers

People subscribed via source and target branches

to all changes: