×

Discussion Board

Results 1 to 6 of 6

Hybrid View

  1. #1
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    50

    playing a sound file

    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();

    iPlayerAdapter = CPlayerAdapter::NewL(KSoundFile, *this);
    iAudioAdapter = iPlayerAdapter;

    iAppContainer = new (ELeave) CGhawadiContainer;
    iAppContainer->SetMopParent(this);
    iAppContainer->ConstructL( ClientRect() );
    AddToStackL( iAppContainer );
    }
    GIVE PANIC!

    2- In DoActivateL() of the first view:
    void CCSM4View:oActivateL(
    const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
    const TDesC8& /*aCustomMessage*/)
    {
    if (!iContainer)
    {
    iContainer = new (ELeave) CCSM4Container;
    iContainer->SetMopParent(this);
    iContainer->ConstructL( ClientRect() );
    AppUi()->AddToStackL( *this, iContainer );
    }

    // Display wellcome message in a dialog
    if(IsStarted)
    {
    iPlayerAdapter->PlayL();
    iContainer->ShowMessageL(KWellcome, CAknQueryDialog::EConfirmationTone, ETrue);
    iContainer->ShowMessageL(KEnjoy, CAknQueryDialog::EConfirmationTone, EFalse);
    IsStarted=EFalse;
    }
    }
    GIVE PANIC TOO!

    3- In the container constructor:
    void CCSM4Container::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
    iPlayerAdapter->PlayL();
    //some code
    SetRect(aRect);
    ActivateL();
    }
    GIVE PANIC ALSO!

    where should I play the sound???

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166
    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.

    yucca

  3. #3
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    50
    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?

    regards,
    murmur

  4. #4
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    50
    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?

    Regards,
    murmur

  5. #5
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166
    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.

    yucca

  6. #6
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    50
    Thank you symbianyucca for your replay I called PlayL() from the audio player callback instead of the view and it worked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×