From 89dd6408cc09af47e87952bbff680784f6dfff89 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 12 Mar 2006 00:01:04 +0000 Subject: [PATCH] Jumps now work by timecode --- player.cc | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/player.cc b/player.cc index e70eca7..d8dc92e 100644 --- a/player.cc +++ b/player.cc @@ -273,12 +273,13 @@ void Player::setLength(ULLONG length) void Player::skipForward(int seconds) { - // skip forward 1 minute logger->log("Player", Log::DEBUG, "SKIP FORWARD %i SECONDS", seconds); if (paused) togglePause(); - ULLONG moveBy = seconds * 500000; + ULONG wantedFrameNumber = video->timecodeToFrameNumber(getPositionTS() + (seconds * 90000)); + ULLONG newPosition = VDR::getInstance()->positionFromFrameNumber(wantedFrameNumber); + logger->log("Player", Log::DEBUG, "wantedframe %i feedpos %llu goto %llu", wantedFrameNumber, feedPosition, newPosition); vfeed.stop(); afeed.stop(); @@ -288,7 +289,7 @@ void Player::skipForward(int seconds) audio->reset(); audio->doMuting(); // ??? demuxer.flush(); - feedPosition += moveBy; + feedPosition = newPosition; vfeed.start(); afeed.start(); threadStart(); @@ -302,12 +303,19 @@ void Player::skipForward(int seconds) void Player::skipBackward(int seconds) { - // skip forward 1 minute logger->log("Player", Log::DEBUG, "SKIP BACKWARD %i SECONDS", seconds); if (paused) togglePause(); - ULLONG moveBy = seconds * 500000; + ULLONG newPosition = 0; + + long long newTimeCode = getPositionTS() - (seconds * 90000); + if (newTimeCode > 0) + { + ULONG wantedFrameNumber = video->timecodeToFrameNumber((ULLONG)newTimeCode); + newPosition = VDR::getInstance()->positionFromFrameNumber(wantedFrameNumber); + logger->log("Player", Log::DEBUG, "wantedframe %i feedpos %llu goto %llu", wantedFrameNumber, feedPosition, newPosition); + } vfeed.stop(); afeed.stop(); @@ -318,7 +326,7 @@ void Player::skipBackward(int seconds) audio->reset(); audio->doMuting(); // ??? demuxer.flush(); - if (feedPosition > moveBy) feedPosition -= moveBy; + feedPosition = newPosition; vfeed.start(); afeed.start(); threadStart(); @@ -671,15 +679,5 @@ void Player::test1() void Player::test2() { logger->log("Player", Log::DEBUG, "PLAYER TEST 2"); - - ULLONG currentTS = getPositionTS(); - ULONG currentFrameNumber = video->timecodeToFrameNumber(currentTS); - logger->log("Player", Log::DEBUG, "Current frame number: %lu", currentFrameNumber); - - ULONG wantedFrameNumber = video->timecodeToFrameNumber(currentTS + (10 * 90000)); - logger->log("Player", Log::DEBUG, "Wanted frame number: %lu", wantedFrameNumber); - - ULLONG newPosition = VDR::getInstance()->positionFromFrameNumber(wantedFrameNumber); - logger->log("Player", Log::DEBUG, "feedpos %llu goto %llu", feedPosition, newPosition); } #endif -- 2.39.5