mp3splt-gtk
|
00001 /********************************************************** 00002 * 00003 * mp3splt-gtk -- utility based on mp3splt, 00004 * for mp3/ogg splitting without decoding 00005 * 00006 * Copyright: (C) 2005-2011 Alexandru Munteanu 00007 * Contact: io_fx@yahoo.fr 00008 * 00009 * 00010 * http://mp3splt.sourceforge.net/ 00011 * 00012 *********************************************************/ 00013 00014 /********************************************************** 00015 * 00016 * This program is free software; you ca nredistribute it and/or 00017 * modify it under the terms of the GNU General Public License 00018 * as published by the Free Software Foundation; either version 2 00019 * of the License, or (at your option) any later version. 00020 * 00021 * This program is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU General Public License for more details. 00025 * 00026 * You should have received a copy of the GNU General Public License 00027 * along with this program; if not, write to the Free Software 00028 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00029 * USA. 00030 * 00031 *********************************************************/ 00032 00033 /*!******************************************************** 00034 * \file 00035 * Functions to access the currently selected player 00036 * 00037 * this file is used to play for the appropriate player, 00038 * for example if we choose snackamp, the player will use 00039 * snackamp 00040 **********************************************************/ 00041 00042 #include <glib.h> 00043 #include <stdio.h> 00044 00045 #include "player.h" 00046 #include "snackamp_control.h" 00047 #include "xmms_control.h" 00048 #include "gstreamer_control.h" 00049 00050 extern int selected_player; 00051 00053 gint player_get_elapsed_time() 00054 { 00055 if (selected_player == PLAYER_SNACKAMP) 00056 { 00057 return snackamp_get_time_elapsed(); 00058 } 00059 else if (selected_player == PLAYER_AUDACIOUS) 00060 { 00061 #ifndef __WIN32__ 00062 #ifndef NO_AUDACIOUS 00063 return myxmms_get_time_elapsed(); 00064 #endif 00065 #endif 00066 } 00067 else 00068 { 00069 #ifndef NO_GSTREAMER 00070 return gstreamer_get_time_elapsed(); 00071 #endif 00072 } 00073 00074 return 0; 00075 } 00076 00078 gint player_get_total_time() 00079 { 00080 if (selected_player == PLAYER_SNACKAMP) 00081 { 00082 return snackamp_get_total_time(); 00083 } 00084 else if (selected_player == PLAYER_AUDACIOUS) 00085 { 00086 #ifndef __WIN32__ 00087 #ifndef NO_AUDACIOUS 00088 return myxmms_get_total_time(); 00089 #endif 00090 #endif 00091 } 00092 else 00093 { 00094 #ifndef NO_GSTREAMER 00095 return gstreamer_get_total_time(); 00096 #endif 00097 } 00098 00099 return 0; 00100 } 00101 00103 gint player_is_running() 00104 { 00105 if (selected_player == PLAYER_SNACKAMP) 00106 { 00107 return snackamp_is_running(); 00108 } 00109 else if (selected_player == PLAYER_AUDACIOUS) 00110 { 00111 #ifndef __WIN32__ 00112 #ifndef NO_AUDACIOUS 00113 return myxmms_is_running(); 00114 #endif 00115 #endif 00116 } 00117 else 00118 { 00119 #ifndef NO_GSTREAMER 00120 return gstreamer_is_running(); 00121 #endif 00122 } 00123 00124 return 0; 00125 } 00126 00128 void player_start() 00129 { 00130 if (selected_player == PLAYER_SNACKAMP) 00131 { 00132 snackamp_start(); 00133 } 00134 else if (selected_player == PLAYER_AUDACIOUS) 00135 { 00136 #ifndef __WIN32__ 00137 #ifndef NO_AUDACIOUS 00138 myxmms_start(); 00139 #endif 00140 #endif 00141 } 00142 else 00143 { 00144 #ifndef NO_GSTREAMER 00145 gstreamer_start(); 00146 #endif 00147 } 00148 } 00149 00151 void player_start_add_files(GList *list) 00152 { 00153 if (selected_player == PLAYER_SNACKAMP) 00154 { 00155 snackamp_start_with_songs(list); 00156 } 00157 else if (selected_player == PLAYER_AUDACIOUS) 00158 { 00159 #ifndef __WIN32__ 00160 #ifndef NO_AUDACIOUS 00161 myxmms_start_with_songs(list); 00162 #endif 00163 #endif 00164 } 00165 else 00166 { 00167 #ifndef NO_GSTREAMER 00168 gstreamer_start_with_songs(list); 00169 #endif 00170 } 00171 } 00172 00174 void player_add_files(GList *list) 00175 { 00176 if (selected_player == PLAYER_SNACKAMP) 00177 { 00178 snackamp_add_files(list); 00179 } 00180 else if (selected_player == PLAYER_AUDACIOUS) 00181 { 00182 #ifndef __WIN32__ 00183 #ifndef NO_AUDACIOUS 00184 myxmms_add_files(list); 00185 #endif 00186 #endif 00187 } 00188 else 00189 { 00190 #ifndef NO_GSTREAMER 00191 gstreamer_add_files(list); 00192 #endif 00193 } 00194 } 00195 00197 void player_add_files_and_select(GList *list) 00198 { 00199 if (selected_player == PLAYER_SNACKAMP) 00200 { 00201 snackamp_add_files(list); 00202 snackamp_select_last_file(); 00203 } 00204 else if (selected_player == PLAYER_AUDACIOUS) 00205 { 00206 #ifndef __WIN32__ 00207 #ifndef NO_AUDACIOUS 00208 myxmms_add_files(list); 00209 myxmms_select_last_file(); 00210 #endif 00211 #endif 00212 } 00213 else 00214 { 00215 #ifndef NO_GSTREAMER 00216 gstreamer_add_files(list); 00217 gstreamer_select_last_file(); 00218 #endif 00219 } 00220 } 00221 00223 void player_add_play_files(GList *list) 00224 { 00225 player_add_files(list); 00226 00227 if (selected_player == PLAYER_SNACKAMP) 00228 { 00229 //snackamp adds files just after the current one 00230 //and not at the end of the playlist 00231 snackamp_next(); 00232 //snackamp_play_last_file(); 00233 } 00234 else if (selected_player == PLAYER_AUDACIOUS) 00235 { 00236 #ifndef __WIN32__ 00237 #ifndef NO_AUDACIOUS 00238 myxmms_play_last_file(); 00239 #endif 00240 #endif 00241 } 00242 else 00243 { 00244 #ifndef NO_GSTREAMER 00245 gstreamer_play_last_file(); 00246 #endif 00247 } 00248 } 00249 00251 void player_start_play_with_songs(GList *list) 00252 { 00253 if (selected_player == PLAYER_SNACKAMP) 00254 { 00255 snackamp_start_with_songs(list); 00256 snackamp_play_last_file(); 00257 } 00258 else if (selected_player == PLAYER_AUDACIOUS) 00259 { 00260 #ifndef __WIN32__ 00261 #ifndef NO_AUDACIOUS 00262 myxmms_start_with_songs(list); 00263 myxmms_play_last_file(); 00264 #endif 00265 #endif 00266 } 00267 else 00268 { 00269 #ifndef NO_GSTREAMER 00270 gstreamer_start_with_songs(list); 00271 gstreamer_play_last_file(); 00272 #endif 00273 } 00274 } 00275 00277 void player_play() 00278 { 00279 if (selected_player == PLAYER_SNACKAMP) 00280 { 00281 snackamp_play(); 00282 } 00283 else if (selected_player == PLAYER_AUDACIOUS) 00284 { 00285 #ifndef __WIN32__ 00286 #ifndef NO_AUDACIOUS 00287 myxmms_play(); 00288 #endif 00289 #endif 00290 } 00291 else 00292 { 00293 #ifndef NO_GSTREAMER 00294 gstreamer_play(); 00295 #endif 00296 } 00297 } 00298 00300 void player_stop() 00301 { 00302 if (selected_player == PLAYER_SNACKAMP) 00303 { 00304 snackamp_stop(); 00305 } 00306 else if (selected_player == PLAYER_AUDACIOUS) 00307 { 00308 #ifndef __WIN32__ 00309 #ifndef NO_AUDACIOUS 00310 myxmms_stop(); 00311 #endif 00312 #endif 00313 } 00314 else 00315 { 00316 #ifndef NO_GSTREAMER 00317 gstreamer_stop(); 00318 #endif 00319 } 00320 } 00321 00323 void player_pause() 00324 { 00325 if (selected_player == PLAYER_SNACKAMP) 00326 { 00327 snackamp_pause(); 00328 } 00329 else if (selected_player == PLAYER_AUDACIOUS) 00330 { 00331 #ifndef __WIN32__ 00332 #ifndef NO_AUDACIOUS 00333 myxmms_pause(); 00334 #endif 00335 #endif 00336 } 00337 else 00338 { 00339 #ifndef NO_GSTREAMER 00340 gstreamer_pause(); 00341 #endif 00342 } 00343 } 00344 00346 void player_next() 00347 { 00348 if (selected_player == PLAYER_SNACKAMP) 00349 { 00350 snackamp_next(); 00351 } 00352 else if (selected_player == PLAYER_AUDACIOUS) 00353 { 00354 #ifndef __WIN32__ 00355 #ifndef NO_AUDACIOUS 00356 myxmms_next(); 00357 #endif 00358 #endif 00359 } 00360 else 00361 { 00362 #ifndef NO_GSTREAMER 00363 gstreamer_next(); 00364 #endif 00365 } 00366 } 00367 00369 void player_prev() 00370 { 00371 if (selected_player == PLAYER_SNACKAMP) 00372 { 00373 snackamp_prev(); 00374 } 00375 else if (selected_player == PLAYER_AUDACIOUS) 00376 { 00377 #ifndef __WIN32__ 00378 #ifndef NO_AUDACIOUS 00379 myxmms_prev(); 00380 #endif 00381 #endif 00382 } 00383 else 00384 { 00385 #ifndef NO_GSTREAMER 00386 gstreamer_prev(); 00387 #endif 00388 } 00389 } 00390 00392 void player_jump(gint position) 00393 { 00394 if (selected_player == PLAYER_SNACKAMP) 00395 { 00396 snackamp_jump(position); 00397 } 00398 else if (selected_player == PLAYER_AUDACIOUS) 00399 { 00400 #ifndef __WIN32__ 00401 #ifndef NO_AUDACIOUS 00402 myxmms_jump(position); 00403 #endif 00404 #endif 00405 } 00406 else 00407 { 00408 #ifndef NO_GSTREAMER 00409 gstreamer_jump(position); 00410 #endif 00411 } 00412 } 00413 00418 void player_get_song_infos(gchar *total_infos) 00419 { 00420 if (selected_player == PLAYER_SNACKAMP) 00421 { 00422 snackamp_get_song_infos(total_infos); 00423 } 00424 else if (selected_player == PLAYER_AUDACIOUS) 00425 { 00426 #ifndef __WIN32__ 00427 #ifndef NO_AUDACIOUS 00428 myxmms_get_song_infos(total_infos); 00429 #endif 00430 #endif 00431 } 00432 else 00433 { 00434 #ifndef NO_GSTREAMER 00435 gstreamer_get_song_infos(total_infos); 00436 #endif 00437 } 00438 } 00439 00440 #include <stdio.h> 00442 gint player_is_playing() 00443 { 00444 if (selected_player == PLAYER_SNACKAMP) 00445 { 00446 return snackamp_is_playing(); 00447 } 00448 else if (selected_player == PLAYER_AUDACIOUS) 00449 { 00450 #ifndef __WIN32__ 00451 #ifndef NO_AUDACIOUS 00452 return myxmms_is_playing(); 00453 #endif 00454 #endif 00455 } 00456 else 00457 { 00458 #ifndef NO_GSTREAMER 00459 return gstreamer_is_playing(); 00460 #endif 00461 } 00462 00463 return 0; 00464 } 00465 00467 gint player_is_paused() 00468 { 00469 if (selected_player == PLAYER_SNACKAMP) 00470 { 00471 return snackamp_is_paused(); 00472 } 00473 else if (selected_player == PLAYER_AUDACIOUS) 00474 { 00475 #ifndef __WIN32__ 00476 #ifndef NO_AUDACIOUS 00477 return myxmms_is_paused(); 00478 #endif 00479 #endif 00480 } 00481 else 00482 { 00483 #ifndef NO_GSTREAMER 00484 return gstreamer_is_paused(); 00485 #endif 00486 } 00487 00488 return 0; 00489 } 00490 00495 gchar *player_get_filename() 00496 { 00497 if (selected_player == PLAYER_SNACKAMP) 00498 { 00499 return snackamp_get_filename(); 00500 } 00501 else if (selected_player == PLAYER_AUDACIOUS) 00502 { 00503 #ifndef __WIN32__ 00504 #ifndef NO_AUDACIOUS 00505 return myxmms_get_filename(); 00506 #endif 00507 #endif 00508 } 00509 else 00510 { 00511 #ifndef NO_GSTREAMER 00512 return gstreamer_get_filename(); 00513 #endif 00514 } 00515 00516 return 0; 00517 } 00518 00523 gchar *player_get_title() 00524 { 00525 if (selected_player == PLAYER_SNACKAMP) 00526 { 00527 return snackamp_get_title_song(); 00528 } 00529 else if (selected_player == PLAYER_AUDACIOUS) 00530 { 00531 #ifndef __WIN32__ 00532 #ifndef NO_AUDACIOUS 00533 return myxmms_get_title_song(); 00534 #endif 00535 #endif 00536 } 00537 else 00538 { 00539 #ifndef NO_GSTREAMER 00540 return gstreamer_get_title_song(); 00541 #endif 00542 } 00543 00544 return 0; 00545 } 00546 00548 gint player_get_volume() 00549 { 00550 if (selected_player == PLAYER_SNACKAMP) 00551 { 00552 return snackamp_get_volume(); 00553 } 00554 else if (selected_player == PLAYER_AUDACIOUS) 00555 { 00556 #ifndef __WIN32__ 00557 #ifndef NO_AUDACIOUS 00558 return myxmms_get_volume(); 00559 #endif 00560 #endif 00561 } 00562 else 00563 { 00564 #ifndef NO_GSTREAMER 00565 return gstreamer_get_volume(); 00566 #endif 00567 } 00568 00569 return 0; 00570 } 00571 00573 void player_set_volume(gint volume) 00574 { 00575 if (selected_player == PLAYER_SNACKAMP) 00576 { 00577 snackamp_set_volume(volume); 00578 } 00579 else if (selected_player == PLAYER_AUDACIOUS) 00580 { 00581 #ifndef __WIN32__ 00582 #ifndef NO_AUDACIOUS 00583 myxmms_set_volume(volume); 00584 #endif 00585 #endif 00586 } 00587 else 00588 { 00589 #ifndef NO_GSTREAMER 00590 gstreamer_set_volume(volume); 00591 #endif 00592 } 00593 } 00594 00596 gint player_get_playlist_number() 00597 { 00598 if (selected_player == PLAYER_SNACKAMP) 00599 { 00600 return snackamp_get_playlist_number(); 00601 } 00602 else if (selected_player == PLAYER_AUDACIOUS) 00603 { 00604 #ifndef __WIN32__ 00605 #ifndef NO_AUDACIOUS 00606 return myxmms_get_playlist_number(); 00607 #endif 00608 #endif 00609 } 00610 else 00611 { 00612 #ifndef NO_GSTREAMER 00613 return gstreamer_get_playlist_number(); 00614 #endif 00615 } 00616 00617 return 0; 00618 } 00619 00621 gint player_quit() 00622 { 00623 /*if (selected_player == PLAYER_SNACKAMP) 00624 { 00625 return snackamp_quit(); 00626 } 00627 else 00628 { 00629 #ifndef __WIN32__ 00630 #ifndef NO_AUDACIOUS 00631 return myxmms_quit(); 00632 #endif 00633 #endif 00634 }*/ 00635 if (selected_player == PLAYER_GSTREAMER) 00636 { 00637 #ifndef NO_GSTREAMER 00638 gstreamer_quit(); 00639 #endif 00640 } 00641 00642 return 0; 00643 }