diff --git a/livesupport/products/gLiveSupport/src/DjBagWindow.cxx b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx index 24fff40e5..100d76d1e 100644 --- a/livesupport/products/gLiveSupport/src/DjBagWindow.cxx +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.6 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -144,6 +144,10 @@ DjBagWindow :: DjBagWindow (Ptr::Ref gLiveSupport, *getResourceUstring("deleteMenuItem"), sigc::mem_fun(*this, &DjBagWindow::onDeleteItem))); + audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("playMenuItem"), + sigc::mem_fun(*this, + &DjBagWindow::onPlayItem))); audioClipMenu->accelerate(*this); // create the right-click entry context menu for playlists @@ -174,7 +178,11 @@ DjBagWindow :: DjBagWindow (Ptr::Ref gLiveSupport, *getResourceUstring("deleteMenuItem"), sigc::mem_fun(*this, &DjBagWindow::onDeleteItem))); - audioClipMenu->accelerate(*this); + playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( + *getResourceUstring("playMenuItem"), + sigc::mem_fun(*this, + &DjBagWindow::onPlayItem))); + playlistMenu->accelerate(*this); // show showContents(); @@ -518,3 +526,23 @@ DjBagWindow :: onSchedulePlaylist(void) throw () } } + +/*------------------------------------------------------------------------------ + * Event handler for the Play menu item selected from the entry conext menu + *----------------------------------------------------------------------------*/ +void +DjBagWindow :: onPlayItem(void) throw () +{ + Glib::RefPtr refSelection = + treeView.get_selection(); + + if (refSelection) { + Gtk::TreeModel::iterator iter = refSelection->get_selected(); + if (iter) { + Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; + + gLiveSupport->play(playable); + } + } +} + diff --git a/livesupport/products/gLiveSupport/src/DjBagWindow.h b/livesupport/products/gLiveSupport/src/DjBagWindow.h index 477de8a29..e279f06e5 100644 --- a/livesupport/products/gLiveSupport/src/DjBagWindow.h +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.4 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -67,8 +67,8 @@ using namespace LiveSupport::Core; * The DJ Bag window, showing recent and relevant audio clips and * playlists. * - * @author $Author: maroy $ - * @version $Revision: 1.4 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.5 $ */ class DjBagWindow : public Gtk::Window, public LocalizedObject { @@ -79,8 +79,8 @@ class DjBagWindow : public Gtk::Window, public LocalizedObject * The columns model needed by Gtk::TreeView. * Lists one clip per row. * - * @author $Author: maroy $ - * @version $Revision: 1.4 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.5 $ */ class ModelColumns : public Gtk::TreeModel::ColumnRecord { @@ -220,6 +220,13 @@ class DjBagWindow : public Gtk::Window, public LocalizedObject virtual void onSchedulePlaylist(void) throw (); + /** + * Signal handler for the "play item" menu item selected + * from the entry context menu. + */ + virtual void + onPlayItem(void) throw (); + /** * Delete an item from the storage and remove it from the dj bag. * diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx index e6a8a2c5d..9e3621bee 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.20 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.21 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $ ------------------------------------------------------------------------------*/ @@ -41,12 +41,14 @@ #include "LiveSupport/Storage/StorageClientFactory.h" #include "LiveSupport/SchedulerClient/SchedulerClientFactory.h" #include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h" +#include "LiveSupport/Core/TimeConversion.h" #include "MasterPanelWindow.h" #include "GLiveSupport.h" using namespace boost; +using namespace boost::posix_time; using namespace LiveSupport::Core; using namespace LiveSupport::Authentication; @@ -565,3 +567,45 @@ GLiveSupport :: deletePlayable(Ptr::Ref playable) } +/*------------------------------------------------------------------------------ + * Play a Playable object using the audio player. + *----------------------------------------------------------------------------*/ +void +LiveSupport :: GLiveSupport :: +GLiveSupport :: play(Ptr::Ref playable) + throw (XmlRpcException, + std::runtime_error) +{ + Ptr::Ref tempAudioClip; + Ptr::Ref tempPlaylist; + Ptr::Ref sleepT(new time_duration(microseconds(10))); + + switch (playable->getType()) { + case Playable::AudioClipType: + tempAudioClip = storage->acquireAudioClip(sessionId, + playable->getId()); + audioPlayer->open(*tempAudioClip->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); + break; + + default: + break; + } +} + diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.h b/livesupport/products/gLiveSupport/src/GLiveSupport.h index 4232efc17..6dc36ec93 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: maroy $ - Version : $Revision: 1.20 $ + Author : $Author: fgerlits $ + Version : $Revision: 1.21 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $ ------------------------------------------------------------------------------*/ @@ -99,8 +99,8 @@ class MasterPanelWindow; * schedulerClientFactory elements see their * respective documentation. * - * @author $Author: maroy $ - * @version $Revision: 1.20 $ + * @author $Author: fgerlits $ + * @version $Revision: 1.21 $ * @see LocalizedObject#getBundle(const xmlpp::Element &) * @see AuthenticationClientFactory * @see StorageClientFactory @@ -507,6 +507,17 @@ class GLiveSupport : public LocalizedConfigurable, deletePlayable(Ptr::Ref playable) throw (XmlRpcException); + /** + * Play a Playable object using the audio player. + * + * @param playable the Playable object to play. + * @exception XmlRpcException in case of XML-RPC errors. + * @exception std::runtime_error in case of audio player errors. + */ + virtual void + play(Ptr::Ref playable) + throw (XmlRpcException, + std::runtime_error); }; diff --git a/livesupport/products/gLiveSupport/var/hu.txt b/livesupport/products/gLiveSupport/var/hu.txt index 3b93a5ed3..ed0c33858 100644 --- a/livesupport/products/gLiveSupport/var/hu.txt +++ b/livesupport/products/gLiveSupport/var/hu.txt @@ -46,6 +46,7 @@ hu:table addToPlaylistMenuItem:string { "_Hozzáad Playlist-hez" } schedulePlaylistMenuItem:string { "_Playlist időzítése" } deleteMenuItem:string { "_Töröl" } + playMenuItem:string { "Le_játszâs" } } playlistListWindow:table diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index 95f96e311..149fca50c 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -46,6 +46,7 @@ root:table addToPlaylistMenuItem:string { "_Add To Playlist" } schedulePlaylistMenuItem:string { "_Schedule Playlist" } deleteMenuItem:string { "_Delete" } + playMenuItem:string { "_Play" } } playlistListWindow:table