×

Discussion Board

Results 1 to 6 of 6
  1. #1
    archerabi
    Guest

    AudioPlayerUtility beginner issue

    Hello,
    I am writing a simple media player and i've used the audioplayerutility classes as shown here
    http://wiki.forum.nokia.com/index.ph...ng_audio_files

    My main class is

    Code:
    _LIT(KFile,"C:/astand.wav");
    //  Global Variables
    
    LOCAL_D CConsoleBase* console; // write all messages to this
    
    
    //  Local Functions
    
    LOCAL_C void MainL()
    	{
    	//
    	// add your program code here, example code below
    	//
    	
    	CPlayerUtility *player;
    	player=  CPlayerUtility::NewL(KFile);
    	console->Write(_L("Hello, world!\n"));
    	
    	}
    The MapcInitComplete function isn't called at all.
    Any ideas?

    Abhi.

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

    Re: AudioPlayerUtility beginner issue

    CPlayerUtility *player; is local for the function, so you should actually make a class, that derives from CBase and from the interface required for the player, and have the player as a member variable for the class.

  3. #3
    archerabi
    Guest

    Re: AudioPlayerUtility beginner issue

    @symbianyucca
    i guess that's what i did ,didn't i?

    The playerutility class inherits from CBASE and the interface and has the CMdaAudioUtilityPLayer as its class variable.
    Also is the path to the file correct...is it C:/astand.wav or C:\astand.wav or C:\\astand.wav.

  4. #4
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,142

    Re: AudioPlayerUtility beginner issue

    you have CPlayerUtility *player; declared in a MainL() function, so it is not as you are now descriping it, either you have mis understood something, or your code
    sample with first post is incorrect.

  5. #5
    archerabi
    Guest

    Re: AudioPlayerUtility beginner issue

    Main.cpp

    Code:
    /*
     ============================================================================
     Name		: Mp3Player.cpp
     Author	  : 
     Copyright   : Your copyright notice
     Description : Exe source file
     ============================================================================
     */
    
    //  Include Files  
    
    #include "main.h"
    #include <e32base.h>
    #include <e32std.h>
    #include <e32cons.h>			// Console
    #include <mda\common\audio.h>
    #include <MdaAudioOutputStream.h>
    #include <Player.h>
    
    //  Constants
    
    _LIT(KTextConsoleTitle, "Console");
    _LIT(KTextFailed, " failed, leave code = %d");
    _LIT(KTextPressAnyKey, " [press any key]\n");
    _LIT(KWait, "Waiting in main\n");
    _LIT(KVolLevel,"Max Volume is %d\n");
    _LIT(KFile,"C:\\astand.wav");
    
    //  Global Variables
    
    LOCAL_D CConsoleBase* console; // write all messages to this
    
    
    //  Local Functions
    
    LOCAL_C void MainL()
    	{
    	
    	CPlayerUtility *player;
    	CSoundPlayer *player1;
    	TRAPD(err,player1=CSoundPlayer::NewL(_L("C:\\astand.wav")););
    		console->Write(_L("Hello, world!\n"));
    		console->Printf(KWait);
    
    	}
    
    LOCAL_C void DoStartL()
    	{
    	// Create active scheduler (to run active objects)
    	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
    	CleanupStack::PushL(scheduler);
    	CActiveScheduler::Install(scheduler);
    
    	MainL();
    
    	// Delete active scheduler
    	CleanupStack::PopAndDestroy(scheduler);
    	}
    
    //  Global Functions
    
    GLDEF_C TInt E32Main()
    	{
    	// Create cleanup stack
    	__UHEAP_MARK;
    	CTrapCleanup* cleanup = CTrapCleanup::New();
    
    	// Create output console
    	TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(
    			KConsFullScreen, KConsFullScreen)));
    	if (createError)
    		return createError;
    
    	// Run application code inside TRAP harness, wait keypress when terminated
    	TRAPD(mainError, DoStartL());
    	if (mainError)
    		console->Printf(KTextFailed, mainError);
    	console->Printf(KTextPressAnyKey);
    	console->Getch();
    
    	delete console;
    	delete cleanup;
    	__UHEAP_MARKEND;
    	return KErrNone;
    	}
    player.h
    Code:
    ifndef PLAYER_H
    #define PLAYER_H
    
    #include <e32std.h>
    #include <MdaAudioSamplePlayer.h>
     
    class CPlayerUtility : public CBase, public MMdaAudioPlayerCallback
        {
    public:
        static CPlayerUtility* NewL(const TDesC& aFileName);
        static CPlayerUtility* NewLC(const TDesC& aFileName);
        ~CPlayerUtility();
    private:
        CPlayerUtility();
        void ConstructL(const TDesC& aFileName);
    public:
        void Play();
        void Stop();
    public: // from MMdaAudioToneObserver
        void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration);
        void MapcPlayComplete(TInt aError);
    private:
        CMdaAudioPlayerUtility* iPlayUtility;
        TBool                    iPlaying,iPrepared;
    };
    Player.cpp

    Code:
    #include <MdaAudioTonePlayer.h>
    #include <eikmenup.h>
    #include "Player.h"
        
    CPlayerUtility* CPlayerUtility::NewL(const TDesC& aFileName)
    {
        CPlayerUtility* self = NewLC(aFileName);
        CleanupStack::Pop(self);  
        return self;
    }
     
    CPlayerUtility* CPlayerUtility::NewLC(const TDesC& aFileName)
    {
        CPlayerUtility* self = new (ELeave) CPlayerUtility();
        CleanupStack::PushL(self);
        self->ConstructL(aFileName);
        return self;
    }
     
    CPlayerUtility::~CPlayerUtility()
    {
    	if(iPlayUtility)
    	{
    		iPlayUtility->Stop();
    		iPlayUtility->Close();
    	}
    	
        delete iPlayUtility;
    }
     
    CPlayerUtility::CPlayerUtility()
    {
    }
     
    void CPlayerUtility::ConstructL(const TDesC& aFileName)
    {
        iPlayUtility = CMdaAudioPlayerUtility::NewFilePlayerL(aFileName, *this);
    	iPlaying = iPrepared = EFalse;
    }
      
    void CPlayerUtility::Play()
    {
    	iPlayUtility->Play();
    	iPlaying = ETrue;
    }
     
    void CPlayerUtility::Stop()
    {
    	iPlayUtility->Stop();
    	iPlaying = EFalse;
    }
     
     
    void CPlayerUtility::MapcPlayComplete(TInt /*aError*/)
    {
    	iPlaying = EFalse;
    }
     
    void CPlayerUtility::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration)	
    {
    	if(aError == KErrNone)
    	{
    		iPrepared = ETrue;
    		iPlayUtility->SetVolume(iPlayUtility->MaxVolume());		
    	}
    }

  6. #6
    archerabi
    Guest

    Thumbs up Re: AudioPlayerUtility beginner issue

    When i played in console it didn't work but when i played it in a GUI app it worked!

Similar Threads

  1. OVI Publishing Issue - POINT OF CONTACT
    By Vignesh.M in forum [Closed] Publishing to Nokia Store
    Replies: 4
    Last Post: 2009-08-18, 14:35
  2. Issue with CAknTabGroup in 3.0 devices
    By nagneeth in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-05-18, 13:01
  3. issue with at+cusd over bluetooth link
    By hbanks in forum General Messaging
    Replies: 2
    Last Post: 2007-09-25, 21:21
  4. RTSP video streaming issue on 6280
    By olivier_irac in forum General Development Questions
    Replies: 0
    Last Post: 2006-12-04, 15:11
  5. Nokia 9500: browsing issue ? cache issuse ?
    By coberle in forum Mobile Web Site Development
    Replies: 0
    Last Post: 2005-10-12, 16:31

Posting Permissions

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