int MP3ME_Load(char * path){ MP3ME_filePos = 0; MP3ME_isPlaying = 0; MP3ME_playingTime = 0; strcpy(MP3ME_Name, path); // Needed for decode thread releaseAudio(); if (setAudioFrequency(OUTPUT_BUFFER_SIZE/4, 44100, 2) < 0){ MP3ME_Stop(); return ERROR_INVALID_SAMPLE_RATE; } MP3ME_eof = 0; MP3ME_thid = sceKernelCreateThread("decodeThread", decodeThread, THREAD_PRIORITY, 0x10000, PSP_THREAD_ATTR_USER, NULL); if(MP3ME_thid < 0) return ERROR_CREATE_THREAD; sceKernelStartThread(MP3ME_thid, 0, NULL); return OPENING_OK; }
void MP3Play(char * path) { struct ID3Tag ID3; nowplaying = oslLoadImageFilePNG(nowplayingBgPath, OSL_IN_RAM, OSL_PF_8888); mp3Play = oslLoadImageFilePNG("system/app/apollo/play.png", OSL_IN_RAM, OSL_PF_8888); mp3Pause = oslLoadImageFilePNG("system/app/apollo/pause.png", OSL_IN_RAM, OSL_PF_8888); if (!nowplaying) debugDisplay(); scePowerSetClockFrequency(333, 333, 166); pspAudioInit(); int i, mp3Min = 0; MP3ME_Init(1); ParseID3(path, &ID3); MP3ME_Load(path); MP3ME_Play(); isPlaying = 1; while (!osl_quit) { LowMemExit(); oslStartDrawing(); oslClearScreen(RGB(0,0,0)); oslReadKeys(); oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, 0); if (MP3ME_playingTime > 59) { mp3Min += 1; MP3ME_playingTime = 0; } oslDrawImageXY(nowplaying, 0, 0); oslDrawStringf(240,76, "Playing: %.19s", folderIcons[current].name); oslDrawStringf(240,96, "Title: %.21s", ID3.ID3Title); oslDrawStringf(240,116, "Artist: %.20s", ID3.ID3Artist); oslDrawStringf(240,136, "Album: %.21s", ID3.ID3Album); oslDrawStringf(240,156, "Year: %.22s", ID3.ID3Year); oslDrawStringf(240,176, "Genre: %.21s", ID3.ID3GenreText); oslDrawStringf(435,206, "0%d:%.f", mp3Min, MP3ME_playingTime); if (MP3ME_isPlaying == 1) oslDrawImageXY(mp3Play, 230, 224); if (MP3ME_isPlaying == 0) oslDrawImageXY(mp3Pause, 230, 224); battery(370,2,1); digitaltime(420,4,0,hrTime); volumeController(); if(osl_keys->pressed.select) { oslDeleteImage(nowplaying); oslDeleteImage(mp3Play); oslDeleteImage(mp3Pause); return; } if(MP3ME_isPlaying == 1 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); MP3ME_Pause(); for(i=0; i<10; i++) { sceDisplayWaitVblankStart(); } } else if (MP3ME_isPlaying == 0 && osl_keys->pressed.cross) { MP3ME_Play(); } if (MP3ME_EndOfStream() == 1) { isPlaying = 0; endAudioLib(); MP3ME_Stop(); releaseAudio(); MP3ME_Play(); } if(osl_keys->pressed.circle) { endAudioLib(); MP3ME_Stop(); releaseAudio(); oslDeleteImage(nowplaying); oslDeleteImage(mp3Play); oslDeleteImage(mp3Pause); isPlaying = 0; setCpuBoot(); //Restore previous CPU state return; } if (osl_keys->pressed.square) { powermenu(); } if (osl_keys->pressed.L) { oslPlaySound(Lock, 1); lockscreen(); } captureScreenshot(); oslEndDrawing(); oslEndFrame(); oslSyncFrame(); } }
void mp3Controls() //Controls { oslReadKeys(); if (pad.Buttons != oldpad.Buttons) { if (osl_keys->pressed.down) { mp3Down(); timer = 0; } else if (osl_keys->pressed.up) { mp3Up(); timer = 0; } if (osl_keys->pressed.right) { mp3Downx5(); timer = 0; } else if (osl_keys->pressed.left) { mp3Upx5(); timer = 0; } if (osl_keys->pressed.triangle) { curScroll = 1; current = 1; } if (osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); openDir(folderIcons[current].filePath, folderIcons[current].fileType); } } volumeController(); char * ext = strrchr(folderIcons[current].filePath, '.'); if (osl_keys->pressed.circle) { if((strcmp("ms0:/MUSIC", curDir)==0) || (strcmp("ms0:/PSP/MUSIC", curDir)==0) || (strcmp("ms0:/PSP/GAME/CyanogenPSP/downloads", curDir)==0) || (strcmp("ms0:/", curDir)==0)) { oslDeleteImage(mp3bg); oslDeleteImage(mp3_select); mp3player(); } else if((strcmp("ms0:/MUSIC", curDir)!=0)) { dirBack(3); } else if((strcmp("ms0:/PSP/MUSIC", curDir)!=0)) { dirBack(4); } else if((strcmp("ms0:/PSP/GAME/CyanogenPSP/downloads", curDir)!=0)) { dirBack(5); } } if (((ext) != NULL) && ((strcmp(ext ,".mp3") == 0) || ((strcmp(ext ,".MP3") == 0))) && (osl_keys->pressed.cross)) { if (isPlaying == 1) { endAudioLib(); MP3ME_Stop(); releaseAudio(); MP3Play(folderIcons[current].filePath); } else { oslPlaySound(KeypressStandard, 1); MP3Play(folderIcons[current].filePath); } } if (osl_keys->pressed.square) { powermenu(); } if (osl_keys->pressed.L) { oslPlaySound(Lock, 1); lockscreen(); } captureScreenshot(); timer++; if ((timer > 30) && (pad.Buttons & PSP_CTRL_UP)) { mp3Up(); timer = 25; } else if ((timer > 30) && (pad.Buttons & PSP_CTRL_DOWN)) { mp3Down(); timer = 25; } if (current < 1) current = 1; if (current > MAX_FILES) current = MAX_FILES; }
void MP3ME_End(){ MP3ME_Stop(); }