created a "stop currently playing" button in the Scheduler window;
fixing #1434, or most of it
This commit is contained in:
parent
d8cd7e8eb0
commit
7a5f5d3ded
8 changed files with 118 additions and 2 deletions
|
@ -252,6 +252,16 @@ class SchedulerClientInterface
|
|||
throw (XmlRpcException)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Stop the scheduler's audio player.
|
||||
*
|
||||
* @param sessionId a valid session ID to identify the user.
|
||||
* @exception XmlRpcException if there is an error.
|
||||
*/
|
||||
virtual void
|
||||
stopCurrentlyPlaying(Ptr<SessionId>::Ref sessionId)
|
||||
throw (XmlRpcException) = 0;
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
*/
|
||||
|
|
|
@ -554,3 +554,41 @@ SchedulerDaemonXmlRpcClient :: restoreBackup(
|
|||
xmlRpcClient.close();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Stop the scheduler's audio player.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemonXmlRpcClient :: stopCurrentlyPlaying(
|
||||
Ptr<SessionId>::Ref sessionId)
|
||||
throw (Core::XmlRpcException)
|
||||
{
|
||||
XmlRpcValue xmlRpcParams;
|
||||
XmlRpcValue xmlRpcResult;
|
||||
|
||||
XmlRpcClient xmlRpcClient(xmlRpcHost->c_str(),
|
||||
xmlRpcPort,
|
||||
xmlRpcUri->c_str(),
|
||||
false);
|
||||
|
||||
XmlRpcTools::sessionIdToXmlRpcValue(sessionId, xmlRpcParams);
|
||||
|
||||
xmlRpcResult.clear();
|
||||
if (!xmlRpcClient.execute("stopCurrentlyPlaying",
|
||||
xmlRpcParams,
|
||||
xmlRpcResult)) {
|
||||
throw Core::XmlRpcCommunicationException(
|
||||
"cannot execute XML-RPC method 'stopCurrentlyPlaying'");
|
||||
}
|
||||
|
||||
if (xmlRpcClient.isFault()) {
|
||||
std::stringstream eMsg;
|
||||
eMsg << "XML-RPC method 'stopCurrentlyPlaying'"
|
||||
<< " returned error message:\n"
|
||||
<< xmlRpcResult;
|
||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||
}
|
||||
|
||||
xmlRpcClient.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -330,6 +330,16 @@ class SchedulerDaemonXmlRpcClient :
|
|||
restoreBackup(Ptr<SessionId>::Ref sessionId,
|
||||
Ptr<const Glib::ustring>::Ref path)
|
||||
throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
* Stop the scheduler's audio player.
|
||||
*
|
||||
* @param sessionId a valid session ID to identify the user.
|
||||
* @exception XmlRpcException if there is an error.
|
||||
*/
|
||||
virtual void
|
||||
stopCurrentlyPlaying(Ptr<SessionId>::Ref sessionId)
|
||||
throw (XmlRpcException);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -201,7 +201,31 @@ SchedulerWindow :: constructScheduleView(void) throw ()
|
|||
Gtk::VBox *
|
||||
SchedulerWindow :: constructStatusView(void) throw ()
|
||||
{
|
||||
Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
Gtk::Label * stopCurrentlyPlayingLabel;
|
||||
Button * stopCurrentlyPlayingButton;
|
||||
try {
|
||||
stopCurrentlyPlayingLabel = Gtk::manage(new Gtk::Label(
|
||||
*getResourceUstring("stopCurrentlyPlayingText")));
|
||||
stopCurrentlyPlayingButton = Gtk::manage(wf->createButton(
|
||||
*getResourceUstring("stopCurrentlyPlayingButtonLabel")));
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
stopCurrentlyPlayingButton->signal_clicked().connect(sigc::mem_fun(
|
||||
*this,
|
||||
&SchedulerWindow::onStopCurrentlyPlayingButtonClicked));
|
||||
|
||||
Gtk::HBox * stopCurrentlyPlayingBox = Gtk::manage(new Gtk::HBox);
|
||||
stopCurrentlyPlayingBox->pack_start(*stopCurrentlyPlayingLabel,
|
||||
Gtk::PACK_SHRINK, 5);
|
||||
stopCurrentlyPlayingBox->pack_start(*stopCurrentlyPlayingButton,
|
||||
Gtk::PACK_SHRINK, 5);
|
||||
|
||||
Gtk::VBox * view = Gtk::manage(new Gtk::VBox);
|
||||
view->pack_start(*stopCurrentlyPlayingBox, Gtk::PACK_SHRINK, 20);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -351,3 +375,22 @@ SchedulerWindow :: onDeleteItem(void) throw ()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Signal handler for the "stop currently playing" button getting clicked.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerWindow :: onStopCurrentlyPlayingButtonClicked(void) throw ()
|
||||
{
|
||||
Ptr<SessionId>::Ref sessionId = gLiveSupport->getSessionId();
|
||||
Ptr<SchedulerClientInterface>::Ref
|
||||
scheduler = gLiveSupport->getScheduler();
|
||||
|
||||
try {
|
||||
scheduler->stopCurrentlyPlaying(sessionId);
|
||||
|
||||
} catch (XmlRpcException &e) {
|
||||
// TODO: signal error here
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -228,6 +228,13 @@ class SchedulerWindow : public GuiWindow
|
|||
virtual void
|
||||
onDeleteItem(void) throw ();
|
||||
|
||||
/**
|
||||
* Signal handler for the "stop currently playing" button
|
||||
* getting clicked.
|
||||
*/
|
||||
virtual void
|
||||
onStopCurrentlyPlayingButtonClicked(void) throw ();
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -168,6 +168,11 @@ root:table
|
|||
endColumnLabel:string { "end" }
|
||||
deleteMenuItem:string { "_Delete" }
|
||||
|
||||
stopCurrentlyPlayingText:string
|
||||
{ "Currently playing in scheduler:" }
|
||||
stopCurrentlyPlayingButtonLabel:string
|
||||
{ "Stop" }
|
||||
|
||||
closeButtonLabel:string { "Close" }
|
||||
}
|
||||
|
||||
|
|
|
@ -170,6 +170,8 @@ PlaylistEvent :: stop(void) throw ()
|
|||
audioPlayer->close();
|
||||
} catch (std::logic_error &e) {
|
||||
// TODO: handle error
|
||||
// NOTE: this may not be an error, because the user may have stopped
|
||||
// the playback manually (see Scheduler::StopCurrentlyPlayingMethod)
|
||||
std::cerr << "PlaylistEvent::stop error: " << std::endl;
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,8 @@ using namespace LiveSupport::Core;
|
|||
/**
|
||||
* An XML-RPC method object to stop the scheduler's audio player.
|
||||
*
|
||||
* The name of the method when called through XML-RPC is "stopCurrenlyPlaying".
|
||||
* The name of the method when called through XML-RPC is
|
||||
* "stopCurrentlyPlaying".
|
||||
*
|
||||
* The expected parameter is an XML-RPC structure, with the following
|
||||
* member:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue