summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJokler <jokler@protonmail.com>2020-01-07 17:03:00 +0100
committerJokler <jokler@protonmail.com>2020-01-07 17:03:00 +0100
commit74e9d2a707f31d99865f9c406893c1221df27db4 (patch)
tree159072c508092f28eb860747f8042008fcee930f
parent96406b289ed823d0422f14772399b3e97edb4049 (diff)
downloadpokebot-74e9d2a707f31d99865f9c406893c1221df27db4.tar.gz
pokebot-74e9d2a707f31d99865f9c406893c1221df27db4.zip
Show correct state in the bot's name after loading
-rw-r--r--src/main.rs10
-rw-r--r--src/state.rs12
2 files changed, 15 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index 6d6c00e..cdb0bd6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,8 +12,8 @@ use structopt::clap::AppSettings;
use structopt::StructOpt;
use tsclientlib::{
- events::Event, ConnectOptions, Connection, ConnectionLock, Event::ConEvents,
- Identity, MessageTarget,
+ events::Event, ConnectOptions, Connection, ConnectionLock, Event::ConEvents, Identity,
+ MessageTarget,
};
use log::error;
@@ -122,9 +122,9 @@ async fn async_main() {
//ctrlc_fut.await.map_err(|(e, _)| e).unwrap();
//conn.disconnect(DisconnectOptions::new())
- //.compat()
- //.await
- //.unwrap();
+ //.compat()
+ //.await
+ //.unwrap();
// TODO Should not be required
//std::process::exit(0);
diff --git a/src/state.rs b/src/state.rs
index 8c6a290..2797254 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -228,11 +228,19 @@ impl State {
address: address.to_owned(),
};
- if gst::State::Null == self.pipeline.get_state(gst::ClockTime(None)).1 {
+ let state = self.pipeline.get_state(gst::ClockTime(None)).1;
+ if gst::State::Null == state {
self.set_name("PokeBot - Playing");
self.start_audio(req);
} else {
- self.set_name("PokeBot - Playing");
+ match state {
+ gst::State::Playing => self.set_name("PokeBot - Playing"),
+ gst::State::Paused => self.set_name("PokeBot - Paused"),
+ gst::State::Ready => self.set_name("PokeBot - Stopped"),
+ gst::State::Null | gst::State::__Unknown(_) | gst::State::VoidPending => {
+ unreachable!()
+ }
+ }
let title = req.title.clone();
if self