summaryrefslogtreecommitdiffstats
path: root/src/audio/audio.vala
diff options
context:
space:
mode:
authorHolger Cremer <HolgerCremer@gmail.com>2018-08-27 19:38:11 +0200
committerHolger Cremer <HolgerCremer@gmail.com>2018-08-27 19:38:11 +0200
commit8f2ba2050ee78d0e4a47f1277c6bc4422d06170c (patch)
treec008d2878905e03df7a8bf8bd3330762cc2d8f43 /src/audio/audio.vala
parentbb55e121576a5b5d225bfc68c5062f386cc32db9 (diff)
parent3fc3ea6c6df237dbdf48d14703118b747bf5d647 (diff)
downloadserial-barcode-scanner-8f2ba2050ee78d0e4a47f1277c6bc4422d06170c.tar.bz2
Merge branch 'master' into better_inventory
Conflicts: README data/templates/products/entry.html docker/Dockerfile docker/init.sh src/database/database.vala src/database/db-interface.vala src/pdf-stock/Makefile src/pdf-stock/pdf-stock-interface.vala src/pdf-stock/pdf-stock.vala src/web/Makefile src/web/main.vala templates/menu.html templates/products/index.html
Diffstat (limited to 'src/audio/audio.vala')
-rw-r--r--src/audio/audio.vala36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/audio/audio.vala b/src/audio/audio.vala
index 9afb840..0d969e2 100644
--- a/src/audio/audio.vala
+++ b/src/audio/audio.vala
@@ -30,24 +30,31 @@ public class AudioPlayerImplementation {
return true;
}
- public AudioPlayerImplementation(string path) throws IOError {
+ public AudioPlayerImplementation(string path) throws IOError, DBusError {
this.path = path;
var alsa = Gst.ElementFactory.make("alsasink", "alsa");
- if (alsa == null)
- throw new GLib.IOError.FAILED("Cannot find alsa GStreamer plugin");
+ if (alsa == null) {
+ var msg = _("Cannot find alsa GStreamer plugin");
+ stderr.printf(msg);
+ throw new GLib.IOError.FAILED(msg);
+ }
p = Gst.ElementFactory.make("playbin", "player");
- if (p == null)
- throw new GLib.IOError.FAILED("Cannot find playbin2 GStreamer plugin");
+ if (p == null) {
+ var msg = _("Cannot find playbin2 GStreamer plugin");
+ stderr.printf(msg);
+ throw new GLib.IOError.FAILED(msg);
+ }
p.set("audio-sink", alsa);
p.get_bus().add_watch(Priority.DEFAULT, bus_callback);
}
- public void play_system(string file) {
+ public void play_system(string file) throws IOError, DBusError {
p.set_state(Gst.State.NULL);
- p.uri = "file://" + path + "system/" + file;
+ p.uri = "file://" + Path.build_filename(path, "system", file);
+ stdout.printf("Play: %s\n", p.uri);
p.set_state(Gst.State.PLAYING);
}
@@ -76,18 +83,19 @@ public class AudioPlayerImplementation {
return files[index];
}
- public string get_random_user_theme() {
- return get_random_file(path + "user/");
+ public string get_random_user_theme() throws IOError, DBusError {
+ return get_random_file(Path.build_filename(path, "user"));
}
- public string[] get_user_themes() {
- return get_files(path + "user/");
+ public string[] get_user_themes() throws IOError, DBusError {
+ return get_files(Path.build_filename(path, "user"));
}
- public void play_user(string theme, string type) {
+ public void play_user(string theme, string type) throws IOError, DBusError {
p.set_state(Gst.State.NULL);
- var file = get_random_file(path + "user/" + theme+ "/" + type);
- p.uri = "file://" + path + "user/" + theme+ "/" + type + "/" + file;
+ var file = get_random_file(Path.build_filename(path, "user", theme, type));
+ p.uri = "file://" + Path.build_filename(path, "user", theme, type, file);
+ stdout.printf("Play: %s\n", p.uri);
p.set_state(Gst.State.PLAYING);
}
}