📄 mp3.c
字号:
if (i < 0) {
i = 0;
continue;
}
clrscr();
gotoxy(1,25);
printf("MP3 Pro v 2.0 copyright (C) 2002.Press Esc to exit.");
gotoxy(1,2);
printf("Enter value for position: ");
for (a=0;a<i;a++) printf("%c",str[a]);
}
if (ch != 8 && ch != 13 && ch !=27 && ch != 9) {
str[i] = ch;
i++;
if (i > 3) {
i = 3;
continue;
}
gotoxy(27,2);
for (b=0;b<i;b++) printf("%c",str[b]);
}
}
if(i == 2){
str[i] = '0';
str[i+1] = '0';
str[i+2] = '0';
}
if (i == 3){
str[i] = '0';
str[i+1] = '0';
str[i+2] = '0';
}
int i;
int song_len = atoi(str);
song_len = song_len / 1000;
int count = p_count;
if(count > 0){
count++;
count = count * 9;
count = count - 9;
}
i = count + num;
if(song_len > number[i]) {
gotoxy(20,10);
printf("Length is large.Maximum change oflength = %d",number[i]);
getch();
Position();
}
strcat(change,str);
err = mciSendString(change,0,0,0);
if (err > 0) {
perror("Error");
exit(1);
}
stop_flash = 0;
Usage();
}
void GetAllSong() {
struct _finddata_t f;
long int r;
long int RetVal;
int Len;
char Name[128];
FILE *out;
memset(NextSong,'\0',sizeof(NextSong));
memset(LongFileName,'\0',sizeof(LongFileName));
clrscr();
_chdir(dirname);
r = _findfirst("*.mp3",&f);
if(r < 0) {
_chdir(old_path);
if((out = fopen(file_path,"rb")) == NULL){
gotoxy(20,10);
printf("Sorry no mp3 file(s) on this dirictory");
gotoxy(20,11);
printf("Press eny key to continue");
getch();
exit(1);
}
gotoxy(20,10);
printf("-> %s Path is not valid",dirname);
gotoxy(20,11);
printf("Press eny key to exit");
getch();
fclose(out);
remove(file_path);
exit(1);
}
while(1){
if (err < 0) break;
sprintf(Name,"%s",f.name);
strcpy(NextSong[num],Name);
strcpy(LongFileName[num],NextSong[num]);
err = _findnext(r,&f);
Len = 255;
RetVal = GetShortPathName(NextSong[num],ShortPathName[num],Len);
if (RetVal < 0) exit(1);
strcpy(NextSong[num],ShortPathName[num]);
if (num > max_num) {
clrscr();
gotoxy(28,10);
printf("MAX 1000 mp3 files");
getch();
exit(1);
}
num++;
}
TotalSong = num;
num = 0;
_chdir(old_path);
}
void StatSong(){
char Stat[20];
err = mciSendString("status song mode",Stat,128,0);
if (err > 0) {
perror("error");
exit(1);
}
if (!strcmp(p_List[p_count][num],"")) {
m_null = 1;
return;
}
if (!strcmp(Stat,"playing")) {
isPlay = 1;
if (stop_flash) return;
int i;
int count = p_count;
if(count > 0){
count++;
count = (count * 9) - 9;
}
i = count + num;
if(!strcmp(Label,LongFileName[i])){
m_normal_text = num;
textcolor(14); /* cviat za migane 14 = jalt*/
gotoxy(x,y[num]);/* flash na play listata */
clreol();
sleep(150);
gotoxy(x,y[num]);
printf("%d. %s",num+1,Label);
sleep(150);
}
return;
}
isPlay = 0;
if (Control) isPlay = 1;
}
void CloseSong(){
err = mciSendString("close song ",0,0,0);
if (err > 0) {
perror("error");
exit(1);
}
}
void init(){
int ret;
int d,g,z;
z = 0;
for (d = 0;NextSong[d][0];d++){ /* Zarejdane na parvata play lista */
if(z == 9) {
p_count++;
z = 0;
}
for (int len = 0;NextSong[len][0];len++){ /* Skasiavane na golemite imena */
ret = strlen(LongFileName[len]);
if (ret >= 50) {
for (g=50;LongFileName[len][g];g++) LongFileName[len][g] = '\0';
}
for(int v=0;v<ret;v++){ /* premahvane na mp3 natpisa ot file */
if(LongFileName[len][v] == '.'){
for(int p=v;p<ret;p++) LongFileName[len][p] = '\0';
}
}
}
strcpy(p_List[p_count][z],LongFileName[d]);
strcpy(p_file[p_count][z],NextSong[d]);
z++;
}
MAX = p_count;
p_count = 0;
}
void AutoP_List(){
/* avtomatichna smiana na play listata kogato masivat sochi svoia krai */
p_count++;
for (int q=0;p_List[p_count][q][0];q++){
if(!strcmp(p_List[p_count][q+1],"")){
for (int v=q;v<9;v++) {
y[v] = 5 + v;
gotoxy(x,y[v]);
clreol();
}
}
y[q] = 5 + q;
gotoxy(x,y[q]);
clreol();
textcolor(7);
printf("%d. %s",q+1,p_List[p_count][q]);
strcpy(NextSong[q],p_file[p_count][q]);
}
gotoxy(50,4);
printf("[%d]",p_count+1);
m_normal_text = 0;
}
void p_NextList(){
int q;
if(p_count >= MAX) {
stop_flash = 0;
return;
}
for (int q=0;p_List[p_count][q][0];q++) {
y[q] = 5 + q;
gotoxy(x,y[q]);
clreol();
}
p_count++;
if (!p_count){
for (int q=0;p_List[p_count][q][0];q++) {
y[q] = 5 + q;
gotoxy(x,y[q]);
clreol();
}
}
for (q=0;p_List[p_count][q][0];q++){
y[q] = 5 + q;
gotoxy(x,y[q]);
printf("%d. %s",q+1,p_List[p_count][q]);
strcpy(NextSong[q],p_file[p_count][q]);
strcpy(LongFileName[q],p_List[p_count][q]);
}
gotoxy(50,4);
printf("[%d]",p_count+1);
}
void p_PrevList(){
if (p_count <= 0) return;
for (int q=0;*p_List[p_count][q];q++) {
y[q] = 5 + q;
gotoxy(x,y[q]);
clreol();
}
p_count--;
for (int t=0;p_List[p_count][t][0];t++){
y[t] = 5 + t;
gotoxy(x,y[t]);
printf("%d. %s",t+1,p_List[p_count][t]);
strcpy(NextSong[t],p_file[p_count][t]);
strcpy(LongFileName[t],p_List[p_count][t]);
}
gotoxy(50,4);
printf("[%d]",p_count+1);
}
void GetOldColor(){
textcolor(7); /* return old color */
gotoxy(x,y[m_normal_text]);
printf("%d. %s",m_normal_text+1,p_List[p_count][m_normal_text]);
m_normal_text = 0;
}
void GetSongLength(){
char lpszReturnString[128];
char curr_time[128];
int h,m,s;
int h1,m1,s1;
memset(lpszReturnString,'\0',sizeof(lpszReturnString));
h=m=s=0;
h1=m1=s1=0;
mciSendString("status song length",lpszReturnString,128,0);
mciSendString("status song position",curr_time,128,0);
if(lpszReturnString){ /* Get Total time */
int len = atoi(lpszReturnString);
len =len / 1000;
for(int count=0;count<len;count++){
if(s == 60) {
s=0;
m++;
}
if(m == 60) {
m=0;
h++;
}
s++;
}
}
if(curr_time){ /* Get current time */
int len1 = atoi(curr_time);
len1 =len1 / 1000;
for(int register count=0;count<len1;count++){
if(s1 == 60) {
s1=0;
m1++;
}
if(m1 == 60) {
m1=0;
h1++;
}
s1++;
}
}
textcolor(7);
gotoxy(25,19);
printf("%s -> %02d:%02d:%02d","Total Time",h2,m2,s2);
gotoxy(25,20);
clreol();
printf("%s = %02d:%02d","Current Time",m1,s1);
gotoxy(25,21);
printf("%s = %02d:%02d","End Time",m,s);
if(m>=60){
gotoxy(25,21);
printf("%s %d:%d:%d","End Time",h,m,s);
}
}
void GetTotalTimeAllSong(){
char TotalTime[128];
char song[128];
char FileName[128];
unsigned int len;
int h,m,s;
h=m=s=0;
getlen = 0;
memset(FileName,'\0',sizeof(FileName));
memset(song,'\0',sizeof(song));
memset(TotalTime,'\0',sizeof(TotalTime));
for(int n=0;n<MAX;n++) number[n] = 0;
_chdir(dirname);
gotoxy(25,10);
printf("Please wait... Load Songs");
for(int start = 0;start<TotalSong;start++){
strcpy(song,"status ");
strcat(song,NextSong[start]);
strcat(song," length");
strcpy(FileName,"open ");
strcat(FileName,NextSong[start]);
strcat(FileName," alias song");
gotoxy(25,14);
clreol();
printf("%s",LongFileName[start]);
mciSendString(FileName,0,0,0);
mciSendString(song,TotalTime,128,0);
len = atoi(TotalTime);
len=len/1000;
number[start] = len;
strcpy(CompareNames[start],LongFileName[start]);
getlen = getlen + len;
mciSendString("close song",0,0,0);
if(kbhit()) exit(1);
}
for (int start=0;start<getlen;start++){
if(s == 60) {
s=0;
m++;
}
if(m == 60) {
m=0;
h++;
}
if (h == 24) h = 0;
s++;
}
h2=h;
m2=m;
s2=s;
}
void GetTimeAddSong(){
char lpszReturnString[128];
char FileName[128];
int count[1000];
int i;
unsigned len = 0;;
int m_getlen = 0;
int m_count;
int put_name = 0;
_chdir(dirname);
gotoxy(25,10);
printf("Please wait... Load New Songs");
m_count = 0;
for(i=0;i<TotalSong;i++){
for (int st=i;i<TotalSong;i++){
if (put_name) st = st - m_count;
if(!strcmp(LongFileName[i],CompareNames[st])) break;
strcpy(FileName,"open ");
strcat(FileName,NextSong[i]);
strcat(FileName," alias song");
mciSendString(FileName,0,0,0);
mciSendString("status song length",lpszReturnString,128,0);
gotoxy(25,14);
clreol();
printf("%s",LongFileName[i]);
len = atoi(lpszReturnString);
len=len/1000;
number[i] = len;
m_getlen = m_getlen + len;
mciSendString("close song",0,0,0);
m_count++;
put_name = 1;
break;
}
}
for (int start=0;start<m_getlen;start++){
if(s2 == 60) {
s2=0;
m2++;
}
if(m2 == 60) {
m2=0;
h2++;
}
if (h2 == 24) h2 = 0;
s2++;
}
}
void GetTimeDelSong(){
char lpszReturnString[128];
char FileName[128];
char DeleteSongs[max_num][128];
unsigned len = 0;;
int newTime = 0;
int m_count = 0;
int g;
int a,b = 0;
int put_name = 0;
_chdir(dirname);
for(int i=0;i<max_num;i++) DeleteSongs[i][0] = '\0';
gotoxy(25,10);
printf("Please wait... Geting new time of songs");
for (g=0;g<mm_time;g++){
for(int st=g;TotalSong;st++){
if (put_name) st = st - m_count;
if(!strcmp(CompareNames[g],LongFileName[st])) break;
strcpy(DeleteSongs[m_count],CompareNames[g]);
len= number[g];
newTime = newTime + len;
m_count++;
put_name = 1;
break;
}
}
/* izchisliavane na novoto vreme na pesnite pri polojenie che ima iztriti pesni */
getlen = getlen - newTime;
int h,m,s;
h=m=s=0;
for (int start=0;start<getlen;start++){
if(s == 60) {
s=0;
m++;
}
if(m == 60) {
m=0;
h++;
}
if (h == 24) h = 0;
s++;
}
h2=h;
m2=m;
s2=s;
if (g<=1) {
strcpy(DeleteSongs[g],CompareNames[g]);
printf("Cannot %s",DeleteSongs[g]);
}
clrscr();
gotoxy(20,10);
printf("some mp3 file(s) missing on your dirictory");
int a1,b1;
a1 = 20;
b1 = 11;
for(int h=0;h<m_count;h++){
gotoxy(a1,b1+h);
printf("%s",DeleteSongs[h]);
}
getch();
}
void write_data(){
FILE *p;
int i;
_chdir(old_path);
mm_time = TotalSong;
if ((p = fopen("length.txt","wb")) == NULL) exit(1);
fprintf(p,"%d %d %d %d %d",h2,m2,s2,mm_time,getlen);
fclose(p);
clrscr();
if ((p = fopen("number.txt","wb")) == NULL) exit(1);
for (int f=0;f<TotalSong;f++){
fwrite((void*)&number[f],sizeof(int),1,p);
}
fclose(p);
num = 0;
GetAllSong();
init();
if ((p = fopen("names.txt","wb")) == NULL) exit(1);
for (int f=0;f<TotalSong;f++) fwrite((void*)&LongFileName[f],sizeof(char),1024,p);
fclose(p);
}
void Quit() {
int x,y,z;
char *about[128] = {"Programed by Nikolai Halachev BG E-mail:Jakomen@abv.bg",
"This programe a freeware.Thank You,copyright (C) 2002"};
clrscr();
x = 15;
y = 15;
mciSendString("close song",0,0,0);
for(int i=0;i<2;i++){
for(z = 5;z<y;z++){
gotoxy(x,z);
printf("%s",about[i]);
gotoxy(x,z-1);
clreol();
sleep(50);
}
y = 14;
}
write_data();
sleep(500);
exit(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -