00001 /*************************************************************************** 00002 * Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider, * 00003 * Matthias Hardt, Guido Madaus * 00004 * * 00005 * Copyright (C) 2007-2008 BerLinux Solutions GbR * 00006 * Stefan Schwarzer & Guido Madaus * 00007 * * 00008 * Copyright (C) 2009-2013 BerLinux Solutions GmbH * 00009 * * 00010 * Authors: * 00011 * Stefan Schwarzer <stefan.schwarzer@diskohq.org>, * 00012 * Matthias Hardt <matthias.hardt@diskohq.org>, * 00013 * Jens Schneider <jens.schneider@diskohq.org>, * 00014 * Guido Madaus <guido.madaus@diskohq.org>, * 00015 * Patrick Helterhoff <patrick.helterhoff@diskohq.org>, * 00016 * René Bählkow <rene.baehlkow@diskohq.org> * 00017 * * 00018 * This library is free software; you can redistribute it and/or * 00019 * modify it under the terms of the GNU Lesser General Public * 00020 * License version 2.1 as published by the Free Software Foundation. * 00021 * * 00022 * This library is distributed in the hope that it will be useful, * 00023 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00025 * Lesser General Public License for more details. * 00026 * * 00027 * You should have received a copy of the GNU Lesser General Public * 00028 * License along with this library; if not, write to the * 00029 * Free Software Foundation, Inc., * 00030 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00031 **************************************************************************/ 00032 00033 #include "mmsbase/mmsmusicinterface.h" 00034 00035 MMSMusicInterface::MMSMusicInterface() { 00036 this->onNextSong = new sigc::signal<void, int>; 00037 this->onPrevSong = new sigc::signal<void, int>; 00038 } 00039 00040 MMSMusicInterface::~MMSMusicInterface() { 00041 if(this->onNextSong) { 00042 delete this->onNextSong; 00043 } 00044 00045 if(this->onPrevSong) 00046 delete this->onPrevSong; 00047 00048 if(this->manager) { 00049 this->manager->setOnNextSong(NULL); 00050 this->manager->setOnPrevSong(NULL); 00051 } 00052 } 00053 00054 void MMSMusicInterface::setManager(IMMSMusicManager *manager) { 00055 this->manager = manager; 00056 } 00057 00058 void MMSMusicInterface::init(string file) { 00059 if(this->manager!=NULL) { 00060 PLAYLIST playlist; 00061 playlist.push_back(file); 00062 this->manager->init(playlist); 00063 } 00064 } 00065 00066 void MMSMusicInterface::init(PLAYLIST list, int offset) { 00067 if(this->manager!=NULL) { 00068 this->manager->init(list,offset); 00069 if(this->onNextSong) 00070 this->manager->setOnNextSong(this->onNextSong); 00071 if(this->onPrevSong) 00072 this->manager->setOnPrevSong(this->onPrevSong); 00073 } 00074 } 00075 00076 void MMSMusicInterface::play() { 00077 if(this->manager!=NULL) { 00078 this->manager->play(); 00079 } 00080 } 00081 00082 void MMSMusicInterface::stop() { 00083 if(this->manager!=NULL) { 00084 this->manager->stopAll(); 00085 } 00086 } 00087 00088 void MMSMusicInterface::next() { 00089 if(this->manager) 00090 this->manager->next(); 00091 } 00092 00093 void MMSMusicInterface::prev() { 00094 if(this->manager) 00095 this->manager->prev(); 00096 00097 } 00098 00099 void MMSMusicInterface::pause() { 00100 if(this->manager) 00101 this->manager->pause(); 00102 00103 } 00104 00105 bool MMSMusicInterface::hasPlaylist() { 00106 if(this->manager) 00107 return this->manager->hasPlaylist(); 00108 00109 return false; 00110 } 00111 00112 PLAYLIST MMSMusicInterface::getPlaylist() { 00113 PLAYLIST list; 00114 if(this->manager) 00115 return this->manager->getPlaylist(); 00116 00117 return list; 00118 } 00119 00120 int MMSMusicInterface::getPlaylistOffset() { 00121 if(this->manager) 00122 return this->manager->getPlaylistOffset(); 00123 00124 return -1; 00125 } 00126 00127 bool MMSMusicInterface::isPlaying() { 00128 if(this->manager) 00129 return manager->isPlaying(); 00130 00131 return false; 00132 } 00133 00134 bool MMSMusicInterface::isPaused() { 00135 if(this->manager) 00136 return manager->isPaused(); 00137 00138 return true; 00139 } 00140 00141 bool MMSMusicInterface::getTimes(int *pos, int *length) { 00142 if(this->manager) 00143 return manager->getTimes(pos, length); 00144 00145 return false; 00146 } 00147 00148 void MMSMusicInterface::setRepeat(bool repeat) { 00149 this->manager->setRepeat(repeat); 00150 } 00151 00152 void MMSMusicInterface::setShuffle(bool shuffle) { 00153 this->manager->setShuffle(shuffle); 00154 } 00155 00156 IMMSMusicManager *MMSMusicInterface::manager=NULL;