From 2097d305cc55d12b8aa1ee0db6ed90f6f0ccc0ee Mon Sep 17 00:00:00 2001
From: victor <taehoon@falinux.com>
Date: Fri, 21 Apr 2017 13:21:53 +0900
Subject: [PATCH] =?UTF-8?q?=EC=86=8C=EB=A6=AC=20=EC=9E=AC=EC=83=9D=20?=
 =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/gui/oven_control/oven_control.pro |  9 +++++----
 app/gui/oven_control/soundplayer.cpp  | 21 +++++++++++++++++++++
 app/gui/oven_control/soundplayer.h    | 24 ++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 4 deletions(-)
 create mode 100644 app/gui/oven_control/soundplayer.cpp
 create mode 100644 app/gui/oven_control/soundplayer.h

diff --git a/app/gui/oven_control/oven_control.pro b/app/gui/oven_control/oven_control.pro
index 20dfbc5..3fb5ab5 100644
--- a/app/gui/oven_control/oven_control.pro
+++ b/app/gui/oven_control/oven_control.pro
@@ -4,8 +4,7 @@
 #
 #-------------------------------------------------
 
-QT       += core gui
-QT       += network
+QT       += core gui network multimedia
 
 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
@@ -61,7 +60,8 @@ SOURCES += main.cpp\
     realtimemain.cpp \
     realtimepartswindow.cpp \
     realtimesensorwindow.cpp \
-    bulletindicator.cpp
+    bulletindicator.cpp \
+    soundplayer.cpp
 
 HEADERS  += mainwindow.h \
     cook.h \
@@ -111,7 +111,8 @@ HEADERS  += mainwindow.h \
     realtimemain.h \
     realtimepartswindow.h \
     realtimesensorwindow.h \
-    bulletindicator.h
+    bulletindicator.h \
+    soundplayer.h
 
 FORMS    += mainwindow.ui \
     manualcookwindow.ui \
diff --git a/app/gui/oven_control/soundplayer.cpp b/app/gui/oven_control/soundplayer.cpp
new file mode 100644
index 0000000..12440d4
--- /dev/null
+++ b/app/gui/oven_control/soundplayer.cpp
@@ -0,0 +1,21 @@
+#include "soundplayer.h"
+
+QMap<QString, QSound *> SoundPlayer::map;
+QSound *SoundPlayer::current = 0;
+
+void SoundPlayer::play(const QString &filename)
+{
+    if (current && !current->isFinished())
+        current->stop();
+
+    if (map.contains(filename))
+        current = map.value(filename);
+    else
+    {
+        current = new QSound(filename);
+        map[filename] = current;
+    }
+
+    current->play();
+}
+
diff --git a/app/gui/oven_control/soundplayer.h b/app/gui/oven_control/soundplayer.h
new file mode 100644
index 0000000..611412f
--- /dev/null
+++ b/app/gui/oven_control/soundplayer.h
@@ -0,0 +1,24 @@
+#ifndef SOUNDPLAYER_H
+#define SOUNDPLAYER_H
+
+#include <QObject>
+#include <QSound>
+#include <QMap>
+
+class SoundPlayer : public QObject
+{
+    Q_OBJECT
+public:
+    static void play(const QString &filename);
+
+signals:
+
+public slots:
+
+private:
+    static QMap<QString, QSound *> map;
+    static QSound *current;
+
+};
+
+#endif // SOUNDPLAYER_H
-- 
2.1.4