summaryrefslogtreecommitdiffstats
path: root/src/audio/audio.vala
diff options
context:
space:
mode:
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);
}
}