From 8e9973a09d9258802f9bd0142e1c4c877dfd9688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 22 Apr 2010 15:28:39 +0000 Subject: [PATCH] Added easy method to retrieve the playback position (of the seek slider [0..1]). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36417 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/TransportControlGroup.cpp | 7 +++++++ src/apps/mediaplayer/TransportControlGroup.h | 1 + src/apps/mediaplayer/interface/SeekSlider.cpp | 10 ++++++++++ src/apps/mediaplayer/interface/SeekSlider.h | 1 + 4 files changed, 19 insertions(+) diff --git a/src/apps/mediaplayer/TransportControlGroup.cpp b/src/apps/mediaplayer/TransportControlGroup.cpp index 8f78af22a2..da55b27c5f 100644 --- a/src/apps/mediaplayer/TransportControlGroup.cpp +++ b/src/apps/mediaplayer/TransportControlGroup.cpp @@ -464,6 +464,13 @@ TransportControlGroup::SetPosition(float value, bigtime_t position, } +float +TransportControlGroup::Position() const +{ + return fSeekSlider->Position(); +} + + void TransportControlGroup::SetDisabledString(const char* string) { diff --git a/src/apps/mediaplayer/TransportControlGroup.h b/src/apps/mediaplayer/TransportControlGroup.h index 11cefb17ea..6b19f7878a 100644 --- a/src/apps/mediaplayer/TransportControlGroup.h +++ b/src/apps/mediaplayer/TransportControlGroup.h @@ -68,6 +68,7 @@ public: void SetVolume(float value); void SetPosition(float value, bigtime_t position, bigtime_t duration); + float Position() const; PeakView* GetPeakView() const { return fPeakView; } diff --git a/src/apps/mediaplayer/interface/SeekSlider.cpp b/src/apps/mediaplayer/interface/SeekSlider.cpp index b0e5fa58f6..e75ac4b719 100644 --- a/src/apps/mediaplayer/interface/SeekSlider.cpp +++ b/src/apps/mediaplayer/interface/SeekSlider.cpp @@ -299,6 +299,16 @@ SeekSlider::SetPosition(float position) } +float +SeekSlider::Position() const +{ + int32 range = fMaxValue - fMinValue; + if (range == 0) + return 0; + return (float)(Value() - fMinValue) / range; +} + + bool SeekSlider::IsTracking() const { diff --git a/src/apps/mediaplayer/interface/SeekSlider.h b/src/apps/mediaplayer/interface/SeekSlider.h index 2ac5af6a81..d8bad394e2 100644 --- a/src/apps/mediaplayer/interface/SeekSlider.h +++ b/src/apps/mediaplayer/interface/SeekSlider.h @@ -32,6 +32,7 @@ public: // SeekSlider void SetPosition(float position); + float Position() const; bool IsTracking() const; void SetDisabledString(const char* string);