ArticleDirectory
Use of the coesoundplayer class for sound prompts
This class is declared in the coesndpy. h header file, the Library is cone. Lib, the simplest use is the following formatCodeApplication
Tbasystemsoundtype A (ksystemsoundmessageuid );
Coesoundplayer: playsoundnow ();
When using the above Code, the first line declares the tone type of the system. This type is declared in the bassnd. h file, and the bafl. Lib library file is added to the MMP file. Generally, this simple application can hear sound on the simulator (3rd Mr can not hear sound), but basically cannot hear sound on the real machine, one reason is that the default volume is set to ksystemsounddefavolvolume, and its value can be up to 100 (the result of my test is a minimum of 0, no sound, and a maximum of 10, mmfaudioclient 4 is reported when the value is greater than 10,ProgramCrash. So we recommend that you give some advice on this ). In addition, the types defined in bassnd. h include ksystemsoundringuid, ksystemsoundalarmuid, kuidsystemsounderror, and kuidsystemsoundevent. You can test the specific effects by yourself.
The slightly more complex application code is as follows:
Tbasystemsoundtype soundtype (ksystemsoundmessageuid );
// Tbasystemsoundinfo: ttone soundtone (afrequency, aduration );
Tbasystemsoundinfo: ttone soundtone (1500, 3*1000*1000 );
Tbasystemsoundinfo soundinfo (soundtype, soundtone );
Basystemsound: setsoundl (ccoeenv: static ()-> fssession (), soundinfo );
Coesoundplayer: playsoundnow (soundtype );
Here, I am not very familiar with the tone, but the afrequency value has been tested to work properly from 100 to 3400 (probably the best from 1000 to 3000 ), from 3600 to 3800, it became weak, and it was basically impossible to get up to 4000. This method can still be felt on a real machine. It is not like the first case, but it only works on the simulator.
The simple tone Estimation for long-time playback is harsh, so we can play the single-tone ringtone through the RNG file designed in advance. The specific code is as follows:
_ Resolve (kringtonefilename1, "\ data \ Sounds \ simple \ alarm. RNG ");
Const tint kringingtypesilent = 4; // silent
Tint tringingtype (0 );
Crepository * trepository = crepository: newlc (kcruidprofileengine );
User: leaveiferror (trepository-> get (kproengactiveringtype, tringingtype ));
If (tringingtype! = Kringingtypesilent)
{
Tbasystemsoundtype soundtype (ksystemsoundringuid );
Tbasystemsoundname soundname (kringtonefilename1 );
Completewithapppath (soundname );
Tbasystemsoundinfo soundinfo (soundtype, soundname, 10,
Ksystemsounddefapripriority );
Basystemsound: setsoundl (ccoeenv: static ()-> fssession (), soundinfo );
Coesoundplayer: playsoundnow (soundtype );
// Coesoundplayer: playsound (soundtype );
}
Cleanupstack: popanddestroy (); // trepository
When using the above Code, you must note alarm. the RNG file must be available; otherwise, no sound is reported. This file is not available in the path of the fp2 simulator, you can find it in s60_3rd_mr \ epoc32 \ release \ winscw \ udeb \ Z \ System \ Sounds \ simple, copy it to the corresponding epoc32 \ release \ winscw \ udeb \ Z \ System \ Sounds \ simple.
Note: In addition, although you have determined whether the scene mode is set to mute, you can still play out the audio because the scene mode is set to mute. This is very different from vibration.
Vibration Control API
Device, software version:
S60 2nd edition, Nokia 6600, versions 3.42.1 and 4.09.1, and Nokia 7610, version 4.0421.4
Note:
S60 2nd edition, s60 2nd Edition FP1, that is, Symbian OS v7.x does not provide the vibration interface; s60 2nd Edition fp2, s60 2nd Edition fp3, that is, Symbian OS v8.x uses the cvibracontrol class to provide the vibration interface; s60 3rd edition, namely, Symbian OS v9.x, uses the new chwrmvibra class to provide the vibration interface.
Detailed Description: The cvibracontrol API has been described in s60 SDK 2.0 and can be used by developers. However, it is not supported in nokia6600. The second version of s60, fp2 and fp3 devices already include vibractrl. dll and vibration functions. S60 provides a new vibra client API (chwrmvibra) in the third edition)
Example // For s60 3rd # include
Void dovibratel (tint aduration)
{
Chwrmvibra * vibra = chwrmvibra: newlc ();
If (chwrmvibra: evibramodeon = vibra-> vibrasettings () // get vibration setting in the user profile
{
Vibra-> startvibral (aduration );
}
Cleanupstack: popanddestroy (vibra );
}
// For s60 2nd fp2 and fp3 # include <vibractrl. h> // cvibracontrol, vibractrl. Lib
Void dovibratel (tuint16 aduration)
{
Cvibracontrol * control = vibrafactory: newl ();
If (cvibracontrol: evibramodeon = control-> vibrasettings () // get vibration setting in the user profile
{
Control-> startvibra (aduration );
}
Delete control;
Control = NULL;
}
Example:
# Include