diff --git a/livesupport/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h b/livesupport/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h index a17c8e38f..b2f80b2fc 100644 --- a/livesupport/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h +++ b/livesupport/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h,v $ ------------------------------------------------------------------------------*/ @@ -68,7 +68,7 @@ using namespace LiveSupport::Core; * A generic interface for playing audio files. * * @author $Author: fgerlits $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class AudioPlayerInterface { @@ -135,18 +135,31 @@ class AudioPlayerInterface /** * Start playing. * This call will start playing the active playlist, which was - * set by a previous call to playThis(). + * set by a previous call to open(). * Playing can be stopped by calling stop(). * * @exception std::logic_error if there was no previous call to * playThis(). - * @see #playThis + * @see #open * @see #stop */ virtual void start(void) throw (std::logic_error) = 0; + /** + * Pause the player. + * Playing can be resumed by calling start(). + * + * @exception std::logic_error if there was no previous call to + * open(). + * @see #open + * @see #start + */ + virtual void + pause(void) throw (std::logic_error) + = 0; + /** * Tell if we're currently playing. * diff --git a/livesupport/modules/playlistExecutor/src/AudioPlayerFactoryTest.cxx b/livesupport/modules/playlistExecutor/src/AudioPlayerFactoryTest.cxx index fe2696d87..0fc88f034 100644 --- a/livesupport/modules/playlistExecutor/src/AudioPlayerFactoryTest.cxx +++ b/livesupport/modules/playlistExecutor/src/AudioPlayerFactoryTest.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/AudioPlayerFactoryTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -147,7 +147,7 @@ AudioPlayerFactoryTest :: simplePlayTest(void) { Ptr::Ref audioPlayerFactory; Ptr::Ref audioPlayer; - Ptr::Ref sleepT(new time_duration(microseconds(10))); + Ptr::Ref sleepT; audioPlayerFactory = AudioPlayerFactory::getInstance(); audioPlayer = audioPlayerFactory->getAudioPlayer(); @@ -160,6 +160,15 @@ AudioPlayerFactoryTest :: simplePlayTest(void) CPPUNIT_ASSERT(!audioPlayer->isPlaying()); audioPlayer->start(); CPPUNIT_ASSERT(audioPlayer->isPlaying()); + + sleepT.reset(new time_duration(seconds(8))); + TimeConversion::sleep(sleepT); + audioPlayer->pause(); + sleepT.reset(new time_duration(seconds(1))); + TimeConversion::sleep(sleepT); + audioPlayer->start(); + + sleepT.reset(new time_duration(microseconds(10))); while (audioPlayer->isPlaying()) { TimeConversion::sleep(sleepT); } diff --git a/livesupport/modules/playlistExecutor/src/HelixPlayer.cxx b/livesupport/modules/playlistExecutor/src/HelixPlayer.cxx index 50abe2263..e16a12169 100644 --- a/livesupport/modules/playlistExecutor/src/HelixPlayer.cxx +++ b/livesupport/modules/playlistExecutor/src/HelixPlayer.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.16 $ + Version : $Revision: 1.17 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayer.cxx,v $ ------------------------------------------------------------------------------*/ @@ -329,6 +329,20 @@ HelixPlayer :: start(void) throw (std::logic_error) } +/*------------------------------------------------------------------------------ + * Pause the player + *----------------------------------------------------------------------------*/ +void +HelixPlayer :: pause(void) throw (std::logic_error) +{ + if (player->GetSourceCount() == 0) { + throw std::logic_error("HelixPlayer::open() not called yet"); + } + player->Pause(); + playing = false; // Is this what we want? +} + + /*------------------------------------------------------------------------------ * Tell if we're playing *----------------------------------------------------------------------------*/ diff --git a/livesupport/modules/playlistExecutor/src/HelixPlayer.h b/livesupport/modules/playlistExecutor/src/HelixPlayer.h index 776e5c7a2..be21c03d3 100644 --- a/livesupport/modules/playlistExecutor/src/HelixPlayer.h +++ b/livesupport/modules/playlistExecutor/src/HelixPlayer.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.14 $ + Version : $Revision: 1.15 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayer.h,v $ ------------------------------------------------------------------------------*/ @@ -112,7 +112,7 @@ using namespace LiveSupport::Core; * * * @author $Author: fgerlits $ - * @version $Revision: 1.14 $ + * @version $Revision: 1.15 $ */ class HelixPlayer : virtual public Configurable, virtual public AudioPlayerInterface, @@ -338,6 +338,18 @@ class HelixPlayer : virtual public Configurable, virtual void start(void) throw (std::logic_error); + /** + * Pause the player. + * Playing can be resumed by calling start(). + * + * @exception std::logic_error if there was no previous call to + * open(). + * @see #open + * @see #start + */ + virtual void + pause(void) throw (std::logic_error); + /** * Tell if we're currently playing. * diff --git a/livesupport/products/gLiveSupport/src/DjBagWindow.cxx b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx index 9e3dc45c7..4c0d0c937 100644 --- a/livesupport/products/gLiveSupport/src/DjBagWindow.cxx +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.8 $ + Version : $Revision: 1.9 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -70,6 +70,10 @@ DjBagWindow :: DjBagWindow (Ptr::Ref gLiveSupport, set_title(*getResourceUstring("windowTitle")); playButton.reset(new Gtk::Button( *getResourceUstring("playButtonLabel"))); + pauseButton.reset(new Gtk::Button( + *getResourceUstring("pauseButtonLabel"))); + stopButton.reset(new Gtk::Button( + *getResourceUstring("stopButtonLabel"))); closeButton.reset(new Gtk::Button( *getResourceUstring("closeButtonLabel"))); } catch (std::invalid_argument &e) { @@ -82,7 +86,23 @@ DjBagWindow :: DjBagWindow (Ptr::Ref gLiveSupport, playButton->set_relief(Gtk::RELIEF_NORMAL); // Register the signal handler for the button getting clicked. playButton->signal_clicked().connect(sigc::mem_fun(*this, - &DjBagWindow::onPlayItem)); + &DjBagWindow::onPlayButtonClicked)); + + // set up the pause button + pauseButton->set_name("pauseButton"); + pauseButton->set_flags(Gtk::CAN_FOCUS|Gtk::CAN_DEFAULT|Gtk::HAS_DEFAULT); + pauseButton->set_relief(Gtk::RELIEF_NORMAL); + // Register the signal handler for the button getting clicked. + pauseButton->signal_clicked().connect(sigc::mem_fun(*this, + &DjBagWindow::onPauseButtonClicked)); + + // set up the stop button + stopButton->set_name("stopButton"); + stopButton->set_flags(Gtk::CAN_FOCUS|Gtk::CAN_DEFAULT|Gtk::HAS_DEFAULT); + stopButton->set_relief(Gtk::RELIEF_NORMAL); + // Register the signal handler for the button getting clicked. + stopButton->signal_clicked().connect(sigc::mem_fun(*this, + &DjBagWindow::onStopButtonClicked)); // set up the close button closeButton->set_name("closeButton"); @@ -111,6 +131,14 @@ DjBagWindow :: DjBagWindow (Ptr::Ref gLiveSupport, playButtonBox.set_border_width(5); playButtonBox.set_layout(Gtk::BUTTONBOX_SPREAD); + playButtonBox.pack_start(*pauseButton, Gtk::PACK_SHRINK); + playButtonBox.set_border_width(5); + playButtonBox.set_layout(Gtk::BUTTONBOX_SPREAD); + + playButtonBox.pack_start(*stopButton, Gtk::PACK_SHRINK); + playButtonBox.set_border_width(5); + playButtonBox.set_layout(Gtk::BUTTONBOX_SPREAD); + buttonBox.pack_start(*closeButton, Gtk::PACK_SHRINK); buttonBox.set_border_width(5); buttonBox.set_layout(Gtk::BUTTONBOX_END); @@ -555,8 +583,59 @@ DjBagWindow :: onPlayItem(void) throw () if (iter) { Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; - gLiveSupport->play(playable); + try { + gLiveSupport->playAudio(playable); + } catch (XmlRpcException &e) { + std::cerr << "GLiveSupport::playAudio() error:" << std::endl + << e.what() << std::endl; + } catch (std::exception &e) { + std::cerr << "GLiveSupport::playAudio() error:" << std::endl + << e.what() << std::endl; + } } } } + +/*------------------------------------------------------------------------------ + * Event handler for the Play button getting clicked + *----------------------------------------------------------------------------*/ +void +DjBagWindow :: onPlayButtonClicked(void) throw () +{ + onPlayItem(); +} + + +/*------------------------------------------------------------------------------ + * Event handler for the Pause button getting clicked + *----------------------------------------------------------------------------*/ +void +DjBagWindow :: onPauseButtonClicked(void) throw () +{ + try { + gLiveSupport->pauseAudio(); + } catch (std::logic_error &e) { + std::cerr << "GLiveSupport::pauseAudio() error:" << std::endl + << e.what() << std::endl; + } +} + + +/*------------------------------------------------------------------------------ + * Event handler for the Stop button getting clicked + *----------------------------------------------------------------------------*/ +void +DjBagWindow :: onStopButtonClicked(void) throw () +{ + try { + gLiveSupport->stopAudio(); + } catch (XmlRpcException &e) { + std::cerr << "GLiveSupport::stopAudio() error:" << std::endl + << e.what() << std::endl; + } catch (std::logic_error &e) { + std::cerr << "GLiveSupport::stopAudio() error:" << std::endl + << e.what() << std::endl; + } +} + diff --git a/livesupport/products/gLiveSupport/src/DjBagWindow.h b/livesupport/products/gLiveSupport/src/DjBagWindow.h index d4e4af43e..12df6a143 100644 --- a/livesupport/products/gLiveSupport/src/DjBagWindow.h +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -68,7 +68,7 @@ using namespace LiveSupport::Core; * playlists. * * @author $Author: fgerlits $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class DjBagWindow : public Gtk::Window, public LocalizedObject { @@ -80,7 +80,7 @@ class DjBagWindow : public Gtk::Window, public LocalizedObject * Lists one clip per row. * * @author $Author: fgerlits $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class ModelColumns : public Gtk::TreeModel::ColumnRecord { @@ -152,6 +152,16 @@ class DjBagWindow : public Gtk::Window, public LocalizedObject */ Ptr::Ref playButton; + /** + * The pause button. + */ + Ptr::Ref pauseButton; + + /** + * The stop button. + */ + Ptr::Ref stopButton; + /** * The box containing the close button. */ @@ -174,6 +184,24 @@ class DjBagWindow : public Gtk::Window, public LocalizedObject */ Ptr::Ref playlistMenu; + /** + * Signal handler for the play button clicked. + */ + virtual void + onPlayButtonClicked(void) throw (); + + /** + * Signal handler for the pause button clicked. + */ + virtual void + onPauseButtonClicked(void) throw (); + + /** + * Signal handler for the stop button clicked. + */ + virtual void + onStopButtonClicked(void) throw (); + /** * Signal handler for the close button clicked. */ diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx index ef5fdbd1b..8154c9b4f 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.22 $ + Version : $Revision: 1.23 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $ ------------------------------------------------------------------------------*/ @@ -477,7 +477,7 @@ GLiveSupport :: addToPlaylist(Ptr::Ref id) openPlaylistForEditing(); } - // for some wierd reason, the storage functions won't accept + // for some weird reason, the storage functions won't accept // Ptr::Ref, just a non-const version Ptr::Ref uid(new UniqueId(id->getId())); @@ -572,40 +572,85 @@ GLiveSupport :: deletePlayable(Ptr::Ref playable) *----------------------------------------------------------------------------*/ void LiveSupport :: GLiveSupport :: -GLiveSupport :: play(Ptr::Ref playable) - throw (XmlRpcException, - std::runtime_error) +GLiveSupport :: playAudio(Ptr::Ref playable) + throw (XmlRpcException, + std::invalid_argument, + std::logic_error, + std::runtime_error) { - Ptr::Ref tempAudioClip; - Ptr::Ref tempPlaylist; - Ptr::Ref sleepT(new time_duration(microseconds(10))); - + if (audioPlayerIsPaused) { + audioPlayer->start(); + audioPlayerIsPaused = false; + return; + } + + stopAudio(); // stop the audio player and release old resources + switch (playable->getType()) { case Playable::AudioClipType: - tempAudioClip = storage->acquireAudioClip(sessionId, - playable->getId()); - audioPlayer->open(*tempAudioClip->getUri()); + itemPlayingNow = storage->acquireAudioClip(sessionId, + playable->getId()); + audioPlayer->open(*itemPlayingNow->getUri()); audioPlayer->start(); - while (audioPlayer->isPlaying()) { - TimeConversion::sleep(sleepT); - } - audioPlayer->close(); - storage->releaseAudioClip(sessionId, tempAudioClip); break; case Playable::PlaylistType: - tempPlaylist = storage->acquirePlaylist(sessionId, - playable->getId()); - audioPlayer->openAndStart(tempPlaylist); - while (audioPlayer->isPlaying()) { - TimeConversion::sleep(sleepT); - } - audioPlayer->close(); - storage->releasePlaylist(sessionId, tempPlaylist); + itemPlayingNow = storage->acquirePlaylist(sessionId, + playable->getId()); + audioPlayer->openAndStart(itemPlayingNow->getPlaylist()); break; - default: + default: // this never happens break; } + + audioPlayerIsPaused = false; +} + + +/*------------------------------------------------------------------------------ + * Stop the audio player. + *----------------------------------------------------------------------------*/ +void +LiveSupport :: GLiveSupport :: +GLiveSupport :: stopAudio(void) + throw (XmlRpcException, + std::logic_error) +{ + audioPlayer->close(); + + if (itemPlayingNow) { + switch (itemPlayingNow->getType()) { + case Playable::AudioClipType: + storage->releaseAudioClip(sessionId, + itemPlayingNow->getAudioClip()); + itemPlayingNow.reset(); + break; + case Playable::PlaylistType: + storage->releasePlaylist(sessionId, + itemPlayingNow->getPlaylist()); + itemPlayingNow.reset(); + break; + default: // this never happens + break; + } + } + + audioPlayerIsPaused = false; +} + + +/*------------------------------------------------------------------------------ + * Pause the audio player. + *----------------------------------------------------------------------------*/ +void +LiveSupport :: GLiveSupport :: +GLiveSupport :: pauseAudio(void) + throw (std::logic_error) +{ + if (audioPlayer->isPlaying()) { + audioPlayer->pause(); + audioPlayerIsPaused = true; + } } diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.h b/livesupport/products/gLiveSupport/src/GLiveSupport.h index 6dc36ec93..a7e1b2df0 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.21 $ + Version : $Revision: 1.22 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $ ------------------------------------------------------------------------------*/ @@ -100,7 +100,7 @@ class MasterPanelWindow; * respective documentation. * * @author $Author: fgerlits $ - * @version $Revision: 1.21 $ + * @version $Revision: 1.22 $ * @see LocalizedObject#getBundle(const xmlpp::Element &) * @see AuthenticationClientFactory * @see StorageClientFactory @@ -182,6 +182,16 @@ class GLiveSupport : public LocalizedConfigurable, */ Ptr::Ref editedPlaylist; + /** + * The playlist or audio clip that is being played (may be null). + */ + Ptr::Ref itemPlayingNow; + + /** + * True if the audio player has been paused. + */ + bool audioPlayerIsPaused; + /** * Read a supportedLanguages configuration element, * and fill the supportedLanguages map with its contents. @@ -511,13 +521,37 @@ class GLiveSupport : public LocalizedConfigurable, * Play a Playable object using the audio player. * * @param playable the Playable object to play. - * @exception XmlRpcException in case of XML-RPC errors. + * @exception XmlRpcException in case of storage server errors. + * @exception std::invalid_argument in case of audio player errors. + * @exception std::logic_error in case of audio player errors. * @exception std::runtime_error in case of audio player errors. */ virtual void - play(Ptr::Ref playable) - throw (XmlRpcException, - std::runtime_error); + playAudio(Ptr::Ref playable) + throw (XmlRpcException, + std::invalid_argument, + std::logic_error, + std::runtime_error); + + /** + * Stop the audio player. + * + * @exception XmlRpcException in case of storage server errors. + * @exception std::logic_error in case of audio player errors. + */ + virtual void + stopAudio(void) + throw (XmlRpcException, + std::logic_error); + + /** + * Pause the audio player. + * + * @exception std::logic_error in case of audio player errors. + */ + virtual void + pauseAudio(void) + throw (std::logic_error); }; diff --git a/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx b/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx index a58f56f7b..90bf02bd0 100644 --- a/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx +++ b/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.13 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.14 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -177,6 +177,7 @@ MasterPanelWindow :: MasterPanelWindow (Ptr::Ref gLiveSupport, MasterPanelWindow :: ~MasterPanelWindow (void) throw () { resetTimer(); + gLiveSupport->stopAudio(); } diff --git a/livesupport/products/gLiveSupport/var/hu.txt b/livesupport/products/gLiveSupport/var/hu.txt index eee4bab8c..a2b6268ec 100644 --- a/livesupport/products/gLiveSupport/var/hu.txt +++ b/livesupport/products/gLiveSupport/var/hu.txt @@ -38,8 +38,10 @@ hu:table typeColumnLabel:string { "típus" } titleColumnLabel:string { "cím" } - closeButtonLabel:string { "bezár" } playButtonLabel:string { "lejátszás" } + pauseButtonLabel:string { "szünet" } + stopButtonLabel:string { "stop" } + closeButtonLabel:string { "bezár" } upMenuItem:string { "_Fel" } downMenuItem:string { "_Le" } diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index ac641b362..4e2f1058a 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -38,8 +38,10 @@ root:table typeColumnLabel:string { "type" } titleColumnLabel:string { "title" } - closeButtonLabel:string { "close" } playButtonLabel:string { "play" } + pauseButtonLabel:string { "pause" } + stopButtonLabel:string { "stop" } + closeButtonLabel:string { "close" } upMenuItem:string { "Move _Up" } downMenuItem:string { "Move D_own" }