×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    40

    Sample code to run audio file in symbian C++

    After looking thoroughly into previous posts I couldnt find any easy to do code for playing an audio file, can someone please give me some sample code for this.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: Sample code to run audio file in symbian C++


  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    40

    Re: Sample code to run audio file in symbian C++

    I have written the code according to that link , it compiles well, but unfortunately i dont hear the audio file being played in both the emulator and the E71 set.
    Can you please tell what wrong could have happened?

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: Sample code to run audio file in symbian C++

    Is ding.wav there in the SDK? For the device I would suggest writing e:\\ding.wav, then you can simply copy the file in the root of the memory card.

  5. #5
    Registered User
    Join Date
    Oct 2010
    Posts
    40

    Re: Sample code to run audio file in symbian C++

    Thanks for the reply it works,
    But moving forward I want the ding file to be packaged with the sis file , and be run from the private directory of the application ,

    I did something like this in the package file

    "$(EPOCROOT)epoc32\data\z\resource\apps\ding.wav" -"!:\private\0xEBC4A977\ding.wav"

    the ding.wav file exists in , C:\Symbian\9.2\S60_3rd_FP1\Epoc32\Data\z\resource\apps

    Now can you please tell me if this is the correct way of packaging the file and how will I be able to locate this file from code, will I be needing to go to the private path of application ?

    Regards
    Javed Ahmed

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: Sample code to run audio file in symbian C++

    Without the 0x:
    Code:
    ... -"!:\private\EBC4A977\ding.wav"
    and create the drive+path in runtime:
    Code:
    _LIT(KDing,"ding.wav");
    TFileName filename;
    CEikonEnv::Static()->FsSession().PrivatePath(filename); // puts \private\EBC4A977\ into the variable, overwriting any previous content
    filename.Insert(0,RProcess().FileName().Left(2)); // inserts x: at the beginning, where x is the drive where the .exe file is located (I assume that it was installed with !:\sys\bin too)
    filename.Append(KDing); // appends ding.wav at the end
    // and use it with the CMdaXy class

  7. #7
    Registered User
    Join Date
    Oct 2010
    Posts
    40

    Re: Sample code to run audio file in symbian C++

    Thanks for your reply , this code works fine with the skeleton project I was working with and I Correctly hear the file played,
    But when I port this code to my existing project , I get this error, in the ConstructL function where I am initializing the player,

    undefined reference to `CMdaAudioPlayerUtility::NewFilePlayerL(TDesC16 const&, MMdaAudioPlayerCallback&, int, TMdaPriorityPreference, CMdaServer*)'

    however I have the header file included ,
    #include <MdaAudioSamplePlayer.h>

    In carbide C++ project I also see the function definition in intellisense , but I dont know why the compiler is unable to get this function.
    Please help me in this,

  8. #8
    Registered User
    Join Date
    Oct 2010
    Posts
    40

    Re: Sample code to run audio file in symbian C++

    please ignore message # 7 ,I fixed it , I am running into another trouble now,

    Actually I need to play the wav file in a static member function of this class, will that be possible, I tried making the waveplayer a static member variable and putting the initialization inside NewLC instead of constructL but I get error at the initialization of iwaveplayer,
    exactly at this line,

    iWavePlayer = CMdaAudioPlayerUtility::NewFilePlayerL(filename,*this);

    Error, `this' is unavailable for static member functions

    I totally understand this is not the correct way of doing it,
    Can we have some code where I can start stop the player in some static function??

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: Sample code to run audio file in symbian C++

    I do not understand the point of that.

    Anyway, it is not the 'this' what is important, but a valid object implementing the MMdaAudioPlayerCallback interface. The callbacks are going to be invoked, so you can not avoid that (and how would you know when the player is ready, anyway?).
    Theoretically you can implement the interface in an other object, however the callbacks do not get any reference to the player object, so you would have to pass a reference of the player object, which is extremely close to moving the entire player thing into a separate object, and having that object as a static member, anywhere.
    But I still do not understand the static requirement. In a GUI application, you have a number of singleton objects already, the Application, the Document and the AppUi objects are existing all the time, so whatever you put into them behave as "static". Also for GUI stuff, you can use CCoeStatic class to implement explicit singleton objects.

    Your question might be more related to accessibility and usage. Perhaps you want to call the player from a timer or an active object. If this is the case, consider specifying the problem, and there will be a better solution than static members, I promise.

Similar Threads

  1. How to download sample code of book Quick Recipes on Symbian OS
    By dipeshtech in forum General Development Questions
    Replies: 10
    Last Post: 2011-08-22, 05:57
  2. sample code to browse photo's and select file name
    By ksadil in forum Mobile Java Media (Graphics & Sounds)
    Replies: 7
    Last Post: 2010-06-16, 19:31
  3. Help to run sample app included in S60 5th Ed SDK
    By AppTest in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2009-06-02, 07:27
  4. Replies: 1
    Last Post: 2006-02-23, 09:57
  5. Why does the sample WMLScript code of NMIT can not run?
    By yinqingshan in forum Browsing and Mark-ups
    Replies: 4
    Last Post: 2006-01-04, 22:06

Posting Permissions

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