I need to play a sound file automaticly when my application starts, when I put 'iAudioAdapter->PlayL();' in the constructor it gives a CMdaAudioPlayerU 1 panic when the appliction starts. Where sould I call playL()?
Here is what I did:
1- I tryed in the appliction UI constructor:
void CGhawadiAppUi::ConstructL()
{
BaseConstructL();
you basically need to check that the file was opened without errors before playing it. So safest place would be to play it in the callback function, or have boolean variable indicating (that is set in call back) if the player is ready to play,, so you could play it on other places as well.
I checked that the file is working correctlly, if I put the same iPlayerAdapter->PlayL() to be played when selecting an option it worked and the sound is being played. Where can I call PlayL() to be run automaically when the application starts? Can you give me any idea with sample code?
This is what I did in the view doactivate function I wrote:
// Display wellcome message in a dialog
if(IsStarted)
{
iContainer->ShowMessageL(KWellcome, CAknQueryDialog::EConfirmationTone, ETrue);
iPlayerAdapter->PlayL();
iContainer->ShowMessageL(KEnjoy, CAknQueryDialog::EConfirmationTone, EFalse);
IsStarted=EFalse;
}
The sound file was playing correctly but I want it to be played before the first message, if I put iplayerAdapter->PlayL() before the messge it panics. Any suggesstion?
I'm a bit sure it is race condition. So you need really to have some sort of identification process, where you know to play the sound only after it is succesfully opened. One way would be to put the view activation code to the call back of the audio player.