void PLAYBACK::reset() { mustAutopauseAtTheEnd = true; mustFindCurrentMarker = true; displayedMarkerNumber = 0; lastCursorPos = currFrameCounter; lastPositionFrame = pauseFrame = oldPauseFrame = 0; lastPositionIsStable = oldStateOfShowPauseFrame = showPauseFrame = false; rewindButtonOldState = rewindButtonState = false; forwardButtonOldState = forwardButtonState = false; rewindFullButtonOldState = rewindFullButtonState = false; forwardFullButtonOldState = forwardFullButtonState = false; emuPausedOldState = emuPausedState = true; stopSeeking(); }
// an interface for sending Playback cursor to any frame void PLAYBACK::jump(int frame, bool forceStateReload, bool executeLua, bool followPauseframe) { if (frame < 0) return; int lastCursor = currFrameCounter; // 1 - set the Playback cursor to the frame or at least above the frame if (setPlaybackAboveOrToFrame(frame, forceStateReload)) { // since the game state was changed by this jump, we must update possible Lua callbacks and other tools that would normally only update in FCEUI_Emulate if (executeLua) ForceExecuteLuaFrameFunctions(); Update_RAM_Search(); // Update_RAM_Watch() is also called. } // 2 - seek from the current frame if we still aren't at the needed frame if (frame > currFrameCounter) { startSeekingToFrame(frame); } else { // the Playback is already at the needed frame if (pauseFrame) // if Playback was seeking, pause emulation right here stopSeeking(); } // follow the Playback cursor, and optionally follow pauseframe (if seeking was launched) pianoRoll.followPlaybackCursorIfNeeded(followPauseframe); // redraw respective Piano Roll lines if needed if (lastCursor != currFrameCounter) { // redraw row where Playback cursor was (in case there's two or more drags before playback.update()) pianoRoll.redrawRow(lastCursor); bookmarks.redrawChangedBookmarks(lastCursor); } }
TITANIUM_FUNCTION(MusicPlayer, stopSeeking) { stopSeeking(); return get_context().CreateUndefined(); }
void PLAYBACK::update() { // controls: // update < and > buttons rewindButtonOldState = rewindButtonState; rewindButtonState = ((Button_GetState(hwndRewind) & BST_PUSHED) != 0 || mustRewindNow); if (rewindButtonState) { if (!rewindButtonOldState) { buttonHoldTimer = clock(); handleRewindFrame(); } else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock()) { handleRewindFrame(); } } forwardButtonOldState = forwardButtonState; forwardButtonState = (Button_GetState(hwndForward) & BST_PUSHED) != 0; if (forwardButtonState && !rewindButtonState) { if (!forwardButtonOldState) { buttonHoldTimer = clock(); handleForwardFrame(); } else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock()) { handleForwardFrame(); } } // update << and >> buttons rewindFullButtonOldState = rewindFullButtonState; rewindFullButtonState = ((Button_GetState(hwndRewindFull) & BST_PUSHED) != 0); if (rewindFullButtonState && !rewindButtonState && !forwardButtonState) { if (!rewindFullButtonOldState) { buttonHoldTimer = clock(); handleRewindFull(); } else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock()) { handleRewindFull(); } } forwardFullButtonOldState = forwardFullButtonState; forwardFullButtonState = (Button_GetState(hwndForwardFull) & BST_PUSHED) != 0; if (forwardFullButtonState && !rewindButtonState && !forwardButtonState && !rewindFullButtonState) { if (!forwardFullButtonOldState) { buttonHoldTimer = clock(); handleForwardFull(); } else if (buttonHoldTimer + BUTTON_HOLD_REPEAT_DELAY < clock()) { handleForwardFull(); } } // update the Playback cursor if (currFrameCounter != lastCursorPos) { // update gfx of the old and new rows pianoRoll.redrawRow(lastCursorPos); bookmarks.redrawChangedBookmarks(lastCursorPos); pianoRoll.redrawRow(currFrameCounter); bookmarks.redrawChangedBookmarks(currFrameCounter); lastCursorPos = currFrameCounter; // follow the Playback cursor, but in case of seeking don't follow it pianoRoll.followPlaybackCursorIfNeeded(false); //pianoRoll.updatePlaybackCursorPositionInPianoRoll(); // an unfinished experiment // enforce redrawing now UpdateWindow(pianoRoll.hwndList); // lazy update of "Playback's Marker text" int current_marker = markersManager.getMarkerAboveFrame(currFrameCounter); if (displayedMarkerNumber != current_marker) { markersManager.updateEditedMarkerNote(); displayedMarkerNumber = current_marker; redrawMarkerData(); mustFindCurrentMarker = false; } } // [non-lazy] update "Playback's Marker text" if needed if (mustFindCurrentMarker) { markersManager.updateEditedMarkerNote(); displayedMarkerNumber = markersManager.getMarkerAboveFrame(currFrameCounter); redrawMarkerData(); mustFindCurrentMarker = false; } // pause when seeking hits pause_frame if (pauseFrame && currFrameCounter + 1 >= pauseFrame) stopSeeking(); else if (currFrameCounter >= getLastPosition() && currFrameCounter >= currMovieData.getNumRecords() - 1 && mustAutopauseAtTheEnd && taseditorConfig.autopauseAtTheEndOfMovie && !isTaseditorRecording()) // pause at the end of the movie pauseEmulation(); // update flashing pauseframe if (oldPauseFrame != pauseFrame && oldPauseFrame) { // pause_frame was changed, clear old_pauseframe gfx pianoRoll.redrawRow(oldPauseFrame-1); bookmarks.redrawChangedBookmarks(oldPauseFrame-1); } oldPauseFrame = pauseFrame; oldStateOfShowPauseFrame = showPauseFrame; if (pauseFrame) { if (emuPausedState) showPauseFrame = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_WHEN_PAUSED) & 1; else showPauseFrame = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_WHEN_SEEKING) & 1; } else showPauseFrame = false; if (oldStateOfShowPauseFrame != showPauseFrame) { // update pauseframe gfx pianoRoll.redrawRow(pauseFrame - 1); bookmarks.redrawChangedBookmarks(pauseFrame - 1); } // update seeking progressbar emuPausedOldState = emuPausedState; emuPausedState = (FCEUI_EmulationPaused() != 0); if (pauseFrame) { if (oldStateOfShowPauseFrame != showPauseFrame) // update progressbar from time to time // display seeking progress setProgressbar(currFrameCounter - seekingBeginningFrame, pauseFrame - seekingBeginningFrame); } else if (emuPausedOldState != emuPausedState) { // emulator got paused/unpaused externally if (emuPausedOldState && !emuPausedState) { // externally unpaused - show empty progressbar setProgressbar(0, 1); } else { // externally paused - progressbar should be full setProgressbar(1, 1); } } // prepare to stop at the end of the movie in case user unpauses emulator if (emuPausedState) { if (currFrameCounter < currMovieData.getNumRecords() - 1) mustAutopauseAtTheEnd = true; else mustAutopauseAtTheEnd = false; } // this little statement is very important for adequate work of the "green arrow" and "Restore last position" if (!emuPausedState) // when emulating, lost_position_frame becomes unstable (which means that it's probably not equal to the end of current segment anymore) lastPositionIsStable = false; }
void PLAYBACK::cancelSeeking() { if (pauseFrame) stopSeeking(); }