summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Rudolph <johannes.rudolph@gmx.com>2018-01-13 14:26:09 +0100
committerSebastian Reichel <sre@ring0.de>2018-06-28 01:52:53 +0200
commitfe7729489370800a1a24ad4a0b6adf7d95979daf (patch)
tree5ba9fe03715d570157fa174340eb52897f73fda2
parentb46dffb399fa7752c82b8186df3e6d5f22a5315e (diff)
downloadserial-barcode-scanner-fe7729489370800a1a24ad4a0b6adf7d95979daf.tar.bz2
scanner-session: add play_audio()
-rw-r--r--src/audio/audio-interface.vala8
-rw-r--r--src/scanner-session/scannersession.vala20
2 files changed, 28 insertions, 0 deletions
diff --git a/src/audio/audio-interface.vala b/src/audio/audio-interface.vala
index fe13af5..12bfae4 100644
--- a/src/audio/audio-interface.vala
+++ b/src/audio/audio-interface.vala
@@ -22,3 +22,11 @@ public interface AudioPlayer : Object {
public abstract string[] get_user_themes() throws IOError;
public abstract void play_user(string theme, string type) throws IOError;
}
+
+public enum AudioType {
+ ERROR,
+ LOGIN,
+ LOGOUT,
+ PURCHASE,
+ INFO
+}
diff --git a/src/scanner-session/scannersession.vala b/src/scanner-session/scannersession.vala
index 9638ef5..eeb02e3 100644
--- a/src/scanner-session/scannersession.vala
+++ b/src/scanner-session/scannersession.vala
@@ -78,6 +78,26 @@ public class ScannerSessionImplementation {
return true;
}
+ private void play_audio(AudioType audioType){
+ switch (audioType) {
+ case AudioType.ERROR:
+ audio.play_system("error.ogg");
+ break;
+ case AudioType.LOGIN:
+ audio.play_user(theme, "login");
+ break;
+ case AudioType.LOGOUT:
+ audio.play_user(theme, "logout");
+ break;
+ case AudioType.PURCHASE:
+ audio.play_user(theme, "purchase");
+ break;
+ case AudioType.INFO:
+ audio.play_user(theme, "login");
+ break;
+ }
+ }
+
private void handle_barcode(string scannerdata) {
try {
stdout.printf("scannerdata: %s\n", scannerdata);