mp3splt-gtk

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

player.c
Go to the documentation of this file.
1 /**********************************************************
2 *
3 * mp3splt-gtk -- utility based on mp3splt,
4 * for mp3/ogg splitting without decoding
5 *
6 * Copyright: (C) 2005-2012 Alexandru Munteanu
7 * Contact: io_fx@yahoo.fr
8 *
9 *
10 * http://mp3splt.sourceforge.net/
11 *
12 *********************************************************/
13
14 /**********************************************************
15 *
16 * This program is free software; you ca nredistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
29 * USA.
30 *
31 *********************************************************/
32
33 /*!********************************************************
34 * \file
35 * Functions to access the currently selected player
36 *
37 * this file is used to play for the appropriate player,
38 * for example if we choose snackamp, the player will use
39 * snackamp
40 **********************************************************/
41
42 #include <glib.h>
43 #include <stdio.h>
44
45 #include "player.h"
46 #include "snackamp_control.h"
47 #include "xmms_control.h"
48 #include "gstreamer_control.h"
49
50 extern int selected_player;
51
53 gint player_get_elapsed_time()
54 {
55 if (selected_player == PLAYER_SNACKAMP)
56 {
57 return snackamp_get_time_elapsed();
58 }
59 else if (selected_player == PLAYER_AUDACIOUS)
60 {
61 #ifndef __WIN32__
62 #ifndef NO_AUDACIOUS
63 return myxmms_get_time_elapsed();
64 #endif
65 #endif
66 }
67 else
68 {
69 #ifndef NO_GSTREAMER
70 return gstreamer_get_time_elapsed();
71 #endif
72 }
73
74 return 0;
75 }
76
78 gint player_get_total_time()
79 {
80 if (selected_player == PLAYER_SNACKAMP)
81 {
82 return snackamp_get_total_time();
83 }
84 else if (selected_player == PLAYER_AUDACIOUS)
85 {
86 #ifndef __WIN32__
87 #ifndef NO_AUDACIOUS
88 return myxmms_get_total_time();
89 #endif
90 #endif
91 }
92 else
93 {
94 #ifndef NO_GSTREAMER
95 return gstreamer_get_total_time();
96 #endif
97 }
98
99 return 0;
100 }
101
103 gint player_is_running()
104 {
105 if (selected_player == PLAYER_SNACKAMP)
106 {
107 return snackamp_is_running();
108 }
109 else if (selected_player == PLAYER_AUDACIOUS)
110 {
111 #ifndef __WIN32__
112 #ifndef NO_AUDACIOUS
113 return myxmms_is_running();
114 #endif
115 #endif
116 }
117 else
118 {
119 #ifndef NO_GSTREAMER
120 return gstreamer_is_running();
121 #endif
122 }
123
124 return 0;
125 }
126
128 void player_start()
129 {
130 if (selected_player == PLAYER_SNACKAMP)
131 {
132 snackamp_start();
133 }
134 else if (selected_player == PLAYER_AUDACIOUS)
135 {
136 #ifndef __WIN32__
137 #ifndef NO_AUDACIOUS
138 myxmms_start();
139 #endif
140 #endif
141 }
142 else
143 {
144 #ifndef NO_GSTREAMER
145 gstreamer_start();
146 #endif
147 }
148 }
149
151 void player_start_add_files(GList *list)
152 {
153 if (selected_player == PLAYER_SNACKAMP)
154 {
155 snackamp_start_with_songs(list);
156 }
157 else if (selected_player == PLAYER_AUDACIOUS)
158 {
159 #ifndef __WIN32__
160 #ifndef NO_AUDACIOUS
161 myxmms_start_with_songs(list);
162 #endif
163 #endif
164 }
165 else
166 {
167 #ifndef NO_GSTREAMER
168 gstreamer_start_with_songs(list);
169 #endif
170 }
171 }
172
174 void player_add_files(GList *list)
175 {
176 if (selected_player == PLAYER_SNACKAMP)
177 {
178 snackamp_add_files(list);
179 }
180 else if (selected_player == PLAYER_AUDACIOUS)
181 {
182 #ifndef __WIN32__
183 #ifndef NO_AUDACIOUS
184 myxmms_add_files(list);
185 #endif
186 #endif
187 }
188 else
189 {
190 #ifndef NO_GSTREAMER
191 gstreamer_add_files(list);
192 #endif
193 }
194 }
195
197 void player_add_files_and_select(GList *list)
198 {
199 if (selected_player == PLAYER_SNACKAMP)
200 {
201 snackamp_add_files(list);
202 snackamp_select_last_file();
203 }
204 else if (selected_player == PLAYER_AUDACIOUS)
205 {
206 #ifndef __WIN32__
207 #ifndef NO_AUDACIOUS
208 myxmms_add_files(list);
209 myxmms_select_last_file();
210 #endif
211 #endif
212 }
213 else
214 {
215 #ifndef NO_GSTREAMER
216 gstreamer_add_files(list);
217 gstreamer_select_last_file();
218 #endif
219 }
220 }
221
223 void player_add_play_files(GList *list)
224 {
225 player_add_files(list);
226
227 if (selected_player == PLAYER_SNACKAMP)
228 {
229 //snackamp adds files just after the current one
230 //and not at the end of the playlist
231 snackamp_next();
232 //snackamp_play_last_file();
233 }
234 else if (selected_player == PLAYER_AUDACIOUS)
235 {
236 #ifndef __WIN32__
237 #ifndef NO_AUDACIOUS
238 myxmms_play_last_file();
239 #endif
240 #endif
241 }
242 else
243 {
244 #ifndef NO_GSTREAMER
245 gstreamer_play_last_file();
246 #endif
247 }
248 }
249
251 void player_start_play_with_songs(GList *list)
252 {
253 if (selected_player == PLAYER_SNACKAMP)
254 {
255 snackamp_start_with_songs(list);
256 snackamp_play_last_file();
257 }
258 else if (selected_player == PLAYER_AUDACIOUS)
259 {
260 #ifndef __WIN32__
261 #ifndef NO_AUDACIOUS
262 myxmms_start_with_songs(list);
263 myxmms_play_last_file();
264 #endif
265 #endif
266 }
267 else
268 {
269 #ifndef NO_GSTREAMER
270 gstreamer_start_with_songs(list);
271 gstreamer_play_last_file();
272 #endif
273 }
274 }
275
277 void player_play()
278 {
279 if (selected_player == PLAYER_SNACKAMP)
280 {
281 snackamp_play();
282 }
283 else if (selected_player == PLAYER_AUDACIOUS)
284 {
285 #ifndef __WIN32__
286 #ifndef NO_AUDACIOUS
287 myxmms_play();
288 #endif
289 #endif
290 }
291 else
292 {
293 #ifndef NO_GSTREAMER
294 gstreamer_play();
295 #endif
296 }
297 }
298
300 void player_stop()
301 {
302 if (selected_player == PLAYER_SNACKAMP)
303 {
304 snackamp_stop();
305 }
306 else if (selected_player == PLAYER_AUDACIOUS)
307 {
308 #ifndef __WIN32__
309 #ifndef NO_AUDACIOUS
310 myxmms_stop();
311 #endif
312 #endif
313 }
314 else
315 {
316 #ifndef NO_GSTREAMER
317 gstreamer_stop();
318 #endif
319 }
320 }
321
323 void player_pause()
324 {
325 if (selected_player == PLAYER_SNACKAMP)
326 {
327 snackamp_pause();
328 }
329 else if (selected_player == PLAYER_AUDACIOUS)
330 {
331 #ifndef __WIN32__
332 #ifndef NO_AUDACIOUS
333 myxmms_pause();
334 #endif
335 #endif
336 }
337 else
338 {
339 #ifndef NO_GSTREAMER
340 gstreamer_pause();
341 #endif
342 }
343 }
344
346 void player_next()
347 {
348 if (selected_player == PLAYER_SNACKAMP)
349 {
350 snackamp_next();
351 }
352 else if (selected_player == PLAYER_AUDACIOUS)
353 {
354 #ifndef __WIN32__
355 #ifndef NO_AUDACIOUS
356 myxmms_next();
357 #endif
358 #endif
359 }
360 else
361 {
362 #ifndef NO_GSTREAMER
363 gstreamer_next();
364 #endif
365 }
366 }
367
369 void player_prev()
370 {
371 if (selected_player == PLAYER_SNACKAMP)
372 {
373 snackamp_prev();
374 }
375 else if (selected_player == PLAYER_AUDACIOUS)
376 {
377 #ifndef __WIN32__
378 #ifndef NO_AUDACIOUS
379 myxmms_prev();
380 #endif
381 #endif
382 }
383 else
384 {
385 #ifndef NO_GSTREAMER
386 gstreamer_prev();
387 #endif
388 }
389 }
390
392 void player_jump(gint position)
393 {
394 if (selected_player == PLAYER_SNACKAMP)
395 {
396 snackamp_jump(position);
397 }
398 else if (selected_player == PLAYER_AUDACIOUS)
399 {
400 #ifndef __WIN32__
401 #ifndef NO_AUDACIOUS
402 myxmms_jump(position);
403 #endif
404 #endif
405 }
406 else
407 {
408 #ifndef NO_GSTREAMER
409 gstreamer_jump(position);
410 #endif
411 }
412 }
413
418 void player_get_song_infos(gchar *total_infos)
419 {
420 if (selected_player == PLAYER_SNACKAMP)
421 {
422 snackamp_get_song_infos(total_infos);
423 }
424 else if (selected_player == PLAYER_AUDACIOUS)
425 {
426 #ifndef __WIN32__
427 #ifndef NO_AUDACIOUS
428 myxmms_get_song_infos(total_infos);
429 #endif
430 #endif
431 }
432 else
433 {
434 #ifndef NO_GSTREAMER
435 gstreamer_get_song_infos(total_infos);
436 #endif
437 }
438 }
439
440 #include <stdio.h>
442 gint player_is_playing()
443 {
444 if (selected_player == PLAYER_SNACKAMP)
445 {
446 return snackamp_is_playing();
447 }
448 else if (selected_player == PLAYER_AUDACIOUS)
449 {
450 #ifndef __WIN32__
451 #ifndef NO_AUDACIOUS
452 return myxmms_is_playing();
453 #endif
454 #endif
455 }
456 else
457 {
458 #ifndef NO_GSTREAMER
459 return gstreamer_is_playing();
460 #endif
461 }
462
463 return 0;
464 }
465
467 gint player_is_paused()
468 {
469 if (selected_player == PLAYER_SNACKAMP)
470 {
471 return snackamp_is_paused();
472 }
473 else if (selected_player == PLAYER_AUDACIOUS)
474 {
475 #ifndef __WIN32__
476 #ifndef NO_AUDACIOUS
477 return myxmms_is_paused();
478 #endif
479 #endif
480 }
481 else
482 {
483 #ifndef NO_GSTREAMER
484 return gstreamer_is_paused();
485 #endif
486 }
487
488 return 0;
489 }
490
495 gchar *player_get_filename()
496 {
497 if (selected_player == PLAYER_SNACKAMP)
498 {
499 return snackamp_get_filename();
500 }
501 else if (selected_player == PLAYER_AUDACIOUS)
502 {
503 #ifndef __WIN32__
504 #ifndef NO_AUDACIOUS
505 return myxmms_get_filename();
506 #endif
507 #endif
508 }
509 else
510 {
511 #ifndef NO_GSTREAMER
512 return gstreamer_get_filename();
513 #endif
514 }
515
516 return 0;
517 }
518
523 gchar *player_get_title()
524 {
525 if (selected_player == PLAYER_SNACKAMP)
526 {
527 return snackamp_get_title_song();
528 }
529 else if (selected_player == PLAYER_AUDACIOUS)
530 {
531 #ifndef __WIN32__
532 #ifndef NO_AUDACIOUS
533 return myxmms_get_title_song();
534 #endif
535 #endif
536 }
537 else
538 {
539 #ifndef NO_GSTREAMER
540 return gstreamer_get_title_song();
541 #endif
542 }
543
544 return 0;
545 }
546
548 gint player_get_volume()
549 {
550 if (selected_player == PLAYER_SNACKAMP)
551 {
552 return snackamp_get_volume();
553 }
554 else if (selected_player == PLAYER_AUDACIOUS)
555 {
556 #ifndef __WIN32__
557 #ifndef NO_AUDACIOUS
558 return myxmms_get_volume();
559 #endif
560 #endif
561 }
562 else
563 {
564 #ifndef NO_GSTREAMER
565 return gstreamer_get_volume();
566 #endif
567 }
568
569 return 0;
570 }
571
573 void player_set_volume(gint volume)
574 {
575 if (selected_player == PLAYER_SNACKAMP)
576 {
577 snackamp_set_volume(volume);
578 }
579 else if (selected_player == PLAYER_AUDACIOUS)
580 {
581 #ifndef __WIN32__
582 #ifndef NO_AUDACIOUS
583 myxmms_set_volume(volume);
584 #endif
585 #endif
586 }
587 else
588 {
589 #ifndef NO_GSTREAMER
590 gstreamer_set_volume(volume);
591 #endif
592 }
593 }
594
596 gint player_get_playlist_number()
597 {
598 if (selected_player == PLAYER_SNACKAMP)
599 {
600 return snackamp_get_playlist_number();
601 }
602 else if (selected_player == PLAYER_AUDACIOUS)
603 {
604 #ifndef __WIN32__
605 #ifndef NO_AUDACIOUS
606 return myxmms_get_playlist_number();
607 #endif
608 #endif
609 }
610 else
611 {
612 #ifndef NO_GSTREAMER
613 return gstreamer_get_playlist_number();
614 #endif
615 }
616
617 return 0;
618 }
619
621 gint player_quit()
622 {
623 /*if (selected_player == PLAYER_SNACKAMP)
624 {
625 return snackamp_quit();
626 }
627 else
628 {
629 #ifndef __WIN32__
630 #ifndef NO_AUDACIOUS
631 return myxmms_quit();
632 #endif
633 #endif
634 }*/
635 if (selected_player == PLAYER_GSTREAMER)
636 {
637 #ifndef NO_GSTREAMER
638 gstreamer_quit();
639 #endif
640 }
641
642 return 0;
643 }