/* Bliz Player and BlizPlayer(Zero cpu) are minimalistic command line audio player. They can read mp3, wav, obj and other formats. Based on the Audiere library Copyright (C) 2006-2007 Santostefano Giovanni contact: idmgiovanni@libero.it This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include using namespace audiere; #pragma comment (lib, "audiere.lib") int main(int argc, char* argv[]) { system("color A"); AudioDevicePtr audiereDevice; OutputStreamPtr* sound; int i; //musica attualmente in esecuzione int j; int pl=0; int num; //numero di musiche int maxframe; char ext[4]; char song[256]; float volume=1; int paus=0; if(argc<2) exit(0); audiereDevice = OpenDevice(); j=0; while(argv[1][j]!='\0'){ j++; } ext[0]=argv[1][j-3]; ext[1]=argv[1][j-2]; ext[2]=argv[1][j-1]; ext[3]='\0'; if(strcmp(ext,"bpl")==0){ pl=1; printf("BlizPlayList: %s\n",argv[1]); FILE* stream=fopen(argv[1],"rt"); num=0; //char c while(fgets(song,255,stream)!=NULL) num++; printf("\n %d songs in playlist\n",num); rewind(stream); //Creo l'array che conterrą le musiche sound=(OutputStreamPtr*)malloc( sizeof(OutputStreamPtr)*num ); memset(sound,0,sizeof(OutputStreamPtr)*num); for(i=0; isetRepeat(true); } fclose(stream); } else{ num=argc-1; //Creo l'array che conterrą le musiche sound=(OutputStreamPtr*)malloc( sizeof(OutputStreamPtr)*num ); memset(sound,0,sizeof(OutputStreamPtr)*num); printf("BlizPlayer By Santostefano Giovanni!\n"); printf("Loading Sounds! \n"); for(i=0; isetRepeat(true); } } i=0; j=0; system("cls"); printf("\nBlizPlayer By Santostefano 'Blizzard' Giovanni!\n"); if(pl!=1) printf("\n\nEX: %s\n",argv[i+1]); else printf("\n\nEX: playlist %d/%d\n",i+1,num); printf("\nVolume: %d %\n",(int)(volume*100)); maxframe=sound[i]->getLength(); sound[i]->play(); while(1){ char cmd[256]; printf("[bpl@command]$ "); scanf("%s",cmd); //scorri next music if((strcmp(cmd,"next")==0 || strcmp(cmd,"n")==0) && istop(); sound[i]->reset(); i++; maxframe=sound[i]->getLength(); sound[i]->play(); system("cls"); printf("\nBlizPlayer By Santostefano 'Blizzard' Giovanni!\n"); if(pl!=1) printf("\n\nEX: %s\n",argv[i+1]); else printf("\n\nEX: playlist %d/%d\n",i+1,num); printf("\nVolume: %d %\n",(int)(volume*100)); } //scorri prev music if((strcmp(cmd,"prev")==0 || strcmp(cmd,"p")==0) && i>0){ Pleft=1; sound[i]->stop(); sound[i]->reset(); i--; maxframe=sound[i]->getLength(); sound[i]->play(); system("cls"); printf("\nBlizPlayer By Santostefano 'Blizzard' Giovanni!\n"); if(pl!=1) printf("\n\nEX: %s\n",argv[i+1]); else printf("\n\nEX: playlist %d/%d\n",i+1,num); printf("\nVolume: %d %\n",(int)(volume*100)); } //alza volume if((strcmp(cmd,"volumeup")==0 || strcmp(cmd,"u")==0) && volume<1){ Pup=1; volume+=(float)0.10f; //cambio il volume for(j=0; jsetVolume(volume); system("cls"); printf("\nBlizPlayer By Santostefano 'Blizzard' Giovanni!\n"); if(pl!=1) printf("\n\nEX: %s\n",argv[i+1]); else printf("\n\nEX: playlist %d/%d\n",i+1,num); printf("\nVolume: %d %\n",(int)(volume*100)); } //abbassa volume if((strcmp(cmd,"volumedown")==0 || strcmp(cmd,"d")==0) && volume>0.1){ Pdown=1; volume-=(float)0.10f; //cambio il volume for(j=0; jsetVolume(volume); system("cls"); printf("\nBlizPlayer By Santostefano 'Blizzard' Giovanni!\n"); if(pl!=1) printf("\n\nEX: %s\n",argv[i+1]); else printf("\n\nEX: playlist %d/%d\n",i+1,num); printf("\nVolume: %d %\n",(int)(volume*100)); } //pausa / play if((strcmp(cmd,"pause")==0 || strcmp(cmd,"s")==0)){ if(sound[i]->isPlaying()){ paus=1; sound[i]->stop(); system("cls"); printf("\nBlizPlayer By Santostefano 'Blizzard' Giovanni!\n"); if(pl!=1) printf("\n\nEX: %s\n",argv[i+1]); else printf("\n\nEX: playlist %d/%d\n",i+1,num); printf("\nVolume: %d %\n",(int)(volume*100)); printf("\nPAUSED!!!\n"); } else{ paus=0; sound[i]->play(); system("cls"); printf("\nBlizPlayer By Santostefano 'Blizzard' Giovanni!\n"); if(pl!=1) printf("\n\nEX: %s\n",argv[i+1]); else printf("\n\nEX: playlist %d/%d\n",i+1,num); printf("\nVolume: %d %\n",(int)(volume*100)); } } //esce dall'applicazione if((strcmp(cmd,"quit")==0 || strcmp(cmd,"q")==0)){ free(sound); exit(0); } }/*end while*/ return 0; }