void CAMLPlayer::Seek(bool bPlus, bool bLargeStep) { // force updated to m_elapsed_ms, m_duration_ms. GetStatus(); CSingleLock lock(m_aml_csection); // try chapter seeking first, chapter_index is ones based. int chapter_index = GetChapter(); if (bLargeStep) { // seek to next chapter if (bPlus && (chapter_index < GetChapterCount())) { SeekChapter(chapter_index + 1); return; } // seek to previous chapter if (!bPlus && chapter_index) { SeekChapter(chapter_index - 1); return; } } int64_t seek_ms; if (g_advancedSettings.m_videoUseTimeSeeking) { if (bLargeStep && (GetTotalTime() > (2 * g_advancedSettings.m_videoTimeSeekForwardBig))) seek_ms = bPlus ? g_advancedSettings.m_videoTimeSeekForwardBig : g_advancedSettings.m_videoTimeSeekBackwardBig; else seek_ms = bPlus ? g_advancedSettings.m_videoTimeSeekForward : g_advancedSettings.m_videoTimeSeekBackward; // convert to milliseconds seek_ms *= 1000; seek_ms += m_elapsed_ms; } else { float percent; if (bLargeStep) percent = bPlus ? g_advancedSettings.m_videoPercentSeekForwardBig : g_advancedSettings.m_videoPercentSeekBackwardBig; else percent = bPlus ? g_advancedSettings.m_videoPercentSeekForward : g_advancedSettings.m_videoPercentSeekBackward; percent /= 100.0f; percent += (float)m_elapsed_ms/(float)m_duration_ms; // convert to milliseconds seek_ms = m_duration_ms * percent; } // handle stacked videos, dvdplayer does it so we do it too. if (g_application.CurrentFileItem().IsStack() && (seek_ms > m_duration_ms || seek_ms < 0)) { CLog::Log(LOGDEBUG, "CAMLPlayer::Seek: In mystery code, what did I do"); g_application.SeekTime((seek_ms - m_elapsed_ms) * 0.001 + g_application.GetTime()); // warning, don't access any object variables here as // the object may have been destroyed return; } if (seek_ms <= 1000) seek_ms = 1000; if (seek_ms > m_duration_ms) seek_ms = m_duration_ms; // do seek here g_infoManager.SetDisplayAfterSeek(100000); SeekTime(seek_ms); m_callback.OnPlayBackSeek((int)seek_ms, (int)(seek_ms - m_elapsed_ms)); g_infoManager.SetDisplayAfterSeek(); }
bool CGUIWindowFullScreen::OnAction(const CAction &action) { if (g_application.m_pPlayer != NULL && g_application.m_pPlayer->OnAction(action)) return true; switch (action.wID) { case ACTION_SHOW_GUI: { // switch back to the menu OutputDebugString("Switching to GUI\n"); m_gWindowManager.PreviousWindow(); OutputDebugString("Now in GUI\n"); return true; } break; case ACTION_STEP_BACK: Seek(false, false); return true; break; case ACTION_STEP_FORWARD: Seek(true, false); return true; break; case ACTION_BIG_STEP_BACK: SeekChapter(g_application.m_pPlayer->GetChapter() - 1); return true; break; case ACTION_BIG_STEP_FORWARD: SeekChapter(g_application.m_pPlayer->GetChapter() + 1); return true; break; case ACTION_NEXT_SCENE: if (g_application.m_pPlayer->SeekScene(true)) g_infoManager.SetDisplayAfterSeek(); return true; break; case ACTION_PREV_SCENE: if (g_application.m_pPlayer->SeekScene(false)) g_infoManager.SetDisplayAfterSeek(); return true; break; case ACTION_SHOW_OSD_TIME: m_bShowCurrentTime = !m_bShowCurrentTime; if(!m_bShowCurrentTime) g_infoManager.SetDisplayAfterSeek(0); //Force display off g_infoManager.SetShowTime(m_bShowCurrentTime); return true; break; case ACTION_SHOW_OSD: // Show the OSD { CGUIWindowOSD *pOSD = (CGUIWindowOSD *)m_gWindowManager.GetWindow(WINDOW_OSD); if (pOSD) pOSD->DoModal(); return true; } break; case ACTION_SHOW_SUBTITLES: { g_application.m_pPlayer->SetSubtitleVisible(!g_application.m_pPlayer->GetSubtitleVisible()); } return true; break; case ACTION_NEXT_SUBTITLE: { if (g_application.m_pPlayer->GetSubtitleCount() == 1) return true; g_stSettings.m_currentVideoSettings.m_SubtitleStream++; if (g_stSettings.m_currentVideoSettings.m_SubtitleStream >= g_application.m_pPlayer->GetSubtitleCount()) g_stSettings.m_currentVideoSettings.m_SubtitleStream = 0; g_application.m_pPlayer->SetSubtitle(g_stSettings.m_currentVideoSettings.m_SubtitleStream); return true; } return true; break; case ACTION_SUBTITLE_DELAY_MIN: g_stSettings.m_currentVideoSettings.m_SubtitleDelay -= 0.1f; if (g_stSettings.m_currentVideoSettings.m_SubtitleDelay < -g_advancedSettings.m_videoSubsDelayRange) g_stSettings.m_currentVideoSettings.m_SubtitleDelay = -g_advancedSettings.m_videoSubsDelayRange; if (g_application.m_pPlayer) g_application.m_pPlayer->SetSubTitleDelay(g_stSettings.m_currentVideoSettings.m_SubtitleDelay); return true; break; case ACTION_SUBTITLE_DELAY_PLUS: g_stSettings.m_currentVideoSettings.m_SubtitleDelay += 0.1f; if (g_stSettings.m_currentVideoSettings.m_SubtitleDelay > g_advancedSettings.m_videoSubsDelayRange) g_stSettings.m_currentVideoSettings.m_SubtitleDelay = g_advancedSettings.m_videoSubsDelayRange; if (g_application.m_pPlayer) g_application.m_pPlayer->SetSubTitleDelay(g_stSettings.m_currentVideoSettings.m_SubtitleDelay); return true; break; case ACTION_AUDIO_DELAY_MIN: g_stSettings.m_currentVideoSettings.m_AudioDelay -= 0.1f; if (g_stSettings.m_currentVideoSettings.m_AudioDelay < -g_advancedSettings.m_videoAudioDelayRange) g_stSettings.m_currentVideoSettings.m_AudioDelay = -g_advancedSettings.m_videoAudioDelayRange; if (g_application.m_pPlayer) g_application.m_pPlayer->SetAVDelay(g_stSettings.m_currentVideoSettings.m_AudioDelay); return true; break; case ACTION_AUDIO_DELAY_PLUS: g_stSettings.m_currentVideoSettings.m_AudioDelay += 0.1f; if (g_stSettings.m_currentVideoSettings.m_AudioDelay > g_advancedSettings.m_videoAudioDelayRange) g_stSettings.m_currentVideoSettings.m_AudioDelay = g_advancedSettings.m_videoAudioDelayRange; if (g_application.m_pPlayer) g_application.m_pPlayer->SetAVDelay(g_stSettings.m_currentVideoSettings.m_AudioDelay); return true; break; case ACTION_AUDIO_NEXT_LANGUAGE: if (g_application.m_pPlayer->GetAudioStreamCount() == 1) return true; g_stSettings.m_currentVideoSettings.m_AudioStream++; if (g_stSettings.m_currentVideoSettings.m_AudioStream >= g_application.m_pPlayer->GetAudioStreamCount()) g_stSettings.m_currentVideoSettings.m_AudioStream = 0; g_application.m_pPlayer->SetAudioStream(g_stSettings.m_currentVideoSettings.m_AudioStream); // Set the audio stream to the one selected return true; break; case REMOTE_0: case REMOTE_1: case REMOTE_2: case REMOTE_3: case REMOTE_4: case REMOTE_5: case REMOTE_6: case REMOTE_7: case REMOTE_8: case REMOTE_9: ChangetheTimeCode(action.wID); return true; break; case ACTION_ASPECT_RATIO: { // toggle the aspect ratio mode (only if the info is onscreen) if (m_bShowViewModeInfo) { #ifdef HAS_VIDEO_PLAYBACK g_renderManager.SetViewMode(++g_stSettings.m_currentVideoSettings.m_ViewMode); #endif } m_bShowViewModeInfo = true; m_dwShowViewModeTimeout = timeGetTime(); } return true; break; case ACTION_SMALL_STEP_BACK: { int orgpos = (int)g_application.GetTime(); int triesleft = g_advancedSettings.m_videoSmallStepBackTries; int jumpsize = g_advancedSettings.m_videoSmallStepBackSeconds; // secs int setpos = (orgpos > jumpsize) ? orgpos - jumpsize : 0; // First jump = 2*jumpsize int newpos; do { setpos = (setpos > jumpsize) ? setpos - jumpsize : 0; g_application.SeekTime((double)setpos); Sleep(g_advancedSettings.m_videoSmallStepBackDelay); // delay to let mplayer finish its seek (in ms) newpos = (int)g_application.GetTime(); } while ( (newpos > orgpos - jumpsize) && (setpos > 0) && (--triesleft > 0)); //Make sure gui items are visible g_infoManager.SetDisplayAfterSeek(); } return true; break; } return CGUIWindow::OnAction(action); }