Commit 17dec63f authored by Michael Pyne's avatar Michael Pyne

Add more-accurate accessors for track length info.

Our MPRIS implementation had an inaccurate length calculation because it
was assuming it was working with units of ms from the PlayerManager but
was in reality receiving seconds.

Phonon does export ms though, and many other methods of PlayerManager
work with ms. For the sake of consistency we add millisecond-based
methods (add instead of replacing due to the existing methods being part
of the public DBus API), which fixes the calculation as well.
parent 56ca3d7d
......@@ -227,7 +227,7 @@ void MediaPlayer2Player::setVolume(double volume) const
qlonglong MediaPlayer2Player::Position() const
{
return m_player->currentTime() * 1000;
return m_player->currentTimeMSecs() * 1000;
}
double MediaPlayer2Player::MinimumRate() const
......@@ -247,7 +247,7 @@ bool MediaPlayer2Player::CanSeek() const
void MediaPlayer2Player::Seek(qlonglong Offset) const
{
m_player->seek(((m_player->currentTime() * 1000) + Offset) / 1000);
m_player->seek(((m_player->currentTimeMSecs() * 1000) + Offset) / 1000);
}
bool MediaPlayer2Player::CanControl() const
......
......@@ -51,6 +51,12 @@
<method name="totalTime">
<arg type="i" direction="out"/>
</method>
<method name="currentTimeMSecs">
<arg type="i" direction="out"/>
</method>
<method name="totalTimeMSecs">
<arg type="i" direction="out"/>
</method>
<method name="randomPlayMode">
<arg type="s" direction="out"/>
</method>
......
......@@ -134,19 +134,29 @@ int PlayerManager::status() const
}
int PlayerManager::totalTime() const
{
return totalTimeMSecs() / 1000;
}
int PlayerManager::currentTime() const
{
return currentTimeMSecs() / 1000;
}
int PlayerManager::totalTimeMSecs() const
{
if(!m_setup)
return 0;
return m_media[m_curOutputPath]->totalTime() / 1000;
return m_media[m_curOutputPath]->totalTime();
}
int PlayerManager::currentTime() const
int PlayerManager::currentTimeMSecs() const
{
if(!m_setup)
return 0;
return m_media[m_curOutputPath]->currentTime() / 1000;
return m_media[m_curOutputPath]->currentTime();
}
bool PlayerManager::seekable() const
......
......@@ -60,8 +60,16 @@ public:
bool muted() const;
float volume() const;
int status() const;
// These two have been part of the prior public DBus interface so they have
// been retained. You should use the MSecs versions below. These return in units
// of seconds instead.
int totalTime() const;
int currentTime() const;
int totalTimeMSecs() const;
int currentTimeMSecs() const;
bool seekable() const;
//int position() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment