
| July 2003 Playing and Recording Sounds on the P800 |
|
|
There are two ways to do sound playback. The easiest and most versatile method is to use the CQikSoundPlayer class. Simply add the following lines of code to your application. _LIT( soundfilename, "javascript:void(null);" ); CQikSoundPlayer *player; player = CQikSoundPlayer::NewL( *iEikonEnv ); player->StartPlayL( soundfilename ); You can also register an observer with this player class to get notified when the system has finished playing your sound. Another way that is a bit more complicated is to use a CMdaAudioPlayerUtility. When instantiating an object of this class, you need to pass an observer implementing the MMdaAudioPlayerCallback interface. After you have created an instance of CMdaAudioPlayerUtility, you have to wait for the system to call MMdaAudioPlayerCallback::MapcInitComplete() before you can begin playback. When playback is complete, the system will call MMdaAudioPlayerCallback::MapcPlayComplete(). To record sounds, you can use the CMdaAudioRecorderUtility. This class works in a similar way as the CMdaAudioPlayerUtility. The difference is in the callback interface where there is only one method to implement, which will receive events about the recording. The second obstacle is to initialize the recording format structures correctly. The P800 only supports recording to WAV format in 8kHz. Below is a code snippet showing how to initiate a recording of the CMdaAudioRecorderUtility. _LIT( fname, "javascript:void(null);" ); After this, the observer will be called when the initialization is complete, upon receiving the event, you can start the recording as shown below. recorder->SetGain( recorder->MaxGain() ); | |
Copyright © 2001 - 2009 Sony Ericsson Mobile Communications AB. All Rights Reserved.