Before you begin
Your system requires the following components to be installed or available:
- The BlackBerry 10 Native SDK
- Your BlackBerry 10 device or BlackBerry 10 Dev Alpha Simulator
If you haven't already, review the BlackBerry 10 Native SDK getting started information to learn how to set up your environment and configure your device or simulator for development.
Create your own project or load the PlayWav sample app
You can either create your own application or load the PlayWav sample app.
If you want to create your own application, note which type of build you are using (that is, the makefile build or the managed build). For more information about creating your own application, see Create a project.
If you want to load the PlayWav sample application:
- You can load the sample app from GitHub by downloading the BlackBerry 10 Native SDK sample apps repository.
- In the QNX Momentics IDE, on the File menu, click Import.
- Browse to the location where you saved the repository. Then double-click on the folder PlayWav folder.
- Click Finish.
Note that importing in this manner is a makefile build.
PlayWav library requirements
In your application, you will need to use the preprocessor directive #include to include the following header files.
#include <errno.h> #include <fcntl.h> #include <gulliver.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <sys/select.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <sys/slogcodes.h> #include <ctype.h> #include <limits.h> #include <screen/screen.h> #include <sys/asoundlib.h> #include <bps/bps.h> #include <bps/audiomixer.h> #include <bps/audiodevice.h> #include <bps/dialog.h> #include <bps/navigator.h> #include "dialogutil.h"
Configure your linker settings for the libraries
You must configure the linker to include the non-standard libraries your project requires.
If you have a managed build, complete the following steps:
- In the Project Explorer view, right-click your project. Click Properties.
- In the navigation pane, click C/C++ Build > Settings.
- On the Tool Settings tab, click QCC Linker > Libraries.
- In the Libraries
section, verify the following entries and add any that are missing:
- bps
- screen
- asound
If you have a makefile build, complete the following steps:
- In the Project Explorer, under your application double-click the common.mk file.
- Add the following beside LIBS+=
- bps
- screen
- asound
- On the File menu, click Save.
Allow audio in your application
To allow audio capabilities in your application, you must set application permissions. To set this permission, complete the following steps in the QNX Momentics IDE:
- In the Project Explorer view, double click your project's bar-descriptor.xml file.
- On the Application tab, select the Play Sounds check box.
Specify a .wav file as an asset
You must add the .wav file to the project assets using bar-descriptor.xml.
- In the Project Explorer view, double-click your project's bar-descriptor.xml file.
- On the Assets tab, click Add Files...
- Locate a .wav file using either File System... or Workspace...
- Click OK. Click Save button.
Location of the audio file
Our application requires that the audio file is located in the /app/native folder relative to where the application is installed. In this sample application, the name of the audio file is sample.wav.