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

Subscribers

People subscribed via source and target branches