Playing system sounds

A static play() function is provided in the SystemSound class to asynchronously play any system-defined sound file.

The architectural flow diagram for SystemSound is shown in the image to the right.

The flow for SystemSound is straightforward. You need to set a system sound to play, then play it one or more times.

Flow diagram for SystemSound

Here's a code sample that shows you how to use the play() function to play a camera shutter sound.

import bb.cascades 1.2
import bb.multimedia 1.2

Page {
    Container {
        // ...
        attachedObjects: [
            SystemSound {
                id: sysSound
                sound: SystemSound.CameraShutterEvent
        Button {
            text: "Play System Sound"
            onClicked: {
// Code sample showing the single line of code
// needed to asynchronously play a system sound


You can use the play() function to play a sound, either one time or many times in rapid succession. As you can see in the following C++ code sample, a SystemSound object called keypress is used to play a system sound (SystemSound::InputKeypress) two times in rapid succession by repeatedly calling the function in a for loop.

// SystemSound object created and used from C++.
// In this C++ code sample, the InputKeypress system
// sound is played two times

// Define the system sound that you want to play
SystemSound keypress(SystemSound::InputKeypress);

// Play the sound as desired by calling the
// method repeatedly
for(int i=0; i<2; i++) {;

Not applicable

Last modified: 2015-05-07

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus