Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Handle "analog" seeking in a separate handler rather than in GUIDialogSeekBar #1134

Merged
merged 2 commits into from

3 participants

@jmarshallnz
Owner

This moves seek handling to a separate handler, thus ensuring that analog seeking can be done if the seekbar dialog is on screen. It fixes #11712.

As a pull req as there's build changes and a bit of reorg - should be a quick review.

xbmc/Application.cpp
@@ -5308,6 +5315,16 @@ int CApplication::GetPlaySpeed() const
return m_iPlaySpeed;
}
+float CApplication::GetSeekPercentage() const
+{
+ return m_seekHandler->GetPercent();
+}
+
+bool CApplication::IsSeeking() const
+{
+ return m_seekHandler->InProgress();
+}
+
@elupus Collaborator
elupus added a note

Do we really need to put this in CApplication?

@jmarshallnz Owner

We have to put it somewhere. It's either expose the seek handler in some way (owned by the app) or expose the 2 functions we need from it.

@jmarshallnz Owner

@elupus: I can expose using:

const CSeekHandler *GetSeekHandler() const { return m_seekHandler; };

in Application.h if you prefer?

@elupus Collaborator
elupus added a note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Jonathan Mar... added some commits
Jonathan Marshall [seekbar] adds seek handler rather than handling seeking directly in …
…CGUIDialogSeekBar.
124b538
Jonathan Marshall Move the seek handling to the app. Fixes problems where analog seekin…
…g didn't respond while the seekbar wasn't allowed on screen. Fixes #11712
c1398f4
@jmarshallnz jmarshallnz was assigned
@jmarshallnz jmarshallnz merged commit 252ed09 into from
@da-anda
Collaborator

Hey Jonathan, any plans to extend this seekHandler and f.e. also move the calculation for stepForward/bigStepForward out of DVDplayer into this handler, as well as all other seeking stuff (like from CApplication) into this class? Would IMO make the current seeking mess (tons of functions spread everywhere) much better.

@tru tru referenced this pull request from a commit in RasPlex/plex-home-theatre
@tru tru Fix PlexContent for all Episodes
Fixes #1134
5ddbdae
@tru tru referenced this pull request from a commit in RasPlex/plex-home-theatre
@tru tru Fix PlexContent for all Episodes
Fixes #1134
2ae3038
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 11, 2012
  1. [seekbar] adds seek handler rather than handling seeking directly in …

    Jonathan Marshall authored
    …CGUIDialogSeekBar.
Commits on Jul 12, 2012
  1. Move the seek handling to the app. Fixes problems where analog seekin…

    Jonathan Marshall authored
    …g didn't respond while the seekbar wasn't allowed on screen. Fixes #11712
This page is out of date. Refresh to see the latest.
View
6 XBMC-ATV2.xcodeproj/project.pbxproj
@@ -28,6 +28,7 @@
7C0A7FC913A9E75400AFC2BD /* DirtyRegionTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0A7FC613A9E75400AFC2BD /* DirtyRegionTracker.cpp */; };
7C0A7FCC13A9E76E00AFC2BD /* GUIWindowDebugInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0A7FCA13A9E76E00AFC2BD /* GUIWindowDebugInfo.cpp */; };
7C0B990A154B80200065A238 /* AEDeviceInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0B9908154B80200065A238 /* AEDeviceInfo.cpp */; };
+ 7C1A493D15A968BA004AF4A4 /* SeekHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A493B15A968BA004AF4A4 /* SeekHandler.cpp */; };
7C1A89BB152671FB00C63311 /* TextureCacheJob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A89B9152671FB00C63311 /* TextureCacheJob.cpp */; };
7C1D698B15A8142F00658B65 /* DatabaseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1D698915A8142F00658B65 /* DatabaseManager.cpp */; };
7C1F6F8C13ED17CC001726AB /* LibraryDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1F6F8A13ED17CC001726AB /* LibraryDirectory.cpp */; };
@@ -1027,6 +1028,8 @@
7C0B9908154B80200065A238 /* AEDeviceInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AEDeviceInfo.cpp; sourceTree = "<group>"; };
7C0B9909154B80200065A238 /* AEDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AEDeviceInfo.h; sourceTree = "<group>"; };
7C1A494015A968D6004AF4A4 /* SaveFileStateJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaveFileStateJob.h; sourceTree = "<group>"; };
+ 7C1A493B15A968BA004AF4A4 /* SeekHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SeekHandler.cpp; sourceTree = "<group>"; };
+ 7C1A493C15A968BA004AF4A4 /* SeekHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SeekHandler.h; sourceTree = "<group>"; };
7C1A89B9152671FB00C63311 /* TextureCacheJob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureCacheJob.cpp; sourceTree = "<group>"; };
7C1A89BA152671FB00C63311 /* TextureCacheJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureCacheJob.h; sourceTree = "<group>"; };
7C1D698915A8142F00658B65 /* DatabaseManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseManager.cpp; sourceTree = "<group>"; };
@@ -5454,6 +5457,8 @@
F56C775F131EC154000AD0F6 /* ScraperParser.h */,
F56C7760131EC154000AD0F6 /* ScraperUrl.cpp */,
F56C7761131EC154000AD0F6 /* ScraperUrl.h */,
+ 7C1A493B15A968BA004AF4A4 /* SeekHandler.cpp */,
+ 7C1A493C15A968BA004AF4A4 /* SeekHandler.h */,
36A9445B15821FAB00727135 /* SortUtils.cpp */,
36A9445C15821FAB00727135 /* SortUtils.h */,
F56C7762131EC154000AD0F6 /* Splash.cpp */,
@@ -7233,6 +7238,7 @@
DF08E84515829BA600058C77 /* Exception.cpp in Sources */,
36A9465315AA269B00727135 /* DirectoryNodeTags.cpp in Sources */,
7C1D698B15A8142F00658B65 /* DatabaseManager.cpp in Sources */,
+ 7C1A493D15A968BA004AF4A4 /* SeekHandler.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
6 XBMC-IOS.xcodeproj/project.pbxproj
@@ -29,6 +29,7 @@
7C0A7FB213A9E72E00AFC2BD /* DirtyRegionSolvers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0A7FAE13A9E72E00AFC2BD /* DirtyRegionSolvers.cpp */; };
7C0A7FB313A9E72E00AFC2BD /* DirtyRegionTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0A7FB013A9E72E00AFC2BD /* DirtyRegionTracker.cpp */; };
7C0B98F9154B7FF30065A238 /* AEDeviceInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0B98F7154B7FF30065A238 /* AEDeviceInfo.cpp */; };
+ 7C1A495315A968FB004AF4A4 /* SeekHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A495115A968FB004AF4A4 /* SeekHandler.cpp */; };
7C1A89CE1526722200C63311 /* TextureCacheJob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A89CC1526722200C63311 /* TextureCacheJob.cpp */; };
7C1D697815A8141000658B65 /* DatabaseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1D697615A8141000658B65 /* DatabaseManager.cpp */; };
7C1F6F7A13ED178F001726AB /* LibraryDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1F6F7813ED178F001726AB /* LibraryDirectory.cpp */; };
@@ -1027,6 +1028,8 @@
7C0B98F7154B7FF30065A238 /* AEDeviceInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AEDeviceInfo.cpp; sourceTree = "<group>"; };
7C0B98F8154B7FF30065A238 /* AEDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AEDeviceInfo.h; sourceTree = "<group>"; };
7C1A495415A96908004AF4A4 /* SaveFileStateJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaveFileStateJob.h; sourceTree = "<group>"; };
+ 7C1A495115A968FB004AF4A4 /* SeekHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SeekHandler.cpp; sourceTree = "<group>"; };
+ 7C1A495215A968FB004AF4A4 /* SeekHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SeekHandler.h; sourceTree = "<group>"; };
7C1A89CC1526722200C63311 /* TextureCacheJob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureCacheJob.cpp; sourceTree = "<group>"; };
7C1A89CD1526722200C63311 /* TextureCacheJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureCacheJob.h; sourceTree = "<group>"; };
7C1D697615A8141000658B65 /* DatabaseManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseManager.cpp; sourceTree = "<group>"; };
@@ -5819,6 +5822,8 @@
F56C874E131F42EC000AD0F6 /* ScraperParser.h */,
F56C874F131F42EC000AD0F6 /* ScraperUrl.cpp */,
F56C8750131F42EC000AD0F6 /* ScraperUrl.h */,
+ 7C1A495115A968FB004AF4A4 /* SeekHandler.cpp */,
+ 7C1A495215A968FB004AF4A4 /* SeekHandler.h */,
36A9445015821F5300727135 /* SortUtils.cpp */,
36A9445115821F5300727135 /* SortUtils.h */,
F56C8751131F42EC000AD0F6 /* Splash.cpp */,
@@ -7244,6 +7249,7 @@
DFC3867E158296EC008AE277 /* Exception.cpp in Sources */,
36A9465B15AA26BC00727135 /* DirectoryNodeTags.cpp in Sources */,
7C1D697815A8141000658B65 /* DatabaseManager.cpp in Sources */,
+ 7C1A495315A968FB004AF4A4 /* SeekHandler.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
6 XBMC.xcodeproj/project.pbxproj
@@ -258,6 +258,7 @@
43BF09AB1080D2ED00E25290 /* RdrConnectionManagerSCPD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43BF09A81080D2ED00E25290 /* RdrConnectionManagerSCPD.cpp */; };
7C0A7EC013A5DBCE00AFC2BD /* AppParamParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0A7EBE13A5DBCE00AFC2BD /* AppParamParser.cpp */; };
7C0B98A4154B79C30065A238 /* AEDeviceInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0B98A1154B79C30065A238 /* AEDeviceInfo.cpp */; };
+ 7C1A492315A962EE004AF4A4 /* SeekHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A492115A962EE004AF4A4 /* SeekHandler.cpp */; };
7C1A85661520522500C63311 /* TextureCacheJob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1A85631520522500C63311 /* TextureCacheJob.cpp */; };
7C1D682915A7D2FD00658B65 /* DatabaseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1D682715A7D2FD00658B65 /* DatabaseManager.cpp */; };
7C1F6EBB13ECCFA7001726AB /* LibraryDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1F6EB913ECCFA7001726AB /* LibraryDirectory.cpp */; };
@@ -1533,6 +1534,8 @@
7C0B98A1154B79C30065A238 /* AEDeviceInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AEDeviceInfo.cpp; sourceTree = "<group>"; };
7C0B98A2154B79C30065A238 /* AEDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AEDeviceInfo.h; sourceTree = "<group>"; };
7C1A495B15A96918004AF4A4 /* SaveFileStateJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaveFileStateJob.h; sourceTree = "<group>"; };
+ 7C1A492115A962EE004AF4A4 /* SeekHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SeekHandler.cpp; sourceTree = "<group>"; };
+ 7C1A492215A962EE004AF4A4 /* SeekHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SeekHandler.h; sourceTree = "<group>"; };
7C1A85631520522500C63311 /* TextureCacheJob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureCacheJob.cpp; sourceTree = "<group>"; };
7C1A85641520522500C63311 /* TextureCacheJob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureCacheJob.h; sourceTree = "<group>"; };
7C1D682715A7D2FD00658B65 /* DatabaseManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseManager.cpp; sourceTree = "<group>"; };
@@ -5898,6 +5901,8 @@
E38E1E780D25F9FD00618676 /* ScraperParser.h */,
E36C29E70DA72486001F0C9D /* ScraperUrl.cpp */,
7CAA25381085971C0096DE39 /* ScraperUrl.h */,
+ 7C1A492115A962EE004AF4A4 /* SeekHandler.cpp */,
+ 7C1A492215A962EE004AF4A4 /* SeekHandler.h */,
36A9443F15821E7C00727135 /* SortUtils.cpp */,
36A9444015821E7C00727135 /* SortUtils.h */,
E38E1E7F0D25F9FD00618676 /* Splash.cpp */,
@@ -7325,6 +7330,7 @@
1DE0443515828F4B005DDB4D /* Exception.cpp in Sources */,
36A9464C15AA25FD00727135 /* DirectoryNodeTags.cpp in Sources */,
7C1D682915A7D2FD00658B65 /* DatabaseManager.cpp in Sources */,
+ 7C1A492315A962EE004AF4A4 /* SeekHandler.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
2  project/VS2010Express/XBMC.vcxproj
@@ -1110,6 +1110,7 @@
<ClCompile Include="..\..\xbmc\utils\RssReader.cpp" />
<ClCompile Include="..\..\xbmc\utils\ScraperParser.cpp" />
<ClCompile Include="..\..\xbmc\utils\ScraperUrl.cpp" />
+ <ClCompile Include="..\..\xbmc\utils\SeekHandler.cpp" />
<ClCompile Include="..\..\xbmc\utils\SortUtils.cpp" />
<ClCompile Include="..\..\xbmc\utils\Splash.cpp" />
<ClCompile Include="..\..\xbmc\utils\ssrc.cpp" />
@@ -1906,6 +1907,7 @@
<ClInclude Include="..\..\xbmc\utils\SaveFileStateJob.h" />
<ClInclude Include="..\..\xbmc\utils\ScraperParser.h" />
<ClInclude Include="..\..\xbmc\utils\ScraperUrl.h" />
+ <ClInclude Include="..\..\xbmc\utils\SeekHandler.h" />
<ClInclude Include="..\..\xbmc\utils\SortUtils.h" />
<ClInclude Include="..\..\xbmc\utils\Splash.h" />
<ClInclude Include="..\..\xbmc\utils\ssrc.h" />
View
6 project/VS2010Express/XBMC.vcxproj.filters
@@ -2581,6 +2581,9 @@
<ClCompile Include="..\..\xbmc\network\AirTunesServer.cpp">
<Filter>network</Filter>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\utils\SeekHandler.cpp">
+ <Filter>utils</Filter>
+ </ClCompile>
<ClCompile Include="..\..\xbmc\utils\SortUtils.cpp">
<Filter>utils</Filter>
</ClCompile>
@@ -5215,6 +5218,9 @@
<ClInclude Include="..\..\xbmc\network\DllLibShairplay.h">
<Filter>network</Filter>
</ClInclude>
+ <ClInclude Include="..\..\xbmc\utils\SeekHandler.h">
+ <Filter>utils</Filter>
+ </ClInclude>
<ClInclude Include="..\..\xbmc\utils\SortUtils.h">
<Filter>utils</Filter>
</ClInclude>
View
13 xbmc/Application.cpp
@@ -104,6 +104,7 @@
#include "settings/AdvancedSettings.h"
#include "guilib/LocalizeStrings.h"
#include "utils/CPUInfo.h"
+#include "utils/SeekHandler.h"
#include "input/KeyboardStat.h"
#include "input/XBMC_vkeys.h"
@@ -375,6 +376,7 @@ CApplication::CApplication(void)
, m_progressTrackingItem(new CFileItem)
, m_videoInfoScanner(new CVideoInfoScanner)
, m_musicInfoScanner(new CMusicInfoScanner)
+ , m_seekHandler(new CSeekHandler)
{
TiXmlBase::SetCondenseWhiteSpace(false);
m_iPlaySpeed = 1;
@@ -445,6 +447,7 @@ CApplication::~CApplication(void)
#endif
delete m_dpms;
+ delete m_seekHandler;
delete m_pInertialScrollingHandler;
}
@@ -2712,9 +2715,7 @@ bool CApplication::OnAction(const CAction &action)
if (IsPlaying() && action.GetAmount() && (action.GetID() == ACTION_ANALOG_SEEK_FORWARD || action.GetID() == ACTION_ANALOG_SEEK_BACK))
{
if (!m_pPlayer->CanSeek()) return false;
- CGUIWindow *seekBar = g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
- if (seekBar)
- seekBar->OnAction(action);
+ m_seekHandler->Seek(action.GetID() == ACTION_ANALOG_SEEK_FORWARD, action.GetAmount(), action.GetRepeat());
return true;
}
if (action.GetID() == ACTION_GUIPROFILE_BEGIN)
@@ -2807,7 +2808,10 @@ void CApplication::FrameMove(bool processEvents, bool processGUI)
ProcessEventServer(frameTime);
ProcessPeripherals(frameTime);
if (processGUI)
+ {
m_pInertialScrollingHandler->ProcessInertialScroll(frameTime);
+ m_seekHandler->Process();
+ }
}
if (processGUI)
{
@@ -4721,6 +4725,9 @@ bool CApplication::OnMessage(CGUIMessage& message)
#ifdef TARGET_DARWIN
DarwinSetScheduling(message.GetMessage());
#endif
+ // reset the seek handler
+ m_seekHandler->Reset();
+
// Update our infoManager with the new details etc.
if (m_nextPlaylistItem >= 0)
{ // we've started a previously queued item
View
8 xbmc/Application.h
@@ -62,6 +62,7 @@ namespace MEDIA_DETECT
#include "windowing/XBMC_events.h"
#include "threads/Thread.h"
+class CSeekHandler;
class CKaraokeLyricsManager;
class CInertialScrollingHandler;
class CApplicationMessenger;
@@ -337,6 +338,12 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool ToggleDPMS(bool manual);
float GetDimScreenSaverLevel() const;
+
+ /*! \brief Retrieve the applications seek handler.
+ \return a constant pointer to the seek handler.
+ \sa CSeekHandler
+ */
+ const CSeekHandler *GetSeekHandler() const { return m_seekHandler; };
protected:
bool LoadSkin(const CStdString& skinID);
void LoadSkin(const boost::shared_ptr<ADDON::CSkinInfo>& skin);
@@ -436,6 +443,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool InitDirectoriesWin32();
void CreateUserDirs();
+ CSeekHandler *m_seekHandler;
CInertialScrollingHandler *m_pInertialScrollingHandler;
CApplicationMessenger m_applicationMessenger;
#if defined(HAS_LINUX_NETWORK)
View
26 xbmc/GUIInfoManager.cpp
@@ -20,7 +20,6 @@
*/
#include "system.h"
-#include "dialogs/GUIDialogSeekBar.h"
#include "windows/GUIMediaWindow.h"
#include "dialogs/GUIDialogFileBrowser.h"
#include "settings/GUIDialogContentSettings.h"
@@ -58,6 +57,7 @@
#include "utils/CPUInfo.h"
#include "utils/StringUtils.h"
#include "utils/MathUtils.h"
+#include "utils/SeekHandler.h"
// stuff for current song
#include "music/tags/MusicInfoTagLoaderFactory.h"
@@ -1731,11 +1731,8 @@ bool CGUIInfoManager::GetInt(int &value, int info, int contextWindow, const CGUI
value = (int)(g_application.GetCachePercentage());
break;
case PLAYER_SEEKBAR:
- {
- CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
- value = seekBar ? (int)seekBar->GetPercentage() : 0;
- break;
- }
+ value = (int)g_application.GetSeekHandler()->GetPercent();
+ break;
case PLAYER_CACHELEVEL:
value = (int)(g_application.m_pPlayer->GetCacheLevel());
break;
@@ -2128,7 +2125,7 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI
break;
case PLAYER_SEEKBAR:
{
- CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
+ CGUIDialog *seekBar = (CGUIDialog*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
bReturn = seekBar ? seekBar->IsDialogRunning() : false;
}
break;
@@ -2736,12 +2733,7 @@ CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWi
}
else if (info.m_info == PLAYER_SEEKTIME)
{
- TIME_FORMAT format = (TIME_FORMAT)info.GetData1();
- if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
- format = TIME_FORMAT_HH_MM_SS;
- CGUIDialogSeekBar *seekBar = (CGUIDialogSeekBar*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
- if (seekBar)
- return seekBar->GetSeekTimeLabel(format);
+ return GetCurrentSeekTime((TIME_FORMAT)info.GetData1());
}
else if (info.m_info == PLAYER_SEEKOFFSET)
{
@@ -3493,6 +3485,14 @@ CStdString CGUIInfoManager::GetCurrentPlayTime(TIME_FORMAT format) const
return "";
}
+CStdString CGUIInfoManager::GetCurrentSeekTime(TIME_FORMAT format) const
+{
+ if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
+ format = TIME_FORMAT_HH_MM_SS;
+ float time = GetTotalPlayTime() * g_application.GetSeekHandler()->GetPercent() * 0.01f;
+ return StringUtils::SecondsToTimeString((int)time, format);
+}
+
int CGUIInfoManager::GetTotalPlayTime() const
{
int iTotalTime = (int)g_application.GetTotalTime();
View
1  xbmc/GUIInfoManager.h
@@ -651,6 +651,7 @@ class CGUIInfoManager : public IMsgTargetCallback
int64_t GetPlayTime() const; // in ms
CStdString GetCurrentPlayTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const;
+ CStdString GetCurrentSeekTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const;
int GetPlayTimeRemaining() const;
int GetTotalPlayTime() const;
CStdString GetCurrentPlayTimeRemaining(TIME_FORMAT format) const;
View
95 xbmc/dialogs/GUIDialogSeekBar.cpp
@@ -21,14 +21,9 @@
#include "GUIDialogSeekBar.h"
#include "guilib/GUISliderControl.h"
-#include "GUIUserMessages.h"
#include "Application.h"
#include "GUIInfoManager.h"
-#include "utils/TimeUtils.h"
-#include "utils/StringUtils.h"
-
-#define SEEK_BAR_DISPLAY_TIME 2000L
-#define SEEK_BAR_SEEK_TIME 500L
+#include "utils/SeekHandler.h"
#define POPUP_SEEK_SLIDER 401
#define POPUP_SEEK_LABEL 402
@@ -36,8 +31,6 @@
CGUIDialogSeekBar::CGUIDialogSeekBar(void)
: CGUIDialog(WINDOW_DIALOG_SEEK_BAR, "DialogSeekBar.xml")
{
- m_fSeekPercentage = 0.0f;
- m_bRequireSeek = false;
m_loadOnDemand = false; // the application class handles our resources
}
@@ -45,49 +38,6 @@ CGUIDialogSeekBar::~CGUIDialogSeekBar(void)
{
}
-bool CGUIDialogSeekBar::OnAction(const CAction &action)
-{
- if (action.GetID() == ACTION_ANALOG_SEEK_FORWARD || action.GetID() == ACTION_ANALOG_SEEK_BACK)
- {
- if (!m_bRequireSeek)
- { // start of seeking
-
- if (g_infoManager.GetTotalPlayTime())
- m_fSeekPercentage = (float)g_infoManager.GetPlayTime() / g_infoManager.GetTotalPlayTime() * 0.1f;
- else
- m_fSeekPercentage = 0.0f;
-
- // tell info manager that we have started a seekbar operation
- m_bRequireSeek = true;
- g_infoManager.SetSeeking(true);
- }
-
- // calculate our seek amount
- if (g_application.m_pPlayer && !g_infoManager.m_performingSeek)
- {
- //100% over 1 second.
- float speed = 100.0f;
- if( action.GetRepeat() )
- speed *= action.GetRepeat();
- else
- speed /= g_infoManager.GetFPS();
-
- if (action.GetID() == ACTION_ANALOG_SEEK_FORWARD)
- m_fSeekPercentage += action.GetAmount() * action.GetAmount() * speed;
- else
- m_fSeekPercentage -= action.GetAmount() * action.GetAmount() * speed;
- if (m_fSeekPercentage > 100.0f) m_fSeekPercentage = 100.0f;
- if (m_fSeekPercentage < 0.0f) m_fSeekPercentage = 0.0f;
- CGUISliderControl *pSlider = (CGUISliderControl*)GetControl(POPUP_SEEK_SLIDER);
- if (pSlider) pSlider->SetPercentage((int)m_fSeekPercentage); // Update our seek bar accordingly
- }
-
- ResetTimer();
- return true;
- }
- return CGUIDialog::OnAction(action);
-}
-
bool CGUIDialogSeekBar::OnMessage(CGUIMessage& message)
{
switch ( message.GetMessage() )
@@ -102,24 +52,10 @@ bool CGUIDialogSeekBar::OnMessage(CGUIMessage& message)
CGUIDialog::OnMessage(message);
}
break;
- case GUI_MSG_PLAYBACK_STARTED:
- { // new song started while our window is up - update our details
-
- m_bRequireSeek = false;
- m_fSeekPercentage = 0.0f;
-
- }
- break;
-
}
return false; // don't process anything other than what we need!
}
-void CGUIDialogSeekBar::ResetTimer()
-{
- m_timer = CTimeUtils::GetFrameTime();
-}
-
void CGUIDialogSeekBar::FrameMove()
{
if (!g_application.m_pPlayer)
@@ -128,12 +64,8 @@ void CGUIDialogSeekBar::FrameMove()
return;
}
- // check if we should seek or exit
- if (!g_infoManager.m_performingSeek && CTimeUtils::GetFrameTime() - m_timer > SEEK_BAR_DISPLAY_TIME)
- g_infoManager.SetSeeking(false);
-
- // render our controls
- if (!m_bRequireSeek && !g_infoManager.m_performingSeek)
+ // update controls
+ if (!g_application.GetSeekHandler()->InProgress() && !g_infoManager.m_performingSeek)
{ // position the bar at our current time
CGUISliderControl *pSlider = (CGUISliderControl*)GetControl(POPUP_SEEK_SLIDER);
if (pSlider && g_infoManager.GetTotalPlayTime())
@@ -145,25 +77,14 @@ void CGUIDialogSeekBar::FrameMove()
}
else
{
+ CGUISliderControl *pSlider = (CGUISliderControl*)GetControl(POPUP_SEEK_SLIDER);
+ if (pSlider)
+ pSlider->SetPercentage((int)g_application.GetSeekHandler()->GetPercent());
+
CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), POPUP_SEEK_LABEL);
- msg.SetLabel(GetSeekTimeLabel());
+ msg.SetLabel(g_infoManager.GetCurrentSeekTime());
OnMessage(msg);
}
- // Check for seek timeout, and perform the seek
- if (m_bRequireSeek && CTimeUtils::GetFrameTime() - m_timer > SEEK_BAR_SEEK_TIME)
- {
- g_infoManager.m_performingSeek = true;
- double time = g_infoManager.GetTotalPlayTime() * m_fSeekPercentage * 0.01;
- g_application.SeekTime(time);
- m_bRequireSeek = false;
- }
CGUIDialog::FrameMove();
}
-
-CStdString CGUIDialogSeekBar::GetSeekTimeLabel(TIME_FORMAT format)
-{
- int time = (int)(g_infoManager.GetTotalPlayTime() * m_fSeekPercentage * 0.01f);
- return StringUtils::SecondsToTimeString(time, format);
-}
-
View
9 xbmc/dialogs/GUIDialogSeekBar.h
@@ -22,7 +22,6 @@
*/
#include "guilib/GUIDialog.h"
-#include "XBDateTime.h"
class CGUIDialogSeekBar : public CGUIDialog
{
@@ -30,13 +29,5 @@ class CGUIDialogSeekBar : public CGUIDialog
CGUIDialogSeekBar(void);
virtual ~CGUIDialogSeekBar(void);
virtual bool OnMessage(CGUIMessage& message);
- virtual bool OnAction(const CAction &action);
virtual void FrameMove();
- void ResetTimer();
- float GetPercentage() {return m_fSeekPercentage;};
- CStdString GetSeekTimeLabel(TIME_FORMAT format = TIME_FORMAT_GUESS);
-protected:
- unsigned int m_timer;
- float m_fSeekPercentage;
- bool m_bRequireSeek;
};
View
1  xbmc/utils/Makefile
@@ -46,6 +46,7 @@ SRCS=AlarmClock.cpp \
RssReader.cpp \
ScraperParser.cpp \
ScraperUrl.cpp \
+ SeekHandler.cpp \
SortUtils.cpp \
Splash.cpp \
ssrc.cpp \
View
95 xbmc/utils/SeekHandler.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "SeekHandler.h"
+#include "GUIInfoManager.h"
+#include "Application.h"
+
+CSeekHandler::CSeekHandler()
+: m_requireSeek(false),
+ m_percent(0.0f)
+{
+}
+
+void CSeekHandler::Reset()
+{
+ m_requireSeek = false;
+ m_percent = 0;
+}
+
+void CSeekHandler::Seek(bool forward, float amount, float duration)
+{
+ if (!m_requireSeek)
+ { // not yet seeking
+ if (g_infoManager.GetTotalPlayTime())
+ m_percent = (float)g_infoManager.GetPlayTime() / g_infoManager.GetTotalPlayTime() * 0.1f;
+ else
+ m_percent = 0.0f;
+
+ // tell info manager that we have started a seek operation
+ m_requireSeek = true;
+ g_infoManager.SetSeeking(true);
+ }
+ // calculate our seek amount
+ if (!g_infoManager.m_performingSeek)
+ {
+ //100% over 1 second.
+ float speed = 100.0f;
+ if( duration )
+ speed *= duration;
+ else
+ speed /= g_infoManager.GetFPS();
+
+ if (forward)
+ m_percent += amount * amount * speed;
+ else
+ m_percent -= amount * amount * speed;
+ if (m_percent > 100.0f) m_percent = 100.0f;
+ if (m_percent < 0.0f) m_percent = 0.0f;
+ }
+ m_timer.StartZero();
+}
+
+float CSeekHandler::GetPercent() const
+{
+ return m_percent;
+}
+
+bool CSeekHandler::InProgress() const
+{
+ return m_requireSeek;
+}
+
+void CSeekHandler::Process()
+{
+ if (m_timer.GetElapsedMilliseconds() > time_before_seek)
+ {
+ if (!g_infoManager.m_performingSeek && m_timer.GetElapsedMilliseconds() > time_for_display) // TODO: Why?
+ g_infoManager.SetSeeking(false);
+ if (m_requireSeek)
+ {
+ g_infoManager.m_performingSeek = true;
+ double time = g_infoManager.GetTotalPlayTime() * m_percent * 0.01;
+ g_application.SeekTime(time);
+ m_requireSeek = false;
+ }
+ }
+}
View
42 xbmc/utils/SeekHandler.h
@@ -0,0 +1,42 @@
+#pragma once
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "utils/Stopwatch.h"
+
+class CSeekHandler
+{
+public:
+ CSeekHandler();
+
+ void Seek(bool forward, float amount, float duration = 0);
+ void Process();
+ void Reset();
+
+ float GetPercent() const;
+ bool InProgress() const;
+private:
+ static const int time_before_seek = 500;
+ static const int time_for_display = 2000; // TODO: WTF?
+ bool m_requireSeek;
+ float m_percent;
+ CStopWatch m_timer;
+};
Something went wrong with that request. Please try again.