From 22190faeace11d58b452d0c5dea8b7c613c08705 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 5 Oct 2012 22:26:47 +0200 Subject: play audio on shutdown (GH-13) --- src/audio.vala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/audio.vala') 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); } -- cgit v1.2.3