×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Background music loop for game

    Hello Folks,
    I have already tried to google this quite a bit, but have failed.

    I am currently working on a game for Symbian OS, and would love to use an MP3 file as background music loop. Is it possible to play an MP3 file in a loop on Symbian - or rather, how do I do it?

    With big thanks in advance for answers!
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,144

    Re: Background music loop for game

    just check the audio player examples from wiki, and when you get the event that the playing has stopped, just re-start it.

  3. #3
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: Background music loop for game

    Hi yucca,
    I just stumbles across this:
    http://wiki.forum.nokia.com/index.ph...ng_audio_files

    The question is: how can I make this play two sounds in paralell?

    All the best
    Tam Hanna
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  4. #4
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: Background music loop for game

    Hi,
    something else. I have now added the files to my Qt project (and also found the timer) - and now run into compile errors on the C level (no linker errors):
    Code:
    \S60\devices\S60_5th_Edition_SDK_v1.0\EPOC32\BUILD\Symbian\Carbide\workspace\QtBallZ\QTBALLZ_0X2002CAC7\GCCE\udeb\AudioPlayer.o: In function `CAudioPlayer::PlayL(TDesC16 const&)':
    /Symbian/Carbide/workspace/QtBallZ/s60sound/audioplayer.cpp:87: undefined reference to `CMdaAudioRecorderUtility::NewL(MMdaObjectStateChangeObserver&, CMdaServer*, int, TMdaPriorityPreference)'
    \S60\devices\S60_5th_Edition_SDK_v1.0\EPOC32\BUILD\Symbian\Carbide\workspace\QtBallZ\QTBALLZ_0X2002CAC7\GCCE\udeb\PlayUtility.o: In function `~CPlayerUtility':
    /Symbian/Carbide/workspace/QtBallZ/s60sound/playutility.cpp:33: undefined reference to `CMdaAudioPlayerUtility::Close()'
    /Symbian/Carbide/workspace/QtBallZ/s60sound/playutility.cpp:33: undefined reference to `CMdaAudioPlayerUtility::Close()'
    /Symbian/Carbide/workspace/QtBallZ/s60sound/playutility.cpp:33: undefined reference to `CMdaAudioPlayerUtility::Close()'
    \S60\devices\S60_5th_Edition_SDK_v1.0\EPOC32\BUILD\Symbian\Carbide\workspace\QtBallZ\QTBALLZ_0X2002CAC7\GCCE\udeb\PlayUtility.o: In function `CPlayerUtility::ConstructL(TDesC16 const&)':
    /Symbian/Carbide/workspace/QtBallZ/s60sound/playutility.cpp:45: undefined reference to `CMdaAudioPlayerUtility::NewFilePlayerL(TDesC16 const&, MMdaAudioPlayerCallback&, int, TMdaPriorityPreference, CMdaServer*)'
    make[1]: *** [\S60\devices\S60_5th_Edition_SDK_v1.0\epoc32\release\gcce\udeb\QtBallZ.exe] Error 1
    make: *** [TARGETQTBALLZ_0X2002CAC7] Error 2
    The strange thing is that all the methods look ok. Any idea what is going on here?

    (For example, I have a method like)
    IMPORT_C static CMdaAudioRecorderUtility* NewL(
    MMdaObjectStateChangeObserver& aObserver,
    CMdaServer* aServer = NULL,
    TInt aPriority = EMdaPriorityNormal,
    TMdaPriorityPreference aPref = EMdaPriorityPreferenceTimeAndQuality);

    I call it like this:
    iPlayerUtility = CMdaAudioRecorderUtility::NewL(*this);

    and it whines
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  5. #5
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: Background music loop for game

    And here is the error for AudioPlayer.cpp:
    Code:
    \S60\devices\S60_5th_Edition_SDK_v1.0\EPOC32\BUILD\Symbian\Carbide\workspace\QtBallZ\QTBALLZ_0X2002CAC7\GCCE\udeb\AudioPlayer.o: In function `CAudioPlayer::PlayL(TDesC16 const&)':
    /Symbian/Carbide/workspace/QtBallZ/s60sound/audioplayer.cpp:87: undefined reference to `CMdaAudioRecorderUtility::NewL(MMdaObjectStateChangeObserver&, CMdaServer*, int, TMdaPriorityPreference)'
    make[1]: *** [\S60\devices\S60_5th_Edition_SDK_v1.0\epoc32\release\gcce\udeb\QtBallZ.exe] Error 1
    make: *** [TARGETQTBALLZ_0X2002CAC7] Error 2
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  6. #6
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: Background music loop for game

    Hi,
    got it fixed. To get it building with Qt, the header must look like this:

    Code:
    /*
     * AudioPlayer.h
     *
     *  Created on: 02.02.2010
     *      Author: TAMHAN
     */
    
    #ifndef AUDIOPLAYER_H_
    #define AUDIOPLAYER_H_
    
    #include <MdaAudioSamplePlayer.h>
    #include <MdaAudioSampleEditor.h>
    #include <Mda\Client\Utility.h>
    #include "CExampleTimer.h"
     
    const TInt	KReFreshTimeOut = 1000000; // re-fresh every second
    //
    class MExamplePlayStateObserver
    	{
    	public:
    		virtual void StateUpdate(CMdaAudioClipUtility::TState aState, TInt aPosition, TInt aDuration)=0;
    	};
     
     
    class CAudioPlayer : MMdaObjectStateChangeObserver, CBase, MExampleTimerNotify 
        {
    public:
        static CAudioPlayer* NewL(MExamplePlayStateObserver& aObserver);
        static CAudioPlayer* NewLC(MExamplePlayStateObserver& aObserver);
         ~CAudioPlayer();
    public:  // public functions 
        void PlayL(const TDesC& aFileName);
    	void StopL(void);
    	void SetVolume(TInt& aVolume);
    protected: // from MMdaObjectStateChangeObserver & MExampleTimerNotify
    	void MoscoStateChangeEvent(CBase* aObject, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode);
    	void TimerExpired(TAny* aTimer,TInt aError);
    private:// interna functions
    	void ReportStateAndTime(void);
        void ConstructL();
        CAudioPlayer(MExamplePlayStateObserver& aObserver);	
    private:
    	MExamplePlayStateObserver&		iObserver;
    	CMdaAudioRecorderUtility* 		iPlayerUtility;
        TInt 							iVolume;
        TMdaFileClipLocation 			iCurrentFile;
        CExampleTimer*					iExampleTimer;
    };
    
    #endif /* AUDIOPLAYER_H_ */
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

Similar Threads

  1. Running music Player in Background
    By gailu in forum Symbian
    Replies: 2
    Last Post: 2009-01-19, 11:49
  2. background music during call
    By pankaj gupta55 in forum Symbian
    Replies: 3
    Last Post: 2008-08-27, 12:13
  3. Nokia N91, how to close the music application in the background?
    By goodluck_975 in forum General Development Questions
    Replies: 3
    Last Post: 2007-03-08, 14:48
  4. RunL() method is not being called
    By dotcdotc in forum Symbian
    Replies: 9
    Last Post: 2004-12-13, 11:25

Posting Permissions

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