mp3splt-gtk
player_control.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 "player_control.h"
43 
46 {
47  if (ui->infos->selected_player == PLAYER_SNACKAMP)
48  {
49  return snackamp_get_time_elapsed(ui);
50  }
51  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
52  {
53 #ifndef __WIN32__
54 #ifndef NO_AUDACIOUS
56 #endif
57 #endif
58  }
59  else
60  {
61 #ifndef NO_GSTREAMER
62  return gstreamer_get_time_elapsed(ui);
63 #endif
64  }
65 
66  return 0;
67 }
68 
71 {
72  if (ui->infos->selected_player == PLAYER_SNACKAMP)
73  {
74  return snackamp_get_total_time(ui);
75  }
76  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
77  {
78 #ifndef __WIN32__
79 #ifndef NO_AUDACIOUS
80  return myaudacious_get_total_time(ui);
81 #endif
82 #endif
83  }
84  else
85  {
86 #ifndef NO_GSTREAMER
87  return gstreamer_get_total_time(ui);
88 #endif
89  }
90 
91  return 0;
92 }
93 
96 {
97  if (ui->infos->selected_player == PLAYER_SNACKAMP)
98  {
99  return snackamp_is_running(ui);
100  }
101  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
102  {
103 #ifndef __WIN32__
104 #ifndef NO_AUDACIOUS
105  return myaudacious_is_running(ui);
106 #endif
107 #endif
108  }
109  else
110  {
111 #ifndef NO_GSTREAMER
112  return gstreamer_is_running(ui);
113 #endif
114  }
115 
116  return 0;
117 }
118 
121 {
122  if (ui->infos->selected_player == PLAYER_SNACKAMP)
123  {
124  snackamp_start(ui);
125  }
126  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
127  {
128 #ifndef __WIN32__
129 #ifndef NO_AUDACIOUS
130  myaudacious_start(ui);
131 #endif
132 #endif
133  }
134  else
135  {
136 #ifndef NO_GSTREAMER
137  gstreamer_start(ui);
138 #endif
139  }
140 }
141 
143 void player_start_add_files(GList *list, ui_state *ui)
144 {
145  if (ui->infos->selected_player == PLAYER_SNACKAMP)
146  {
147  snackamp_start_with_songs(list, ui);
148  }
149  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
150  {
151 #ifndef __WIN32__
152 #ifndef NO_AUDACIOUS
154 #endif
155 #endif
156  }
157  else
158  {
159 #ifndef NO_GSTREAMER
160  gstreamer_start_with_songs(list, ui);
161 #endif
162  }
163 }
164 
166 void player_add_files(GList *list, ui_state *ui)
167 {
168  if (ui->infos->selected_player == PLAYER_SNACKAMP)
169  {
170  snackamp_add_files(list, ui);
171  }
172  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
173  {
174 #ifndef __WIN32__
175 #ifndef NO_AUDACIOUS
176  myaudacious_add_files(list, ui);
177 #endif
178 #endif
179  }
180  else
181  {
182 #ifndef NO_GSTREAMER
183  gstreamer_add_files(list, ui);
184 #endif
185  }
186 }
187 
189 void player_add_files_and_select(GList *list, ui_state *ui)
190 {
191  if (ui->infos->selected_player == PLAYER_SNACKAMP)
192  {
193  snackamp_add_files(list, ui);
195  }
196  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
197  {
198 #ifndef __WIN32__
199 #ifndef NO_AUDACIOUS
200  myaudacious_add_files(list, ui);
202 #endif
203 #endif
204  }
205  else
206  {
207 #ifndef NO_GSTREAMER
208  gstreamer_add_files(list, ui);
210 #endif
211  }
212 }
213 
215 void player_add_play_files(GList *list, ui_state *ui)
216 {
217  player_add_files(list, ui);
218 
219  if (ui->infos->selected_player == PLAYER_SNACKAMP)
220  {
221  snackamp_next(ui);
222  }
223  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
224  {
225 #ifndef __WIN32__
226 #ifndef NO_AUDACIOUS
228 #endif
229 #endif
230  }
231  else
232  {
233 #ifndef NO_GSTREAMER
235 #endif
236  }
237 }
238 
241 {
242  if (ui->infos->selected_player == PLAYER_SNACKAMP)
243  {
244  snackamp_start_with_songs(list, ui);
246  }
247  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
248  {
249 #ifndef __WIN32__
250 #ifndef NO_AUDACIOUS
253 #endif
254 #endif
255  }
256  else
257  {
258 #ifndef NO_GSTREAMER
259  gstreamer_start_with_songs(list, ui);
261 #endif
262  }
263 }
264 
267 {
268  if (ui->infos->selected_player == PLAYER_SNACKAMP)
269  {
270  snackamp_play(ui);
271  }
272  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
273  {
274 #ifndef __WIN32__
275 #ifndef NO_AUDACIOUS
276  myaudacious_play(ui);
277 #endif
278 #endif
279  }
280  else
281  {
282 #ifndef NO_GSTREAMER
283  gstreamer_play(ui);
284 #endif
285  }
286 }
287 
290 {
291  if (ui->infos->selected_player == PLAYER_SNACKAMP)
292  {
293  snackamp_stop(ui);
294  }
295  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
296  {
297 #ifndef __WIN32__
298 #ifndef NO_AUDACIOUS
299  myaudacious_stop(ui);
300 #endif
301 #endif
302  }
303  else
304  {
305 #ifndef NO_GSTREAMER
306  gstreamer_stop(ui);
307 #endif
308  }
309 }
310 
313 {
314  if (ui->infos->selected_player == PLAYER_SNACKAMP)
315  {
316  snackamp_pause(ui);
317  }
318  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
319  {
320 #ifndef __WIN32__
321 #ifndef NO_AUDACIOUS
322  myaudacious_pause(ui);
323 #endif
324 #endif
325  }
326  else
327  {
328 #ifndef NO_GSTREAMER
329  gstreamer_pause(ui);
330 #endif
331  }
332 }
333 
336 {
337  if (ui->infos->selected_player == PLAYER_SNACKAMP)
338  {
339  snackamp_next(ui);
340  }
341  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
342  {
343 #ifndef __WIN32__
344 #ifndef NO_AUDACIOUS
345  myaudacious_next(ui);
346 #endif
347 #endif
348  }
349  else
350  {
351 #ifndef NO_GSTREAMER
352  gstreamer_next(ui);
353 #endif
354  }
355 }
356 
359 {
360  if (ui->infos->selected_player == PLAYER_SNACKAMP)
361  {
362  snackamp_prev(ui);
363  }
364  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
365  {
366 #ifndef __WIN32__
367 #ifndef NO_AUDACIOUS
368  myaudacious_prev(ui);
369 #endif
370 #endif
371  }
372  else
373  {
374 #ifndef NO_GSTREAMER
375  gstreamer_prev(ui);
376 #endif
377  }
378 }
379 
381 void player_seek(gint position, ui_state *ui)
382 {
383  if (ui->infos->selected_player == PLAYER_SNACKAMP)
384  {
385  snackamp_jump(position, ui);
386  }
387  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
388  {
389 #ifndef __WIN32__
390 #ifndef NO_AUDACIOUS
391  myaudacious_jump(position, ui);
392 #endif
393 #endif
394  }
395  else
396  {
397 #ifndef NO_GSTREAMER
398  gstreamer_jump(position, ui);
399 #endif
400  }
401 }
402 
407 void player_get_song_infos(gchar *total_infos, ui_state *ui)
408 {
409  if (ui->infos->selected_player == PLAYER_SNACKAMP)
410  {
411  snackamp_get_song_infos(total_infos, ui);
412  }
413  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
414  {
415 #ifndef __WIN32__
416 #ifndef NO_AUDACIOUS
417  myaudacious_get_song_infos(total_infos, ui);
418 #endif
419 #endif
420  }
421  else
422  {
423 #ifndef NO_GSTREAMER
424  gstreamer_get_song_infos(total_infos, ui);
425 #endif
426  }
427 }
428 
431 {
432  if (ui->infos->selected_player == PLAYER_SNACKAMP)
433  {
434  return snackamp_is_playing(ui);
435  }
436  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
437  {
438 #ifndef __WIN32__
439 #ifndef NO_AUDACIOUS
440  return myaudacious_is_playing(ui);
441 #endif
442 #endif
443  }
444  else
445  {
446 #ifndef NO_GSTREAMER
447  return gstreamer_is_playing(ui);
448 #endif
449  }
450 
451  return FALSE;
452 }
453 
456 {
457  if (ui->infos->selected_player == PLAYER_SNACKAMP)
458  {
459  return snackamp_is_paused(ui);
460  }
461  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
462  {
463 #ifndef __WIN32__
464 #ifndef NO_AUDACIOUS
465  return myaudacious_is_paused(ui);
466 #endif
467 #endif
468  }
469  else
470  {
471 #ifndef NO_GSTREAMER
472  return gstreamer_is_paused(ui);
473 #endif
474  }
475 
476  return 0;
477 }
478 
484 {
485  if (ui->infos->selected_player == PLAYER_SNACKAMP)
486  {
487  return snackamp_get_filename(ui);
488  }
489  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
490  {
491 #ifndef __WIN32__
492 #ifndef NO_AUDACIOUS
493  return myaudacious_get_filename(ui);
494 #endif
495 #endif
496  }
497  else
498  {
499 #ifndef NO_GSTREAMER
500  return gstreamer_get_filename(ui);
501 #endif
502  }
503 
504  return 0;
505 }
506 
512 {
513  if (ui->infos->selected_player == PLAYER_SNACKAMP)
514  {
515  return snackamp_get_title_song(ui);
516  }
517  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
518  {
519 #ifndef __WIN32__
520 #ifndef NO_AUDACIOUS
521  return myaudacious_get_title_song(ui);
522 #endif
523 #endif
524  }
525  else
526  {
527 #ifndef NO_GSTREAMER
528  return gstreamer_get_title_song(ui);
529 #endif
530  }
531 
532  return 0;
533 }
534 
537 {
538  if (ui->infos->selected_player == PLAYER_SNACKAMP)
539  {
540  return snackamp_get_volume(ui);
541  }
542  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
543  {
544 #ifndef __WIN32__
545 #ifndef NO_AUDACIOUS
546  return myaudacious_get_volume(ui);
547 #endif
548 #endif
549  }
550  else
551  {
552 #ifndef NO_GSTREAMER
553  return gstreamer_get_volume(ui);
554 #endif
555  }
556 
557  return 0;
558 }
559 
561 void player_set_volume(gint volume, ui_state *ui)
562 {
563  if (ui->infos->selected_player == PLAYER_SNACKAMP)
564  {
565  snackamp_set_volume(volume, ui);
566  }
567  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
568  {
569 #ifndef __WIN32__
570 #ifndef NO_AUDACIOUS
571  myaudacious_set_volume(volume, ui);
572 #endif
573 #endif
574  }
575  else
576  {
577 #ifndef NO_GSTREAMER
578  gstreamer_set_volume(volume, ui);
579 #endif
580  }
581 }
582 
585 {
586  if (ui->infos->selected_player == PLAYER_SNACKAMP)
587  {
588  return snackamp_get_playlist_number(ui);
589  }
590  else if (ui->infos->selected_player == PLAYER_AUDACIOUS)
591  {
592 #ifndef __WIN32__
593 #ifndef NO_AUDACIOUS
595 #endif
596 #endif
597  }
598  else
599  {
600 #ifndef NO_GSTREAMER
602 #endif
603  }
604 
605  return 0;
606 }
607 
610 {
611  if (ui->infos->selected_player == PLAYER_GSTREAMER)
612  {
613 #ifndef NO_GSTREAMER
614  gstreamer_quit(ui);
615 #endif
616  }
617 
618  return 0;
619 }
620