/* ProcessPlayKey routine This routine processes the play/pause button depending on the current mode of operation. */ void ProcessPlayKey(Uint8 Key) { if (IdleTime == 0) { // If was idle if (IdleVolume > 47){ // If not muted then we have headphones if (Input == MP3In) { MP3_Pause(!MP3Paused); // otherwise toggle the paused state of MP3 engine } else { if (PreMuteVolume) { Volume = PreMuteVolume; SetVolume(Volume); } else { PreMuteVolume = Volume; Volume = 0; SetVolume(Volume); } } }else{ ProcessTrackKey(NextTrack); // The process the same as if next track key pressed } } else { if (Input == MP3In) { MP3_Pause(!MP3Paused); // otherwise toggle the paused state of MP3 engine } else { if (PreMuteVolume) { Volume = PreMuteVolume; SetVolume(Volume); } else { PreMuteVolume = Volume; Volume = 0; SetVolume(Volume); } } } }
void psp_mp3_pause() { # ifndef LINUX_MODE MP3_Pause(); # endif }
/* ProcessTrackKey routine Process a key request to change track */ void ProcessTrackKey(Uint8 Key) { if (!InputPresent[MP3In]) // If MP3 player is dead then ignore these keys return; MP3_Pause(false); // Cancel any pause that may have been active if (IdleTime == 0) { // If was idle Track = 1; Ramp = RampDefault; IdleTime = Settings.IdlePeriod; SetDefaultBay(); } else if (Input != MP3In) { // If was not MP3 input Track = 1; // Ramp = RampDefault; } else { // MP3 is currently active input if (Key == NextTrack) { // Work out next track if (++Track > Tracks) Track = 1; } else { if (PrevTime) if (!--Track) Track = Tracks; PrevTime = PrevTimeDefault; } } MP3_Track(Track); // Force to MP3 player and wait for key release SetAllInputs(MP3In); RefreshLamps(); }
int Audio_Pause(){ if(MediaType=="mp3"){ MP3_Pause(); } else if(MediaType=="ogg"){ OGG_Pause(); } else if(MediaType=="mod"){ MIKMOD_Pause(); } }
int main() { pspDebugScreenInit(); SetupCallbacks(); scePowerSetClockFrequency(333, 333, 166); pspAudioInit(); SceCtrlData pad; int i; tzset(); printf("Hello World\n"); time_t now; now = time(NULL); printf("Started %s\n", ctime(&now)); MP3_Init(1); MP3_Load("test.mp3"); MP3_Play(); while(1) { sceCtrlReadBufferPositive(&pad, 1); if(pad.Buttons & PSP_CTRL_CROSS) { break; } else if(pad.Buttons & PSP_CTRL_CIRCLE) { MP3_Pause(); for(i=0; i<10; i++) { sceDisplayWaitVblankStart(); } } if (MP3_EndOfStream() == 1) { MP3_Stop(); } } MP3_Stop(); MP3_FreeTune(); sceKernelSleepThread(); return 0; }
/* SetIdleState routine This routine sets the audio source, destination and volume to the idle state. */ void SetIdleState(void) { enum TBay TempBay; UART_TxStr("Setting to idle\r\n"); IdleTime = 0; // Work out default input for each bay if (Settings.LeftIdleInput <= RightTablet) { SetInput(Settings.LeftIdleInput, LeftBay); } else if (BayProduct[LeftBay] != UnknownProduct) { if (InputPresent[LeftTablet]) SetInput(LeftTablet, LeftBay); else if (InputPresent[RightTablet]) SetInput(RightTablet, LeftBay); else if (InputPresent[LCDIn]) SetInput(LCDIn, LeftBay); else SetInput(MP3In, LeftBay); } if (Settings.CenterIdleInput <= RightTablet) { SetInput(Settings.CenterIdleInput, CenterBay); } else if (BayProduct[CenterBay] != UnknownProduct) { if (InputPresent[LCDIn]) SetInput(LCDIn, CenterBay); else SetInput(MP3In, CenterBay); } if (Settings.RightIdleInput <= RightTablet) { SetInput(Settings.RightIdleInput, RightBay); } else if (BayProduct[RightBay] != UnknownProduct) { if (InputPresent[RightTablet]) SetInput(RightTablet, RightBay); else if (InputPresent[LeftTablet]) SetInput(LeftTablet, RightBay); else if (InputPresent[LCDIn]) SetInput(LCDIn, RightBay); else SetInput(MP3In, RightBay); } SetDefaultBay(); TempBay = Bay; // Work out the idle volume for each bay UART_TxStr("Setting idle volumes\r\n"); for (Bay = LeftBay; Bay <= RightBay; Bay++) { LastBayVolume[Bay] = Settings.ProdDef[BayProduct[Bay]].DefaultVolume; UART_TxStr("Setting bay "); UART_TxNum(Bay, 1); UART_TxStr(" default volume "); UART_TxNum(LastBayVolume[Bay], 3); UART_TxNewLine(); Volume = Settings.ProdDef[BayProduct[Bay]].IdleVolume; SetVolume(Volume); } Bay = TempBay; Volume = IdleVolume; UART_TxStr("Idle volume is "); UART_TxNum(Volume, 1); UART_TxNewLine(); if (MP3Paused) // If paused then unpause MP3_Pause(false); }
/* MainLoop routine This routine should be called ever LoopPeriod. The PlayerStatus should be 0 if stopped or 1 is playing. */ void MainLoop(Uint8 PlayerStatus) { // Update state info wdt_reset(); // Update the watchdog FlashPhase++; if (PrevTime) PrevTime--; // Check for failure of MP3 player if (InputPresent[MP3In] && !MP3Ready) // If MP3 player has died ShowError(ErrorNoMP3, true); // Display error then reboot // See if we need to start playback of next track if (InputPresent[MP3In] && (PlayerStatus == 0)) { if (++Track > Tracks) Track = 1; if(!MP3_Track(Track)){ UART_TxStr("\r\nCan't open track, waiting for watchdog reset\r\n"); DelayMS(10000); // Force the watchdog to activate } } // Process an incoming comms CheckForBoardMsg(); // Check for settings changes SerialControl(); // Poll keys Key = GetKey(); /* if (Key) ClearBit(LogoLEDPort, LogoLED); else SetBit(LogoLEDPort, LogoLED); */ //if no card or in 5headphone no TV input ,some key need disable if(Config==OneBayOneSource){//only one bay,so not need left and right bay if((Key==LeftSelect) || (Key==RightSelect)){ Key = 0; } }else if((Config==OneBayTwoSources) && (!MP3Ready)){ // if((Key==LeftSelect) || (Key==RightSelect) || (Key==PrevTrack) || (Key==NextTrack)){ Key = 0; } }else if(!MP3Ready){ if((Key==PrevTrack) || (Key==NextTrack)){ //if Mp3 not ready so next and prev key not need Key = 0; } } if (!Settings.PauseKeyEnabled && (Key == PlayPause)) // Handle disabled Key = LastKey; if (LastKey != Key) { // Until we know the keyboard is good show it's output UART_TxStr("Key "); UART_TxNum(Key, 1); UART_TxNewLine(); } // Handle error code display request if (Key && (LastKey != Key) && KonamiCheck(Key)) // Until we know the keyboard is good show it's output ShowError(LastError, false); // Handle un-pausing if (Key && (Key != PlayPause)) { // && InputPresent[MP3In] if (MP3Paused) // If paused then unpause MP3_Pause(false); if (PreMuteVolume) { // If muted then unmute Volume = PreMuteVolume; SetVolume(Volume); } } // Process key touched switch (Key){ case LeftSelect: case RightSelect: case CenterSelect: if (Key != LastKey){ if(Config!=OneBayOneSource)//no need to select ProcessSelectKey(Key); } break; case NextTrack: case PrevTrack: if (Key != LastKey) ProcessTrackKey(Key); break; case VolUp: case VolDown: ProcessVolumeKey(Key); break; case PlayPause: if (Key != LastKey) ProcessPlayKey(Key); break; default: break; } LastKey = Key; // Handle time out if (Key) { // See if currently not idle IdleTime = Settings.IdlePeriod; } else if (IdleTime && !--IdleTime) { UART_TxStr("Idle timeout\r\n"); Ramp = RampDown; } // Handle volume ramping switch (Ramp) { case RampDown: UART_TxStr("Ramping down\r\n"); if ((Volume >= MinVolume) && (Volume >= IdleVolume + Settings.VolumeRampStep)) Volume -= Settings.VolumeRampStep; else Volume = IdleVolume; SetVolume(Volume); if (Volume <= IdleVolume) { Ramp = NoRamp; SetIdleState(); } break; case RampDefault: UART_TxStr("Ramping to default\r\n"); if (Volume < DefaultVolume) { if (Volume + Settings.VolumeRampStep <= DefaultVolume) Volume += Settings.VolumeRampStep; else Volume = DefaultVolume; SetVolume(Volume); } else if (Volume > DefaultVolume) { if (Volume >= DefaultVolume + Settings.VolumeRampStep) Volume -= Settings.VolumeRampStep; else Volume = DefaultVolume; SetVolume(Volume); } else { Ramp = NoRamp; } break; default: break; } if(!SlaveMode){ PollTime(); RefreshLamps(); } }