×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    10

    Audio file play from Rom when file copy is taking place

    Is it posible to do an application that does Audio file play from Rom when File copy between two folders in ram
    is taking place.I want to do a console application.is it feasible.
    Do reply It is ver urgent thanks in advance

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

    Re: Audio file play from Rom when file copy is taking place

    I wouldn't see any problem with that, though, it would be easiest to test it out by adding the functionality to SDK helloworld example.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    21

    Re: Audio file play from Rom when file copy is taking place

    Hi,

    You can try in the following way.On running this application, you need to press command1, then command2, then command3 and command4 if you want to stop the audio

    In the ...AppUi.cpp file,

    _LIT( KSrcFile, "C:\\Data\\Documents\\Log.txt");
    _LIT( KDestFile, "C:\\Data\\Documents\\vamsi.txt");

    void CAudioPlay_FileCopy_guiAppUi::HandleCommandL( TInt aCommand )
    {
    switch( aCommand )
    {
    case EEikCmdExit:
    case EAknSoftkeyExit:
    Exit();
    break;

    case ECommand1:
    {
    TBuf<100> buf;
    buf.Copy(
    _L("Z:\\Data\\Sounds\\Digital\\Afternoon.aac"));

    audio = CAudio::NewL( buf );
    audio->SetRepeat( KMdaRepeatForever );
    }
    break;
    case ECommand2:
    {
    audio->Play();
    }
    break;
    case ECommand3:
    {
    FileCopy();
    }
    break;
    case ECommand4:
    {
    audio->Stop();
    }
    break;
    default:
    Panic( EAudioPlay_FileCopy_guiUi );
    break;
    }

    void CAudioPlay_FileCopy_guiAppUi::FileCopy()
    {
    HBufC8* FilBuff(NULL);

    TBuf<100> readFile(KSrcFile);


    RFile ReadFil;
    if(KErrNone == ReadFil.Open(
    CCoeEnv::Static()->
    FsSession(),
    readFile,
    EFileRead) )
    {
    CleanupClosePushL(ReadFil);

    TInt FilSiz(0);
    if(ReadFil.Size(FilSiz) == KErrNone)
    {
    if(FilSiz > 0)
    {
    FilBuff = HBufC8::NewL(FilSiz);
    TPtr8 ReadPoint(FilBuff->Des());

    ReadFil.Read(ReadPoint,FilSiz);
    }
    }

    CleanupStack::PopAndDestroy(1);//ReadFile
    }

    WriteToFileL( FilBuff->Des() );
    }

    void CAudioPlay_FileCopy_guiAppUi::WriteToFileL(const TDesC8& aData)
    {
    TBuf<100> writeFile(KDestFile);

    RFile WriteFil;

    if(BaflUtils::FileExists(
    CCoeEnv::Static()->FsSession(),
    writeFile)
    )
    User::LeaveIfError(
    WriteFil.Open(
    CCoeEnv::Static()->FsSession()
    ,writeFile
    ,EFileWrite)
    );
    else
    User::LeaveIfError(
    WriteFil.Create(
    CCoeEnv::Static()->FsSession()
    ,writeFile
    ,EFileWrite)
    );

    CleanupClosePushL(WriteFil);

    User::LeaveIfError(WriteFil.Write(aData));

    CleanupStack::PopAndDestroy(1);//ReadFile

    }

    Create a CAudio.h and CAudio.cpp file to play the audio fom ROM

    #ifndef CAUDIO_H_
    #define CAUDIO_H_

    #include <coeccntx.h>
    #include <eikenv.h>
    #include <eikappui.h>
    #include <eikapp.h>
    #include <eikdoc.h>
    #include <eikmenup.h>
    #include <eikon.hrh>
    #include <e32base.h>
    #include <coecntrl.h>
    #include <MdaAudioSamplePlayer.h>
    #include <MdaAudioTonePlayer.h>

    #include <mmfPluginInterfaceUIDs.hrh>

    // Include for KMdaRepeatForever
    #include <Mda\Common\Resource.h>

    //Forward Declarations
    class CMdaAudioToneUtility ;
    class MMdaAudioPlayerCallback;
    class CMdaAudioPlayerUtility;

    enum TState
    {
    ENotReady,
    EReadyToPlay,
    EPlaying
    };

    class TTone
    {
    public:
    TInt pitch;
    TInt duration;
    };


    class CAudio : public CBase, public MMdaAudioPlayerCallback
    {
    public:
    TState iState;
    static CAudio* NewL(const TDesC& aFileName);
    virtual ~CAudio();

    void Play();
    void Stop();

    void SetRepeat(
    const TInt aRepeatNumberOfTimes =
    KMdaRepeatForever,
    const TTimeIntervalMicroSeconds
    aTrailingSilence = 0
    );

    private:
    CAudio();
    void ConstructL(const TDesC& aFileName);

    void MapcInitComplete(TInt aError,
    const TTimeIntervalMicroSeconds &aDuration);
    void MapcPlayComplete(TInt aError);

    private:
    CMdaAudioPlayerUtility* iMdaAudioPlayerUtility;
    RArray<TTone> iTones;
    TInt iIndex;

    TBool iStartTimer;

    TBool iRepeatAudio;

    };

    #endif /*CAUDIO_H_*/


    // INCLUDE FILES
    #include <eikstart.h>
    #include "CAudio.h"

    CAudio* CAudio::NewL(const TDesC& aFileName)
    {
    CAudio* self=new(ELeave) CAudio();
    CleanupStack::PushL(self);
    self->ConstructL(aFileName);
    CleanupStack::Pop(self);
    return self;
    }

    CAudio::CAudio() : iIndex(ENotReady)
    {
    iMdaAudioPlayerUtility = NULL;
    iStartTimer = EFalse;
    iRepeatAudio = EFalse;
    }

    void CAudio::ConstructL(const TDesC& aFileName)
    {
    if( iState != EReadyToPlay )
    {
    Stop();
    }

    if( iMdaAudioPlayerUtility == NULL )
    {
    iMdaAudioPlayerUtility = CMdaAudioPlayerUtility::NewL(*this, EMdaPriorityMax );
    iMdaAudioPlayerUtility->OpenFileL(aFileName);
    }
    }

    CAudio::~CAudio()
    {
    if( iMdaAudioPlayerUtility != NULL )
    {
    iMdaAudioPlayerUtility->Close();
    delete iMdaAudioPlayerUtility;
    }
    }

    void Audio::MapcInitComplete(TInt aError,const TTimeIntervalMicroSeconds & /*aDuration*/ )
    {
    iState = aError ? ENotReady : EReadyToPlay;
    }

    void CAudio::MapcPlayComplete(TInt aError)
    {
    iState = aError ? ENotReady : EReadyToPlay;
    }

    void CAudio::Play()
    {
    if(iMdaAudioPlayerUtility)
    {
    iMdaAudioPlayerUtility->Play();
    iState=EPlaying;
    }
    }

    void CAudio::Stop()
    {
    if(iMdaAudioPlayerUtility)
    {
    iMdaAudioPlayerUtility->Stop();
    iMdaAudioPlayerUtility->Close();
    iState=ENotReady;
    }
    }


    /**
    * Function : SetRepeat
    * Description : Sets how many times the repeatition of file has to
    * take place followed by the trailing silence
    *
    * Note : By default, the repeat is forever, so we should be careful
    * while using this API
    *
    */
    void CAudio::SetRepeat(const TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds aTrailingSilence )
    {
    if( iMdaAudioPlayerUtility != NULL )
    {
    iMdaAudioPlayerUtility->SetRepeats( aRepeatNumberOfTimes, aTrailingSilence );
    }
    else
    {
    }
    }


    In the mmp file,
    SYSTEMINCLUDE \epoc32\include\mmf\plugin

    LIBRARY mediaclientaudio.lib
    LIBRARY bafl.lib

    CAPABILITY ReadUserData WriteUserData ReadDeviceData WriteDeviceData

Similar Threads

  1. How to change between audio files to play with CMdaAudioPlayerUtility
    By Besieger in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-08-07, 14:55
  2. How can I play the segment of an audio file, e.g. wav. file in my N73?
    By ipxx in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2007-07-30, 05:03
  3. Contacts fields order??
    By timatima in forum Symbian
    Replies: 1
    Last Post: 2007-06-08, 13:51
  4. [B]AnyOne who can play 3gp Audio[/B]
    By MananW in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2007-01-02, 15:00
  5. Recording Audio in file using CMdaAudioRecordUtility in S60 V3
    By gpalvia in forum Symbian Media (Closed)
    Replies: 6
    Last Post: 2006-08-15, 10:40

Posting Permissions

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