?? song_task.c
字號(hào):
case KEY_FILE_NEXT:
if (file_seek_next(FILE_MP3 | FILE_DIR, TRUE)); /* select next song with loop */
// print_file_name(); /* display file name */
else
{
File_goto_parent(FILE_MP3 | FILE_DIR); /* goto parent directory */
file_seek_next(FILE_MP3 | FILE_DIR, TRUE);
}
print_file_name(); /* display first file name */
break;
case KEY_FILE_PREV:
if (file_seek_prev(FILE_MP3 | FILE_DIR, TRUE)); /* select previous song */
//print_file_name(); /* display file name */
else
{
File_goto_parent(FILE_MP3 | FILE_DIR); /* goto parent directory */
file_seek_prev(FILE_MP3 | FILE_DIR, TRUE);
}
print_file_name(); /* display first file name */
break;
case (KEY_PLAY|KEY_PAUSE):
if (File_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 */
Fclose();
loop = TRUE; /* keypad action so loop */
song_state = SONG_NEXT;
break;
case KEY_PREV:
song_pause(); /* pause playing song */
Fclose();
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 */
Fclose();
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 (File_type() == FILE_DIR)
{
if (file_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 (file_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 (File_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 (file_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( !file_seek_prev(FILE_MP3 | FILE_DIR, FALSE))
{ /* No mp3 or dir selected, at beginning of dir */
if (File_goto_parent(FILE_MP3 | FILE_DIR) != OK)
{ /* no parent: beginning of root dir */
if (loop)
{
if(File_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 (File_type() == FILE_DIR)
{ /* file found is directory -> enter directory and goto last file */
if (file_entry_dir(FILE_MP3 | FILE_DIR) == OK)
{ /* mp3 or dir in sub-dir */
if(File_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 (File_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 (file_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 */
Fclose(); /* close opened file */
disp_clock_reset(); /* reset clock timer */
print_state_error(); /* display error icon */
disp_name_stop();
song_state = SONG_IDLE;
break;
}
}
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
void song_task_32 (void)
{
// Byte cpt_data;
bit loop;
/*if (Mp3_frame_request())
{
// printch(0x96,"請(qǐng)求 ");
cpt_data = 0;
do
{
Mp3_load(Fgetc()); //send data while requested
cpt_data++;
// workaround for 320Kbs frame support
if ((cpt_data & 0x40) == 0x40)
{
Mp3_set_full();
Mp3_reset_full(); // ack 64 Bytes write
break;
}
}
while (Mp3_frame_request()); // until frame request */
while (Mp3_frame_request()) /* frame request ? */
{
Mp3_load(Fgetc32()); /* send data while requested */
}
//}
switch (song_state)
{
case SONG_START:
{
printch(0x93,"選曲 ");
Mp3_set_right_vol(0);
Mp3_set_left_vol(0);
song_state = SONG_INSTALL;
break;
}
case SONG_INSTALL:
{
if (File32_entry_root(FILE_MP3 | FILE_DIR) == OK) /* goto root directory */
{
print_file_name(); /* display file name */
//#if PLAYER_PLAY_START == START_STOP
// song_state = SONG_IDLE;
//#else
if (File32_type() == FILE_DIR)
{ /* file_type is dir */
#if PLAYER_PLAY_MODE == PLAY_DISK
song_state = SONG_NEW; /* enter dir and play */
#else
song_state = SONG_NEXT; /* stay in root dir */
#endif
}
else
{ /* file_type is MP3 */
song_state = SONG_INIT;
}
// #endif
}
else
{ /* root is empty of song & diretory */
song_state = SONG_NO_SONG;
}
break;
}
case SONG_IDLE: /* no file openned */
{
printch(0x90,"掛起 ");
if (gl_key_press) /* a key is pressed? */
{
switch (gl_key)
{
case KEY_PLAY:
if (File32_type() == FILE_DIR)
{
file32_entry_dir(FILE_MP3 | FILE_DIR); /* goto sub-directory */
print_file_name(); /* display directory name */
}
else
{ /* file_type is MP3 */
song_state = SONG_INIT;
}
break;
case KEY_NEXT:
file32_seek_next(FILE_MP3 | FILE_DIR, TRUE); /* select next song with loop */
print_file_name(); /* display file name */
break;
case KEY_PREV:
file32_seek_prev(FILE_MP3 | FILE_DIR, TRUE); /* select previous song */
print_file_name(); /* display file name */
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_PARENT:
File32_goto_parent(FILE_MP3 | FILE_DIR); /* goto parent directory */
print_file_name(); /* display first file name */
break;
default:
break;
}
gl_key_press = FALSE; /* ack key usage */
}
break;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -