comparison src/scrobbler/plugin.c @ 1015:69cf6184edef trunk

[svn] - make this work without controlsocket
author nenolod
date Fri, 11 May 2007 09:32:54 -0700
parents 238055a6cb8f
children b70103d4b5ba
comparison
equal deleted inserted replaced
1014:af586df84c9b 1015:69cf6184edef
11 #include <audacious/ui_preferences.h> 11 #include <audacious/ui_preferences.h>
12 #include <audacious/playlist.h> 12 #include <audacious/playlist.h>
13 #include <audacious/configdb.h> 13 #include <audacious/configdb.h>
14 #include <audacious/beepctrl.h> 14 #include <audacious/beepctrl.h>
15 #include <audacious/strings.h> 15 #include <audacious/strings.h>
16 #include <audacious/main.h>
16 17
17 #include <unistd.h> 18 #include <unistd.h>
18 #include <stdio.h> 19 #include <stdio.h>
19 #include <stdlib.h> 20 #include <stdlib.h>
20 #include <string.h> 21 #include <string.h>
194 static int pos_c, playlistlen_c, playtime_c, time_c, 195 static int pos_c, playlistlen_c, playtime_c, time_c,
195 pos_p = 0, playlistlen_p = 0, playtime_p = 0, 196 pos_p = 0, playlistlen_p = 0, playtime_p = 0,
196 playtime_i = 0, time_i = 0, 197 playtime_i = 0, time_i = 0,
197 playtime_ofs = 0; 198 playtime_ofs = 0;
198 static char *file_c = NULL, *file_p = NULL; 199 static char *file_c = NULL, *file_p = NULL;
200 Playlist *playlist = playlist_get_active();
199 201
200 static enum playstatus { 202 static enum playstatus {
201 ps_stop, ps_play, ps_pause 203 ps_stop, ps_play, ps_pause
202 } ps_c, ps_p = ps_stop; 204 } ps_c, ps_p = ps_stop;
203 205
214 216
215 /* clear dosubmit */ 217 /* clear dosubmit */
216 dosubmit.dosubmit = dosubmit.pos_c = dosubmit.len = dosubmit.gerpok = 0; 218 dosubmit.dosubmit = dosubmit.pos_c = dosubmit.len = dosubmit.gerpok = 0;
217 219
218 /* current music number */ 220 /* current music number */
219 pos_c = xmms_remote_get_playlist_pos(XS_CS); 221 pos_c = playlist_get_position(playlist);
220 /* current file name */ 222 /* current file name */
221 file_c = xmms_remote_get_playlist_file(XS_CS, pos_c); 223 file_c = playlist_get_filename(playlist, pos_c);
222 224
223 if ((file_c != NULL) && (ishttp(file_c))) 225 if ((file_c != NULL) && (ishttp(file_c)))
224 return dosubmit; 226 return dosubmit;
225 227
226 /* total number */ 228 /* total number */
227 playlistlen_c = xmms_remote_get_playlist_length(XS_CS); 229 playlistlen_c = playlist_get_length(playlist);
228 /* current playtime */ 230 /* current playtime */
229 playtime_c = xmms_remote_get_output_time(XS_CS); 231 playtime_c = playback_get_time();
230 /* total length */ 232 /* total length */
231 len = xmms_remote_get_playlist_time(XS_CS, pos_c); 233 len = playlist_get_songtime(playlist, pos_c);
232 234
233 /* current time (ms) */ 235 /* current time (ms) */
234 gettimeofday(&timetmp, NULL); 236 gettimeofday(&timetmp, NULL);
235 time_c = timetmp.tv_sec * 1000 + timetmp.tv_usec / 1000; 237 time_c = timetmp.tv_sec * 1000 + timetmp.tv_usec / 1000;
236 238
237 /* current status */ 239 /* current status */
238 if( xmms_remote_is_paused(XS_CS) ) { 240 if( playback_get_paused(XS_CS) ) {
239 ps_c = ps_pause; 241 ps_c = ps_pause;
240 }else if( xmms_remote_is_playing(XS_CS) ) { 242 }else if( playback_get_playing(XS_CS) ) {
241 ps_c = ps_play; 243 ps_c = ps_play;
242 }else{ 244 }else{
243 ps_c = ps_stop; 245 ps_c = ps_stop;
244 } 246 }
245 247
246 /* repeat setting */ 248 /* repeat setting */
247 repeat = xmms_remote_is_repeat(XS_CS); 249 repeat = cfg.repeat;
248 250
249 if( ps_p == ps_stop && ps_c == ps_stop ) playstate = stopping; 251 if( ps_p == ps_stop && ps_c == ps_stop ) playstate = stopping;
250 else if( ps_p == ps_stop && ps_c == ps_play ) playstate = start; 252 else if( ps_p == ps_stop && ps_c == ps_play ) playstate = start;
251 /* else if( ps_p == ps_stop && ps_c == ps_pause ) ; */ 253 /* else if( ps_p == ps_stop && ps_c == ps_pause ) ; */
252 else if( ps_p == ps_play && ps_c == ps_play ) playstate = playing; 254 else if( ps_p == ps_play && ps_c == ps_play ) playstate = playing;