Changed elapsed/remaining time display to use the AudioPlayerInterface::

getPosition() function instead of the local stopwatch thingie.
This commit is contained in:
fgerlits 2005-08-26 18:56:47 +00:00
parent cb748119cd
commit 1dd735b754
3 changed files with 24 additions and 30 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.46 $
Version : $Revision: 1.47 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $
------------------------------------------------------------------------------*/
@ -102,7 +102,7 @@ class MasterPanelWindow;
* respective documentation.
*
* @author $Author: fgerlits $
* @version $Revision: 1.46 $
* @version $Revision: 1.47 $
* @see LocalizedObject#getBundle(const xmlpp::Element &)
* @see AuthenticationClientFactory
* @see StorageClientFactory
@ -642,6 +642,21 @@ class GLiveSupport : public LocalizedConfigurable,
pauseOutputAudio(void)
throw (std::logic_error);
/**
* Determine the time elapsed in the current Playable object
* played by the output audio player.
*
* @return the current time position in the currently open
* Playable object.
* @exception std::logic_error if there is no Playable object open.
*/
virtual Ptr<time_duration>::Ref
getOutputAudioPosition(void)
throw (std::logic_error)
{
return outputPlayer->getPosition();
}
/**
* Play a Playable object using the cue audio player.
*

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.12 $
Version : $Revision: 1.13 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/NowPlaying.cxx,v $
------------------------------------------------------------------------------*/
@ -159,7 +159,6 @@ NowPlaying :: setPlayable(Ptr<Playable>::Ref playable) throw ()
label->set_markup(*infoString);
audioLength = playable->getPlaylength();
audioStart = TimeConversion::now();
} else {
if (isActive && !isPaused) {
@ -172,7 +171,6 @@ NowPlaying :: setPlayable(Ptr<Playable>::Ref playable) throw ()
elapsedTime->set_text("");
remainsTime->set_text("");
audioLength.reset();
audioStart.reset();
}
}
@ -184,11 +182,6 @@ void
NowPlaying :: onPlayButtonClicked(void) throw ()
{
if (isActive && isPaused) {
Ptr<ptime>::Ref now = TimeConversion::now();
time_duration pauseLength = *now - *pausedAtTime;
audioStart.reset(new ptime(*audioStart + pauseLength));
pausedAtTime.reset();
gLiveSupport->pauseOutputAudio(); // i.e., restart
remove(*playButton);
@ -207,8 +200,6 @@ void
NowPlaying :: onPauseButtonClicked(void) throw ()
{
if (isActive && !isPaused) {
pausedAtTime = TimeConversion::now();
gLiveSupport->pauseOutputAudio();
remove(*pauseButton);
@ -263,13 +254,12 @@ NowPlaying :: createFormattedLabel(int fontSize) throw ()
* Update the timer displays. This is called every second by the master panel.
*----------------------------------------------------------------------------*/
void
NowPlaying :: onUpdateTime(void) throw ()
NowPlaying :: onUpdateTime(void)
throw ()
{
if (isActive) {
Ptr<ptime>::Ref now = isPaused ? pausedAtTime
: TimeConversion::now();
Ptr<time_duration>::Ref elapsed(new time_duration(
*now - *audioStart ));
Ptr<time_duration>::Ref elapsed = gLiveSupport->
getOutputAudioPosition();
Ptr<time_duration>::Ref remains(new time_duration(
*audioLength - *elapsed ));
elapsedTime->set_text(*TimeConversion::timeDurationToHhMmSsString(

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/NowPlaying.h,v $
------------------------------------------------------------------------------*/
@ -66,7 +66,7 @@ using namespace LiveSupport::Widgets;
* The box displaying "now playing" in the master panel.
*
* @author $Author: fgerlits $
* @version $Revision: 1.5 $
* @version $Revision: 1.6 $
*/
class NowPlaying : public Gtk::HBox,
public LocalizedObject
@ -88,17 +88,6 @@ class NowPlaying : public Gtk::HBox,
*/
Ptr<time_duration>::Ref audioLength;
/**
* The time the item started playing.
*/
Ptr<ptime>::Ref audioStart;
/**
* The time the pause button was pressed.
* Non-null if isPaused is true (which implies isActive).
*/
Ptr<ptime>::Ref pausedAtTime;
/**
* The label holding the title etc. of the now playing item.
*/