📄 player.c
字号:
if (player_params->range == RANGE_ALL_VOLUMES) { volume_selection_struct.device = DEV_NO_DEVICE; volume = XAR_FindNextVolume(&volume_selection_struct); //find last valid volume } else { volume_selection_struct.device = player_params->device; volume = XAR_FindNextVolume(&volume_selection_struct); //find last valid volume } break; case INDEX_IN_DIR: default: //unallowed case return 0; } } // end of finding correct volume according to direction //shuffle mode song selection if (player_params->shuffle == SHUFFLE_ON) { return player_shuffle_selection(current_song, player_params, player_playlist); } //range track can be tested separatelly if ((player_params->range == RANGE_TRACK) && ((direction == FORWARD) || (direction == BACKWARD))) { if ((player_params->repeat == REPEAT_ON) && (current_song!=0)) //repeat with valid song index return current_song; if ((player_params->repeat == REPEAT_OFF) && (current_song!=0)) //no one track follows in this configuration return 0; } //normal mode (shuffle off) while(1) //in some cases it's necessary to walk through again { if (XAR_IsActiveVolume(volume)) { switch(direction) { case FORWARD: if (player_params->range != RANGE_PLAYLIST) { if (volume==1) { //TOC volume (inside audio tracks can be handled) next_song = find_next_track(current_song, FORWARD, FALSE); } else next_song = XAR_NextSong(volume,current_song,0); } if (player_params->range == RANGE_DIRECTORY) { if (volume!=1) { dir = XAR_DirFromFile(current_song); if (XAR_DirFromFile(next_song) != dir) { if (player_params->repeat == REPEAT_ON) { index = XAR_DirFirstFile(dir); while(!XAR_IsPlayableFile(index)) { index = XAR_NextFile(index,0); if(!index) return 0; } return index; } else return 0; } }#ifdef AUDIO_AS_DIRECTORY //for case, that audio tracks are understood as one directory else if ((volume==1) && (next_song == 0)) { if (player_params->repeat == REPEAT_ON) return find_next_track(0, FORWARD, FALSE); //look for 1st song in audio tracks else return 0; }#endif } #if(USE_RANGE_SUBDIRS==1) if (player_params->range == RANGE_SUBDIRS) { if (volume!=1) { parent = player_params->parent_index; dir = XAR_DirFromFile(next_song); while (dir!=0) { if (parent == dir) break; //ok file is inside the parent else dir = XAR_DirParent(dir); } if (dir == 0) //we went outside with file from current parent tree { if (player_params->repeat == REPEAT_ON) { next_song = XAR_DirFirstFile(dir); if (!next_song) //find next dir containing file while(1) { dir = XAR_ForwDir(dir,parent); if (!dir) return 0; //didn't found any dir ?! next_song = XAR_DirFirstFile(dir); if (next_song) break; } return (next_song); } else return 0; } }#ifdef AUDIO_AS_DIRECTORY //for case, that audio tracks are understood as one directory else if ((volume==1) && (next_song == 0)) { if (player_params->repeat == REPEAT_ON) return find_next_track(0, FORWARD, FALSE); //look for 1st song in audio tracks else return 0; }#endif } #endif // USE_RANGE_SUBDIRS if (player_params->range == RANGE_PLAYLIST) { if (!(player_playlist->array_items)) return 0; else if (!(current_song)) //select first file in current playlist player_playlist->prepared_array_index = 0; //select 1st playlist index else if ((player_playlist->array_index + 1) < player_playlist->array_items) //select next relative to current song player_playlist->prepared_array_index = player_playlist->array_index + 1; else if (player_params->repeat == REPEAT_ON) player_playlist->prepared_array_index = 0; //rewind to first playlist index else return 0; //no next file in playlist return player_playlist->first_volume_node + player_playlist->array[player_playlist->prepared_array_index]; } if (next_song > 0) { player_params->device = XAR_VolumeDeviceType(volume); //update disc_type information return next_song; } else //no next song in current context - check range { if ((player_params->repeat == REPEAT_OFF) && (player_params->range != RANGE_ALL_VOLUMES) && (player_params->range != RANGE_DEVICE)) //same for all ( RANGE_TRACK, RANGE_DIRECTORY, RANGE_SUBDIRS, RANGE_VOLUME, RANGE_PLAYLIST) return 0; if (player_params->range == RANGE_ALL_VOLUMES) //no next song, but volume switching enabled. Find 1st file in volume { //everlasting loop prevention if ((previous_volume == volume) && (next_song == 0)) return 0; previous_volume = volume; //end of everlasting loop prevention current_song = 0; //prepare for going to next volume volume_selection_struct.volume = volume; volume_selection_struct.direction = FORWARD; volume_selection_struct.audio_first = player_params->audio_tracks_first; volume_selection_struct.repeat = player_params->repeat; volume_selection_struct.device = DEV_NO_DEVICE; volume = XAR_FindNextVolume(&volume_selection_struct); //allow to switch independently from devices if (volume == 0) return 0; //no volume has been found according to repeat mode (error occured) } if (player_params->range == RANGE_DEVICE) { //everlasting loop prevention if ((previous_volume == volume) && (next_song == 0)) return 0; previous_volume = volume; //end of everlasting loop prevention current_song = 0; //prepare for going to next volume volume_selection_struct.volume = volume; volume_selection_struct.direction = FORWARD; volume_selection_struct.audio_first = player_params->audio_tracks_first; volume_selection_struct.repeat = player_params->repeat; volume_selection_struct.device = player_params->device; volume = XAR_FindNextVolume(&volume_selection_struct); //allow to switch only on specified devices if (volume == 0) return 0; //no volume has been found according to repeat mode (error occured) } //repeat = on && range != RANGE_ALL_VOLUMES } break; case BACKWARD: if (player_params->range != RANGE_PLAYLIST) { if (volume==1) { //TOC volume (inside audio tracks can be handled) if (current_song >0) next_song = find_next_track(current_song, BACKWARD, FALSE); else next_song = find_next_track(current_song, BACKWARD, TRUE); //need to go to last song (input param current_song=0) } else next_song = XAR_PreviousSong(volume,current_song); } if (player_params->range == RANGE_DIRECTORY) { if (volume!=1) { dir = XAR_DirFromFile(current_song); if (XAR_DirFromFile(next_song) != dir) { if (player_params->repeat == REPEAT_ON) { //find last playable file in current dir next_song = XAR_FindFile(dir,0xffff); while(next_song) { if (XAR_IsPlayableFile(next_song)) break; next_song = XAR_PrevFile(next_song); } } else return 0; } }#ifdef AUDIO_AS_DIRECTORY //for case, that audio tracks are understood as one directory else if ((volume==1) && (next_song == 0)) { if (player_params->repeat == REPEAT_ON) return find_next_track(0, BACKWARD, TRUE); //look for last song in audio tracks else return 0; }#endif } if (player_params->range == RANGE_SUBDIRS) { if (volume!=1) { parent = player_params->parent_index; dir = XAR_DirFromFile(next_song); while (dir!=0) { if (parent == dir) break; //ok file is inside the parent else dir = XAR_DirParent(dir); } if (dir == 0) //we went outside with file from current subtree { if (player_params->repeat == REPEAT_ON) //goto last file in subtree { //goto last dir in a subtree dir = XAR_DirChild(parent); while (1) { tmp2 = XAR_NextDir(dir); if (tmp2 > 0) tmp = tmp2; else { tmp2 = XAR_DirChild(tmp); if(tmp2<=0) break; //tmp carries the last directory in volume tmp = tmp2; } } //now goto last file in dir (in case that dir is empty, go backward in dirs and find some with files while(1) { next_song = XAR_FindFile(tmp,0xffff); if (next_song) return next_song; //last file in last dir //if last dir doesn't contain files tmp = XAR_BackwDir(tmp,parent); if (tmp==S_NOT_FOUND) return tmp; } } else return 0; //no repeat - went outside range subdirs } }#ifdef AUDIO_AS_DIRECTORY //for case, that audio tracks are understood as one directory else if ((volume==1) && (next_song == 0)) { if (player_params->repeat == REPEAT_ON) return find_next_track(0, BACKWARD, TRUE); //look for 1st song in audio tracks else return 0; }#endif } if (player_params->range == RANGE_PLAYLIST) { if (!(player_playlist->array_items)) return 0; else if (!(current_song)) //select first file in current playlist player_playlist->prepared_array_index = player_playlist->array_items - 1; //select last playlist index if (player_playlist->array_index > 0) player_playlist->prepared_array_index = player_playlist->array_index - 1; else if (player_params->repeat == REPEAT_ON) player_playlist->prepared_array_index = player_playlist->array_items - 1; //rewind to last playlist index else return 0; //no next file in playlist return player_playlist->first_volume_node + player_playlist->array[player_playlist->prepared_array_index]; } if (next_song > 0) { player_params->device = XAR_VolumeDeviceType(volume); //update disc_type information return next_song; } else //no next song in current context - check range { if ((player_params->repeat == REPEAT_OFF) && (player_params->range != RANGE_ALL_VOLUMES) && (player_params->range != RANGE_DEVICE)) //same for all ( RANGE_TRACK, RANGE_DIRECTORY, RANGE_SUBDIRS, RANGE_VOLUME, RANGE_PLAYLIST) return 0; if (player_params->range == RANGE_ALL_VOLUMES) //no next song, but volume switching enabled. Find 1st file in volume { //everlasting loop prevention if ((previous_volume == volume) && (next_song == 0)) return 0; previous_volume = volume; //end of everlasting loop prevention current_song = 0; //prepare for going to next volume volume_selection_struct.volume = volume; volume_selection_struct.direction = BACKWARD; volume_selection_struct.audio_first = player_params->audio_tracks_first; volume_selection_struct.repeat = player_params->repeat; volume_selection_struct.device = DEV_NO_DEVICE; volume = XAR_FindNextVolume(&volume_selection_struct); //allow to switch independently from devices if (volume==0) return 0; //no volume has been found according to repeat mode (error occured) } if (player_params->range == RANGE_DEVICE) { //everlasting loop prevention if ((previous_volume == volume) && (next_song == 0)) return 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -