File: ch06lev1sec5.html

package info (click to toggle)
ebook-dev-kde20 200010-3
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k, sarge
  • size: 11,428 kB
  • ctags: 2,726
  • sloc: sh: 96; makefile: 35
file content (169 lines) | stat: -rw-r--r-- 3,270 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>Playing Sounds</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.54"/><LINK
REL="HOME"
TITLE="KDE 2.0 Development"
HREF="index.html"/><LINK
REL="UP"
TITLE="KDE Style Reference"
HREF="ch06.html"/><LINK
REL="PREVIOUS"
TITLE="Internationalization"
HREF="ch06lev1sec4.html"/><LINK
REL="NEXT"
TITLE="User Notifications"
HREF="ch06lev1sec6.html"/><META
HTTP-EQUIV="Content-Style-Type"
CONTENT="text/css"/><LINK
REL="stylesheet"
HREF="kde-common.css"
TYPE="text/css"/><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=iso-8859-1"/><META
HTTP-EQUIV="Content-Language"
CONTENT="en"/><LINK
REL="stylesheet"
HREF="kde-localised.css"
TYPE="text/css"
TITLE="KDE-English"/><LINK
REL="stylesheet"
HREF="kde-default.css"
TYPE="text/css"
TITLE="KDE-Default"/></HEAD
><BODY
CLASS="section"
LINK="#336699"
VLINK="#336699"
ALINK="#336699"
BGCOLOR="#FFFFFF"
><DIV
ALIGN="RIGHT"
CLASS="NAVBAR"
><P
><A
HREF="ch06lev1sec4.html"
>Prev</A
> <A
HREF="ch06lev1sec6.html"
>Next</A
> <A
HREF="index.html"
>Table of Contents</A
></P
></DIV
><DIV
CLASS="section"
><TABLE
WIDTH="100%"
CELLPADDING="0"
CELLSPACING="0"
BORDER="0"
ALIGN="CENTER"
><TR
><TD
WIDTH="90%"
><H1
CLASS="section"
><A
NAME="ch06lev1sec5"
>6.5. Playing Sounds</A
></H1
><P
>There should rarely be a need for playing a sound. Sounds should be used only in games, and they should never be required for the use of your program unless, of course, your program's purpose is to play sound. Do not play sounds in the event of an error; that is the purpose of <TT
CLASS="literal"
>KNotify</TT
>, which will be discussed shortly.</P
><P
>Playing sound is a simple command:</P
><DIV
CLASS="informalexample"
><HR/><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>   1&nbsp;
   2&nbsp;KAudioPlayer::play("squish.wav");
   3&nbsp;</PRE
></TD
></TR
></TABLE
><HR/></DIV
><P
>You can also use this in a slot:</P
><DIV
CLASS="informalexample"
><HR/><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>   1&nbsp;
   2&nbsp;QButton *button = new QButton(this);
   3&nbsp;KAudioPlayer *player = new KAudioPlayer("foo.wav", button);
   4&nbsp;connect(button, SIGNAL(clicked()), player, SLOT(play()));
   5&nbsp;</PRE
></TD
></TR
></TABLE
><HR/></DIV
><P
>In this example, the file $KDEDIR/share/sounds/foo.wav is played whenever <TT
CLASS="literal"
>button</TT
> is clicked.</P
><P
>You can also send absolute filenames, in which case it will ignore the KDEDIR/share/sounds path.</P
><P
>This is not a superbly fast class, because it plays sounds via DCOP. For true real-time sound, you should use MCOP. For more information on multimedia, see <A
HREF="ch14.html"
>Chapter 14, <SPAN
CLASS="QUOTE"
>"Multimedia."</SPAN
></A
></P
></TD
><TD
WIDTH="10%"
VALIGN="BOTTOM"
ALIGN="CENTER"
><ANNMARK
NAME="ch06lev1sec5"/></TD
></TR
><ANNOTATION
NAME="ch06lev1sec5"
TITLE="Playing Sounds"/></TABLE
></DIV
><DIV
ALIGN="RIGHT"
CLASS="NAVBAR"
><P
><A
HREF="ch06lev1sec4.html"
>Prev</A
> <A
HREF="ch06lev1sec6.html"
>Next</A
> <A
HREF="index.html"
>Table of Contents</A
></P
></DIV
><HR
WIDTH="100%"
SIZE="2"
ALIGN="CENTER"
NOSHADE="NOSHADE"/></BODY
></HTML
>