void main() { void main() { //MP3 Player /*初始化*/ MP3player_Init(); //解码器初始化 Mutestate(1);//初始化为声状态 P1 = 0x0f; KBCON = 0x00; IEN1 |=EKB; //按键初始化 EA = 1; //中断使能 /*获得曲目数量*/ Number_Song = GetMP3NUM(); /*处理播放曲目程序*/ Playingflag= 0; while(1) //循环 { if(Number_Song != 0)//如果存在MP3文件 { PlayInit(&SONG[11 * Playingflag]); Mutestate(0);//有声模式 PlayMP3(&SONG[11 * Playingflag]);//播放指定MP3文件 Mutestate(1); } if(Playingflag ==Number_Song)//循环播放 { Playingflag= 0; } } }
/** * * DigitalPlayback * @param aNumSamples * @param aFilename * @param aDataType * @result TVerdict * */ TVerdict CTestStepSDevSoundPlayEOFPCM16::DigitalPlayback(TInt aNumSamples, TDesC& aFilename, TFourCC& aDataType) { TVerdict initializeOK = InitializeDevSound(aDataType, EMMFStatePlaying); if (initializeOK != EPass) { return EInconclusive; } SetVolume(iMMFDevSound->MaxVolume()); //Get a buffer to fill initializeOK = PlayInit(); if (initializeOK != EPass) { return EInconclusive; } TInt error = iFs.Connect(); if (error != KErrNone) { ERR_PRINTF2 (_L("Could not connect to Filesystem. Error is %d"), error); return EInconclusive; } TInt err = iFile.Open(iFs, aFilename, EFileRead); if (err != KErrNone) { ERR_PRINTF2 (_L("Could not open input file. Error is %d"), err); return EInconclusive; } TInt bufferCount = 0; if (aNumSamples < 0) {// Play to EOF while (initializeOK == KErrNone && iCallbackError == KErrNone) { //read sizeof buffer from file CMMFDataBuffer* buffer = STATIC_CAST (CMMFDataBuffer*, iBuffer); iFile.Read(buffer->Data()); if (buffer->Data().Length()!= buffer->RequestSize()) { INFO_PRINTF3(_L("Data length copied from file = %d. Expected %d. Must be EOF"), buffer->Data().Length(), buffer->RequestSize()); iBuffer->SetLastBuffer(ETrue); } //DevSound Play initializeOK = PlayData(); bufferCount ++; } } else { while (bufferCount < aNumSamples && initializeOK == KErrNone && iCallbackError == KErrNone)
int simuaudioinit() { nPlayBuffers=0; PlayState=PLAYST_IDLE; nRecBuffers=0; SendInBuffers=0; StopRecord=FALSE; RecordInitialised=FALSE; PlayInit(44100,10000 //22050 ,8); return 0; }