?? song_task.c
字號:
case SONG_INIT:
{
// disp_clock_reset(); /* reset clock timer */
if (Fopen32(READ) == OK)
{
if (song32_init() != SONG_NO_ERR) /* init song playing */
{
song_stop(); /* stop playing song */
Fclose32();
loop = song_loop;
song_state = SONG_NEXT;
}
else
{
song_audio_init(); /* init audio interface */
// clock_song_init();
song_state = SONG_PLL;
Mp3_set_right_vol(mp3_volume);
Mp3_set_left_vol(mp3_volume);
}
}
else
{
song_state = SONG_ERROR;
}
break;
}
case SONG_PLL:
{
if (Pll_get_lock()) /* pll locked? */
{
song_start(); /* start playing song */
//disp_clock_start(); /* start clock timer */
//print_state_play(); /* display play icon */
song_state = SONG_PLAY;
}
break;
}
case SONG_PLAY:
{
printch(0x90,"播放 ");
if (Feof32() == TRUE)
{
Mp3_set_right_vol(0);
Mp3_set_left_vol(0);
// printch(0x95,"結(jié)束 "); /* end of file reached */
song_stop(); /* stop playing song */
//Fclose();
loop = song_loop;
song_state = SONG_NEXT;
gl_key_press = FALSE; /* no key usage */
}
if (gl_key_press) /* a key is pressed? */
{
gl_key_press = FALSE;
switch (gl_key)
{
case KEY_PAUSE:
Aud_song_pause(); /* suspend sample request */
disp_clock_stop(); /* suspend clock timer */
print_state_pause(); /* display pause icon */
song_state = SONG_PAUSE;
break;
case KEY_NEXT:
song_pause(); /* pause playing song */
disp_clock_stop(); /* suspend clock timer */
Fclose32();
loop = TRUE; /* keypad action so loop */
song_state = SONG_NEXT;
break;
case KEY_PREV:
song_pause(); /* pause playing song */
disp_clock_stop(); /* suspend clock timer */
Fclose32();
loop = TRUE;
song_state = SONG_PREV;
break;
case KEY_INC:
song_snd_inc(); /* increment selected control */
print_sound_level(); /* display new level */
break;
case KEY_DEC:
song_snd_dec(); /* decrement selected control */
print_sound_level(); /* display new level */
break;
// case KEY_SOUND:
// song_snd_select(); /* select next sound control */
// print_sound(); /* display selected sound icon */
// print_sound_level(); /* display new level */
// break;
case KEY_REPEAT:
song_loop = ~song_loop; /* display repeat or not */
print_repeat(song_loop);
break;
case KEY_STOP:
song_stop(); /* stop playing song */
Fclose32();
song_state = SONG_STOP;
break;
case KEY_FILE_SELECT:
song_stop(); /* stop playing song */
Fclose();
File32_entry_root(FILE_MP3 | FILE_DIR); /* goto root directory */
print_file_name();
song_state = SONG_FILE_SELECT;
break;
default:
break;
}
gl_key_press = FALSE; /* ack key usage */
}
break;
}
case SONG_FILE_SELECT:
{
if (gl_key_press) /* a key is pressed? */
{
gl_key_press = FALSE;
switch (gl_key)
{
case KEY_FILE_NEXT:
if (file32_seek_next(FILE_MP3 | FILE_DIR, TRUE)); /* select next song with loop */
// print_file_name(); /* display file name */
else
{
File32_goto_parent(FILE_MP3 | FILE_DIR); /* goto parent directory */
file32_seek_next(FILE_MP3 | FILE_DIR, TRUE);
}
print_file_name(); /* display first file name */
break;
case KEY_FILE_PREV:
if (file32_seek_prev(FILE_MP3 | FILE_DIR, TRUE)); /* select previous song */
//print_file_name(); /* display file name */
else
{
File32_goto_parent(FILE_MP3 | FILE_DIR); /* goto parent directory */
file32_seek_prev(FILE_MP3 | FILE_DIR, TRUE);
}
print_file_name(); /* display first file name */
break;
case (KEY_PLAY|KEY_PAUSE):
if (File32_type() == FILE_DIR)
song_state = SONG_NEW;
else
song_state = SONG_INIT;
break;
default:
break;
}
}
break;
}
case SONG_PAUSE: /* one file openned */
{
if (gl_key_press) /* a key is pressed? */
{
switch (gl_key)
{
case KEY_PLAY:
disp_clock_start(); /* restart clock timer */
Aud_song_play(); /* restart sample request */
print_state_play(); /* display play icon */
song_state = SONG_PLAY;
break;
case KEY_NEXT:
song_pause(); /* pause playing song */
Fclose32();
loop = TRUE; /* keypad action so loop */
song_state = SONG_NEXT;
break;
case KEY_PREV:
song_pause(); /* pause playing song */
Fclose32();
loop = TRUE; /* keypad action so loop */
song_state = SONG_PREV;
break;
case KEY_INC:
song_snd_inc(); /* increment selected control */
print_sound_level(); /* display new level */
break;
case KEY_DEC:
song_snd_dec(); /* decrement selected control */
print_sound_level(); /* display new level */
break;
// case KEY_SOUND:
// song_snd_select(); /* select next sound control */
// print_sound(); /* display selected sound icon */
// print_sound_level(); /* display new level */
// break;
case KEY_REPEAT:
song_loop = ~song_loop; /* display repeat or not */
print_repeat(song_loop);
break;
case KEY_STOP:
song_stop(); /* stop playing song */
Fclose32();
song_state = SONG_STOP;
break;
default:
break;
}
gl_key_press = FALSE; /* ack key usage */
}
break;
}
case SONG_NEW:
{
#if PLAYER_PLAY_MODE == PLAY_DISK
if (File32_type() == FILE_DIR)
{
if (file32_entry_dir(FILE_MP3 | FILE_DIR) == OK)
{ /* mp3 or dir in sub-dir */
song_state = SONG_NEW; /* stay in same state */
}
else
{ /* no mp3 or dir in sub-dir */
song_state = SONG_NEXT; /* select next */
}
}
else
{ /* file is MP3 */
song_state = SONG_INIT; /* new song */
// print_repeat(song_loop);
Mp3_set_right_vol(0);
Mp3_set_left_vol(0);
print_file_name(); /* display file name */
}
break;
#else /* PLAYER_MODE == PLAY_DIR */
song_state = SONG_INIT; /* new song */
print_repeat(song_loop);
Mp3_set_right_vol(0);
Mp3_set_left_vol(0);
print_file_name(); /* display file name */
break;
#endif
}
case SONG_NEXT:
{
// printch(0x90,"下首 ");
//disp_name_stop(); /* stop scrolling */
#if PLAYER_PLAY_MODE == PLAY_DISK
if (file32_seek_next(FILE_MP3 | FILE_DIR, FALSE))/* next song or dir */
{ /* mp3 or dir selected */
song_state = SONG_NEW;
}
else
{ /* at end of dir */
if (File32_goto_parent(FILE_MP3 | FILE_DIR) == OK)
{ /* parent exists, point on dir */
song_state = SONG_NEXT; /* next will select next file */
}
else
{ /* no parent: end of root dir */
if (loop)
{
song_state = SONG_NEW;
}
else
{
song_stop();
song_state = SONG_STOP;
}
}
}
break;
#else /* PLAYER_MODE == PLAY_DIR */
if (file32_seek_next(FILE_MP3, loop)) /* select next song */
{ /* still some file to play */
song_state = SONG_NEW;
}
else
{ /* end of dir: stop */
song_stop();
song_state = SONG_STOP;
}
break;
#endif
}
case SONG_PREV:
{
// printch(0x90,"前首 ");
disp_name_stop(); /* stop scrolling */
#if PLAYER_PLAY_MODE == PLAY_DISK
while( song_state == SONG_PREV )
{ /* prev song or dir */
if( !file32_seek_prev(FILE_MP3 | FILE_DIR, FALSE))
{ /* No mp3 or dir selected, at beginning of dir */
if (File32_goto_parent(FILE_MP3 | FILE_DIR) != OK)
{ /* no parent: beginning of root dir */
if (loop)
{
if(File32_goto_last() != OK) /* goto to the end of dir */
{ /* error system */
song_stop();
song_state = SONG_STOP;
}
}
else
{ /* end of dir: stop */
song_stop();
song_state = SONG_STOP;
}
}
else
{
continue; /* goto to previous file in dir parent */
}
}
while (File32_type() == FILE_DIR)
{ /* file found is directory -> enter directory and goto last file */
if (file32_entry_dir(FILE_MP3 | FILE_DIR) == OK)
{ /* mp3 or dir in sub-dir */
if(File32_goto_last() != OK) /* goto to the end of dir */
{ /* error system */
song_stop();
song_state = SONG_STOP;
}
}
else
{
break; /* directory empty goto search previous file */
}
}
if (File32_type() == FILE_MP3)
{ /* mp3 file -> stop research previous file */
song_state = SONG_NEW;
}
/* HERE song_state == SONG_PREV, if select file is empty directory or not mp3 file */
}
break;
#else /* PLAYER_MODE == PLAY_DIR */
if (file32_seek_prev(FILE_MP3, loop)) /* select prev song */
{ /* still some file to play */
song_state = SONG_NEW;
}
else
{ /* beginning of dir: stop */
song_stop();
song_state = SONG_STOP;
}
break;
#endif
}
case SONG_STOP:
{
printch(0x90,"停止 ");
disp_end_of_play(); /* end of music... */
disp_clock_reset(); /* reset clock timer */
print_file_name(); /* display file name */
song_state = SONG_IDLE;
break;
}
case SONG_ERROR:
{
song_stop(); /* stop playing song */
Fclose32(); /* close opened file */
disp_clock_reset(); /* reset clock timer */
print_state_error(); /* display error icon */
disp_name_stop();
song_state = SONG_IDLE;
break;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -