summaryrefslogtreecommitdiffstats
path: root/src/music.rs
diff options
context:
space:
mode:
authorRaymond Hogenson <rhogenson@posteo.net>2018-08-22 16:28:58 -0400
committerRaymond Hogenson <rhogenson@posteo.net>2018-08-22 16:28:58 -0400
commit8656df15f29ebe0900db830eb6e5d8d1f11c2e03 (patch)
treed0b1d3d437dff05ced40d90c5beae7b1e7d1bc49 /src/music.rs
parentChange SDL2 version (diff)
downloadstallman-shooter-8656df15f29ebe0900db830eb6e5d8d1f11c2e03.tar.zst
Add introduction and conclusion screens
We're releasing version 1.0.0 baby
Diffstat (limited to 'src/music.rs')
-rw-r--r--src/music.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/music.rs b/src/music.rs
new file mode 100644
index 0000000..90cd276
--- /dev/null
+++ b/src/music.rs
@@ -0,0 +1,32 @@
+extern crate std;
+
+pub struct Player {
+ player: Option<std::process::Child>,
+}
+
+impl Player {
+ pub fn play(&mut self) -> Result<(), &'static str> {
+ match std::process::Command::new("mpv").arg("https://www.youtube.com/watch?v=TdWd7Znz00Q").arg("--no-video").stdin(std::process::Stdio::null()).spawn() {
+ Ok(child) => {
+ self.player = Some(child);
+ Ok(())
+ }
+ Err(_) => Err("Couldn't use mpv to play music")
+ }
+ }
+}
+
+impl Drop for Player {
+ fn drop(&mut self) {
+ match self.player {
+ Some(ref mut x) => {
+ let _ = x.kill();
+ }
+ None => { }
+ }
+ }
+}
+
+pub fn new() -> Player {
+ Player { player: None }
+}