summaryrefslogtreecommitdiffstats
path: root/qtjava/javalib/examples/sound
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /qtjava/javalib/examples/sound
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtjava/javalib/examples/sound')
-rw-r--r--qtjava/javalib/examples/sound/SoundPlayer.java116
-rw-r--r--qtjava/javalib/examples/sound/sounds/1.wavbin0 -> 8624 bytes
-rw-r--r--qtjava/javalib/examples/sound/sounds/2.wavbin0 -> 7266 bytes
-rw-r--r--qtjava/javalib/examples/sound/sounds/3.wavbin0 -> 4709 bytes
-rw-r--r--qtjava/javalib/examples/sound/sounds/4.wavbin0 -> 5538 bytes
5 files changed, 116 insertions, 0 deletions
diff --git a/qtjava/javalib/examples/sound/SoundPlayer.java b/qtjava/javalib/examples/sound/SoundPlayer.java
new file mode 100644
index 00000000..ad6cf7a7
--- /dev/null
+++ b/qtjava/javalib/examples/sound/SoundPlayer.java
@@ -0,0 +1,116 @@
+/***************************************************************************
+* $Id$
+**
+* Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
+**
+* This file is part of an example program for Qt. This example
+* program may be used, distributed and modified without limitation.
+**
+****************************************************************************/
+
+import org.kde.qt.*;
+
+
+class SoundPlayer extends QMainWindow {
+
+private QSound bucket3;
+private QSound bucket4;
+
+//
+// Very simple example of QSound.play(filename)
+//
+// 99% of this program is just boilerplate Qt code to put up a nice
+// window so you think something special is happening.
+//
+
+
+SoundPlayer()
+{
+ super();
+ bucket3 = new QSound("sounds/3.wav");
+ bucket4 = new QSound("sounds/4.wav");
+
+ if (!QSound.isAvailable()) {
+ // Bail out. Programs in which sound is not critical
+ // could just silently (hehe) ignore the lack of a server.
+ //
+ QMessageBox.warning(this,"No Sound",
+ "<p><b>Sorry, you are not running the Network Audio System.</b>"
+ + "<p>If you have the `au' command, run it in the background before this program. "
+ + "The latest release of the Network Audio System can be obtained from:"
+ + "<pre>\n"
+ + " &nbsp;\n"
+ + " ftp.ncd.com:/pub/ncd/technology/src/nas\n"
+ + " ftp.x.org:/contrib/audio/nas\n"
+ + "</pre>"
+ + "<p>Release 1.2 of NAS is also included with the X11R6"
+ + "contrib distribution."
+ + "<p>After installing NAS, you will then need to reconfigure Qt with NAS sound support");
+ }
+
+ QPopupMenu file = new QPopupMenu(this);
+ file.insertItem("Play &1", this, SLOT("doPlay1()"), new QKeySequence(CTRL+Key_1));
+ file.insertItem("Play &2", this, SLOT("doPlay2()"), new QKeySequence(CTRL+Key_2));
+ file.insertItem("Play from bucket &3", this, SLOT("doPlay3()"), new QKeySequence(CTRL+Key_3));
+ file.insertItem("Play from bucket &4", this, SLOT("doPlay4()"), new QKeySequence(CTRL+Key_4));
+ file.insertSeparator();
+ file.insertItem("Play 3 and 4 together", this, SLOT("doPlay34()"));
+ file.insertItem("Play all together", this, SLOT("doPlay1234()"));
+ file.insertSeparator();
+ file.insertItem("E&xit", qApp(), SLOT("quit()"));
+ menuBar().insertItem("&File", file);
+}
+
+void doPlay1()
+{
+ QSound.play("sounds/1.wav");
+}
+
+void doPlay2()
+{
+ QSound.play("sounds/2.wav");
+}
+
+void doPlay3()
+{
+ bucket3.play();
+}
+
+void doPlay4()
+{
+ bucket4.play();
+}
+
+void doPlay34()
+{
+ // Some sound platforms will only play one sound at a time
+ bucket3.play();
+ bucket4.play();
+}
+
+void doPlay1234()
+{
+ // Some sound platforms will only play one sound at a time
+ QSound.play("sounds/1.wav");
+ QSound.play("sounds/2.wav");
+ bucket3.play();
+ bucket4.play();
+}
+
+public static void main(String[] args)
+{
+ QApplication app = new QApplication(args);
+ SoundPlayer sp = new SoundPlayer();
+ app.setMainWidget(sp);
+ sp.setCaption("Qt Example - Sounds");
+ sp.show();
+ app.exec();
+ return;
+}
+
+ static {
+ qtjava.initialize();
+ }
+
+}
+
diff --git a/qtjava/javalib/examples/sound/sounds/1.wav b/qtjava/javalib/examples/sound/sounds/1.wav
new file mode 100644
index 00000000..30b84e30
--- /dev/null
+++ b/qtjava/javalib/examples/sound/sounds/1.wav
Binary files differ
diff --git a/qtjava/javalib/examples/sound/sounds/2.wav b/qtjava/javalib/examples/sound/sounds/2.wav
new file mode 100644
index 00000000..dd32e345
--- /dev/null
+++ b/qtjava/javalib/examples/sound/sounds/2.wav
Binary files differ
diff --git a/qtjava/javalib/examples/sound/sounds/3.wav b/qtjava/javalib/examples/sound/sounds/3.wav
new file mode 100644
index 00000000..5213eb55
--- /dev/null
+++ b/qtjava/javalib/examples/sound/sounds/3.wav
Binary files differ
diff --git a/qtjava/javalib/examples/sound/sounds/4.wav b/qtjava/javalib/examples/sound/sounds/4.wav
new file mode 100644
index 00000000..e31b0609
--- /dev/null
+++ b/qtjava/javalib/examples/sound/sounds/4.wav
Binary files differ