summaryrefslogtreecommitdiffstats
path: root/src/audio.vala
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2012-10-05 22:26:47 +0200
committerSebastian Reichel <sre@ring0.de>2012-10-05 22:26:47 +0200
commit22190faeace11d58b452d0c5dea8b7c613c08705 (patch)
treef884921f6e17cc9ca886c752e58d8f0892e72909 /src/audio.vala
parent400a54fad59b0fbecb451ce86fc40655ce84139f (diff)
downloadserial-barcode-scanner-22190faeace11d58b452d0c5dea8b7c613c08705.tar.bz2
play audio on shutdown (GH-13)
Diffstat (limited to 'src/audio.vala')
-rw-r--r--src/audio.vala14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/audio.vala b/src/audio.vala
index 8e36c70..e30f3b1 100644
--- a/src/audio.vala
+++ b/src/audio.vala
@@ -16,11 +16,25 @@
public class AudioPlayer {
private dynamic Gst.Element p;
+ public signal void end_of_stream();
+
+ private bool bus_callback(Gst.Bus bus, Gst.Message message) {
+ switch (message.type) {
+ case Gst.MessageType.EOS:
+ end_of_stream();
+ break;
+ }
+
+ return true;
+ }
+
public AudioPlayer() {
p = Gst.ElementFactory.make("playbin", "play");
+ p.get_bus().add_watch(bus_callback);
}
public void play(string file) {
+ p.set_state(Gst.State.NULL);
p.uri = "file://"+Environment.get_current_dir()+"/sounds/"+file;
p.set_state(Gst.State.PLAYING);
}