📄 play.c
字号:
// Close the current file. // CloseTrack(&sFile); // // Return indicating that we should power off the player. // return(BUTTON_POWER); } // // Is the play button being pressed? // else if((ulButtons & BUTTON_PLAY) && (ulMode != MODE_PLAY)) { // // The user wants to start playback of the song. // ulMode = MODE_PLAY; // // Enable the output processing. // OutputEnable(); // // Inform the user interface that we are playing. // UISetMode(MODE_PLAY); } // // Is the pause button being pressed? // else if((ulButtons & BUTTON_PAUSE) && (ulMode != MODE_PAUSE)) { // // The user wants to pause playback of the song. // ulMode = MODE_PAUSE; // // Disable the output processing. This function will wait until // all the data has been played before shutting down the digital // audio interface and returning. // OutputDisable(); // // Inform the user interface that we are paused. // UISetMode(MODE_PAUSE); } // // Is the stop button being pressed? // else if((ulButtons & BUTTON_STOP) && (ulMode != MODE_STOP)) { // // The user wants to stop playback of the song. // ulMode = MODE_STOP; // // Disable the output processing. This function will wait until // all the data has been played before shutting down the digital // audio interface and returning. // OutputDisable(); // // See if the current track is an Audible program. //#ifdef SUPPORT_AUDIBLE if(AudibleIsAudibleProgram()) { // // Since the current file contains an Audible program, we want // to close and re-open the track when we stop so that the // meta-data will get updated immediately. // CloseTrack(&sFile); OpenTrack(&sFile); } else#endif { // // The current track is not an Audible program, so seek back to // the beginning. // CodecSeek(0); // // Inform the user interface of the new song position. // UISetCurrentTime(0); } // // Inform the user interface that we are stopped. // UISetMode(MODE_STOP); } // // Is the previous track button being pressed? // else if(ulButtons & BUTTON_PREV) { unsigned long ulTime; // // Get the current time. // CodecGetTime(&ulTime); // // If we are more than 3 seconds into the track then simply seek // back to the beginning of the track. // if((ulTime > 3000) && (ulMode != MODE_STOP)) { // // See if we are currently playing an Audible program. //#ifdef SUPPORT_AUDIBLE if(AudibleIsAudibleProgram()) { // // Find the position of the previous section of this // Audible program. // ulTime = AudibleGetPreviousSection(ulTime); } else#endif { // // We should seek to the beginning of the track. // ulTime = 0; } // // Seek to the new time in the track. // CodecSeek(ulTime); // // Inform the user interface of the new track position. // UISetCurrentTime(ulTime); } else { // // Skip to the previous track. // PreviousTrack(&sFile); } } // // Is the next track button being pressed? // else if(ulButtons & BUTTON_NEXT) { // // See if we are currently playing an Audible program. //#ifdef SUPPORT_AUDIBLE if(AudibleIsAudibleProgram() && (ulMode != MODE_STOP)) { unsigned long ulTime; // // Get the current time. // CodecGetTime(&ulTime); // // Find the position of the next section of this Audible // program. // ulTime = AudibleGetNextSection(ulTime); // // See if there is a next section in this Audible program. // if(ulTime != -1) { // // Seek to the new time in the track. // CodecSeek(ulTime); // // Inform the user interface of the new track position. // UISetCurrentTime(ulTime); } else { // // Set the played through indicator for this AUdible // program. // AudibleSetPlayedThrough(); // // Seek to the beginning of the track. // CodecSeek(0); // // Skip to the next track. // NextTrack(&sFile); } } else#endif { // // Skip to the next track. // NextTrack(&sFile); } } // // Is the seek backward button being pressed? // else if((ulButtons & BUTTON_REW) && (ulMode != MODE_STOP)) { unsigned long ulTime, ulSkip; // // Get the current time. // CodecGetTime(&ulTime); // // If we are playing, then we seek backwards by 1.3 seconds. // Otherwise, we seek backwards by 1 second. // if(ulMode == MODE_PLAY) { // // Seek backwards 1.3 seconds. The extra 300ms is to account // for the ~300ms of audio that is played between seeks. // ulSkip = 1300; } else { // // Seek backward 1 second, or to the beginning. // ulSkip = 1000; } // // See if this is an Audible program. //#ifdef SUPPORT_AUDIBLE if(AudibleIsAudibleProgram()) { // // This is an Audible program, so see if we need to accelerate // the seek. // if(ulButtons & BUTTON_SEEK_RATE_ACC1) { // // We should seek by one minute instead of one second. // ulSkip = (ulSkip % 1000) + 60000; } else if(ulButtons & BUTTON_SEEK_RATE_ACC2) { // // We should seek by ten minutes instead of one second. // ulSkip = (ulSkip % 1000) + 600000; } else if(ulButtons & BUTTON_SEEK_RATE_ACC3) { // // We should seek by one hour instead of one second. // ulSkip = (ulSkip % 1000) + 3600000; } } else#endif { // // This is not an Audible program, so see if we need to // accelerate the seek. // if(ulButtons & BUTTON_SEEK_RATE_ACC1) { // // We should seek by two seconds instead of one second. // ulSkip = (ulSkip % 1000) + 2000; } else if(ulButtons & BUTTON_SEEK_RATE_ACC2) { // // We should seek by five seconds instead of one second. // ulSkip = (ulSkip % 1000) + 5000; } else if(ulButtons & BUTTON_SEEK_RATE_ACC3) { // // We should seek by ten seconds instead of one second. // ulSkip = (ulSkip % 1000) + 10000; } } // // If the current time is less than the seek time, then skip to the // previous track. // if(ulTime < ulSkip) { // // Skip to the previous track. // PreviousTrack(&sFile); // // Seek to the end of the previous track. // CodecGetLength(&ulTime); ulTime -= ulSkip; CodecSeek(ulTime); } else { // // Skip backwards by the specified amount of time. // ulTime -= ulSkip; // // Seek to the new position. // CodecSeek(ulTime); } // // Inform the user interface of the new song position. // UISetCurrentTime(ulTime); } // // Is the seek forward button being pressed? // else if((ulButtons & BUTTON_FFWD) && (ulMode != MODE_STOP)) { unsigned long ulTime, ulLength, ulSkip; // // Get the current time. // CodecGetTime(&ulTime); // // Get the length of the song. // CodecGetLength(&ulLength); // // We want to skip by one second. // ulSkip = 1000; // // See if this is an Audible program. //#ifdef SUPPORT_AUDIBLE if(AudibleIsAudibleProgram()) { // // This is an Audible program, so see if we need to accelerate // the seek. // if(ulButtons & BUTTON_SEEK_RATE_ACC1) { // // We should seek by one minute instead of one second. // ulSkip = 60000; } else if(ulButtons & BUTTON_SEEK_RATE_ACC2) { // // We should seek by ten minutes instead of one second. // ulSkip = 600000; } else if(ulButtons & BUTTON_SEEK_RATE_ACC3) { // // We should seek by one hour instead of one second. // ulSkip = 3600000; } } else#endif { // // This is not an Audible program, so see if we need to // accelerate the seek. // if(ulButtons & BUTTON_SEEK_RATE_ACC1) { // // We should seek by two seconds instead of one second. // ulSkip = 2000; } else if(ulButtons & BUTTON_SEEK_RATE_ACC2) { // // We should seek by five seconds instead of one second. // ulSkip = 5000; } else if(ulButtons & BUTTON_SEEK_RATE_ACC3) { // // We should seek by ten seconds instead of one second. // ulSkip = 10000; } } // // If we are more than the seek time from the end of the song, then // seek forward. // if((ulTime + (ulSkip + 300)) < ulLength) { // // Seek to the new position. // CodecSeek(ulTime + ulSkip); // // Inform the user interface of the new song position. // UISetCurrentTime(ulTime + ulSkip); } else { // // Skip to the next track. // NextTrack(&sFile); } } // // Is the record button being pressed? //#ifdef REQUIRE_RECORD else if(ulButtons & BUTTON_RECORD) { // // Disable the output processing. This function will wait until // all the data has been played before shutting down the digital // audio interface and returning. // OutputDisable(); // // Close the current file. // CloseTrack(&sFile); // // Return indicating that we need to record. // return(BUTTON_RECORD); }#endif // // Is the loopback button being pressed? //#ifdef REQUIRE_LOOPBACK else if(ulButtons & BUTTON_LOOPBACK) { // // Disable the output processing. This function will wait until // allt he data has been played before shutting down the digital // audio interface and returning. // OutputDisable(); // // Close the current file. // CloseTrack(&sFile); // // Return indicating that we need to loopback. // return(BUTTON_LOOPBACK); }#endif }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -