How to play mp3 file just like a wav file ?

Login to reply to this topic.
Fri, 2007-09-21 08:39
Joined: 2007-07-31
Forum posts: 123

Hi,

I want to play a mp3 file as a background music in my application not a wav file.But the problem is that when i searched the article about to play the mp3 file then it says to decode the mp3 file and there is a long process to decode the mp3 file, so is not any simpler way to play mp3 file like playing the wav file because playing wav file is much easier.

I am developing the application for the series 60 mobile phones....in symbian C++ with codeworrior IDE ....

I will be very thankful if you tell me the right and easier way to play the mp3 file....

Thank you all...

Brajesh.... Smiling


Life is too short ! so do as many good things as you can do...
Brajesh Kumar...
Beginner in Symbian C++


Sat, 2007-09-22 05:08
Joined: 2006-10-07
Forum posts: 131
Re: How to play mp3 file just like a wav file ?

If you are using CMdaAudioOutputStream to play PCM data, you can play MP3 data by calling CMdaAudioOutputStream::SetDataTypeL(TFourCC aAudioType) with KMMFFourCCCodeMP3.

Sat, 2007-09-22 08:03
Joined: 2007-07-31
Forum posts: 123
Re: How to play mp3 file just like a wav file ?

hi thanks for the help but i request you to please post the sample code to play mp3 file......

thank u

brajesh


Life is too short ! so do as many good things as you can do...
Brajesh Kumar...
Beginner in Symbian C++

Mon, 2007-09-24 08:16
Joined: 2006-10-07
Forum posts: 131
Re: How to play mp3 file just like a wav file ?

Exactly like you would play a WAV file. Since you mentioned in your post that you know how to do it, I thought you do not need the code. For examples, look at Nokia S60 Internet Radio.

Mon, 2007-09-24 13:04
Joined: 2007-07-31
Forum posts: 123
Re: How to play mp3 file just like a wav file ?

Hi Sysctl-forum,

Actually i am able to play the WAV file in the mobile phone but when i want to play the mp3 file, the code does not work.
So i think there is some other way to play the mp3 file thats why i need a sample project to play mp3 file...

Thanks for help...

Brajesh....


Life is too short ! so do as many good things as you can do...
Brajesh Kumar...
Beginner in Symbian C++

Mon, 2007-09-24 16:43
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 1886
Re: How to play mp3 file just like a wav file ?

the code does not work.

What do you mean by the code does not work? It crashes ? it just output gargabe or nothing ? it return an error code ?
Are you sure that your phone can play your MP3 file ?

And maybe you can also post your code instead of requesting some... it would help more people and someone might find why it does not work.


Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Tue, 2007-09-25 12:40
Joined: 2007-07-31
Forum posts: 123
Re: How to play mp3 file just like a wav file ?

Hi eric,

I want to play a mp3 file on my Nokia N72 phone....as i think it support mp3 file.

if i pass the mp3 file in the following function as shown below will it play the mp3 file?

iMdaPlayer=CMdaAudioPlayerUtility::NewFilePlayerL(_L("C:\\system\\Apps\\Sound\\play.mp3"),*this,EMdaPriorityMax);


Life is too short ! so do as many good things as you can do...
Brajesh Kumar...
Beginner in Symbian C++

Mon, 2007-10-08 14:12
Joined: 2007-09-20
Forum posts: 95
Re: How to play mp3 file just like a wav file ?

Hi,

What is the result of the call "CMdaAudioPlayerUtility::NewFilePlayerL()".
This should generate a callback "MMdaAudioPlayerCallback::MapcInitComplete() " with aError=KErrNone. Inidicating the creation and initialization is successful.

What is the error code you are getting in the callback method?

The information you have provided is too little to say anything. If you post your complete (or may be relevant part of) code, you may get some suggestions....

Chao,
Ravi


Chao,
Raghav

Tue, 2007-10-09 08:01
Joined: 2007-07-31
Forum posts: 123
Re: How to play mp3 file just like a wav file ?

Hi,

I have posted the following code....Plz help me in playing the mp3 file.....

Thanks..

When i debugged the following function i got the value of aError -1
void CSoundPlayer::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
{
iState = aError ? ENotReady : EReady;
}
Passing sound file...
void CSortingMainViewContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
if (!pSound)
{
pSound=CSoundPlayer::NewL(_L("C:\\system\\Apps\\Sound\\bkj.mp3"));//Getting the sound file path
}
}
Code to play the sound file...
TKeyResponse CSortingMainViewContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType)
{
switch(MainMenu->MenuItemHandler(aKeyEvent,aType,AppUI))
{

case KMenuOne:
{
if(pSound)
{
pSound->PlayL();//play sound file
}
break;
}
case KMenuTwo:
{
pSound->StopL();
AppUI->ActivateLocalViewL (TUid::Uid(ESortingGameViewId1));
break;
}
default:
break;
}

return EKeyWasNotConsumed;
// return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
}
Functions of CSoundPlayer class

CSoundPlayer* CSoundPlayer::NewL(const TDesC& aFile)
{
CSoundPlayer* self = NewLC(aFile);
CleanupStack::Pop(self);
return self;
}


CSoundPlayer* CSoundPlayer::NewLC(const TDesC& aFile)
{
CSoundPlayer* self = new (ELeave) CSoundPlayer();
CleanupStack::PushL(self);
self->ConstructL(aFile);
return self;
}

CSoundPlayer::CSoundPlayer()
{
}

CSoundPlayer::~CSoundPlayer()
{
delete iMdaPlayer;
iMdaPlayer = NULL;
}

void CSoundPlayer::ConstructL(const TDesC& aFile)
{
if (!iMdaPlayer)
{
iMdaPlayer=CMdaAudioPlayerUtility::NewFilePlayerL(aFile,*this,EMdaPriorityMax);
}

}

void CSoundPlayer::RepeatL()
{
if (iMdaPlayer)
{
iMdaPlayer->SetRepeats(1, TTimeIntervalMicroSeconds(1));
}

}

void CSoundPlayer::PlayL()
{
if(iState==EReady)
{
iState=EPlaying;
iMdaPlayer->Play();
}
}

void CSoundPlayer::StopL()
{
if(iState==EPlaying)
{
iMdaPlayer->Stop();
iState = EReady;
}
}

// from MMdaAudioPlayerCallback
void CSoundPlayer::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
{
iState = aError ? ENotReady : EReady;
}

void CSoundPlayer::MapcPlayComplete(TInt aError)
{
iState = aError ? ENotReady : EReady;
}


Life is too short ! so do as many good things as you can do...
Brajesh Kumar...
Beginner in Symbian C++

Mon, 2007-12-31 06:38
Joined: 2007-09-20
Forum posts: 95
Re: How to play mp3 file just like a wav file ?

Hi,

Make sure that the file exists and the path specified is the correct one. The error in "MapcInitComplete" suggests that probably the file can not be found in the specified path.
Make sure that your app is having the required capability to read from "\sys" folder.


Chao,
Raghav

Wed, 2008-03-12 07:34
Joined: 2006-04-13
Forum posts: 6
How to play mp3 file in UIQ 3.1 Symbian 9.2 via audio stream?

Hi,
I m trying to play an mp3 file in symbian 9.2 by CMdaAudioOutputStream.
I m following these steps:
1. iAudioOutputStream = CMdaAudioOutputStream::NewL(*this);

iAudioSettings.Query();
iAudioSettings.iChannels=TMdaAudioDataSettings::EChannelsMono;
iAudioSettings.iSampleRate=TMdaAudioDataSettings::ESampleRate8000Hz;

iAudioOutputStream->Open(&iAudioSettings);

in callback MaoscOpenComplete() follwoing r implemented:

iDataType.Set(KMMFFourCCCodeMP3);
iAudioOutputStream->SetDataTypeL(iDataType);
iAudioOutputStream->SetPriority(EMdaPriorityMax , EMdaPriorityPreferenceTimeAndQuality);

After these I call:
iAudioOutputStream->WriteL(iBuffer);

Then
MaoscBufferCopied() is called with 0 error

but MaoscPlayComplete()
is called with -10

Please help

Thanks
Regards

  • Login to reply to this topic.