NxWM::CMediaPlayer: Add a CLabel that show the current fast forward/rewind speed
This commit is contained in:
parent
94cec8caff
commit
598dfba79f
@ -51,6 +51,7 @@
|
|||||||
#include "cnxfont.hxx"
|
#include "cnxfont.hxx"
|
||||||
#include "cimage.hxx"
|
#include "cimage.hxx"
|
||||||
#include "cstickyimage.hxx"
|
#include "cstickyimage.hxx"
|
||||||
|
#include "clabel.hxx"
|
||||||
#include "clistbox.hxx"
|
#include "clistbox.hxx"
|
||||||
#include "clistboxdataitem.hxx"
|
#include "clistboxdataitem.hxx"
|
||||||
#include "cglyphsliderhorizontal.hxx"
|
#include "cglyphsliderhorizontal.hxx"
|
||||||
@ -159,7 +160,7 @@ namespace NxWM
|
|||||||
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
||||||
uint8_t m_level; /**< Current volume level, range 0-100 */
|
uint8_t m_level; /**< Current volume level, range 0-100 */
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD
|
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||||
uint8_t m_subSample; /**< Current FFFORWARD subsampling index */
|
uint8_t m_subSample; /**< Current FFFORWARD subsampling index */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -187,6 +188,9 @@ namespace NxWM
|
|||||||
NXWidgets::CStickyImage *m_rewind; /**< Rewind control */
|
NXWidgets::CStickyImage *m_rewind; /**< Rewind control */
|
||||||
NXWidgets::CStickyImage *m_fforward; /**< Fast forward control */
|
NXWidgets::CStickyImage *m_fforward; /**< Fast forward control */
|
||||||
NXWidgets::CGlyphSliderHorizontal *m_volume; /**< Volume control */
|
NXWidgets::CGlyphSliderHorizontal *m_volume; /**< Volume control */
|
||||||
|
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||||
|
NXWidgets::CLabel *m_speed; /**< FForward/rewind speed */
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bitmaps
|
* Bitmaps
|
||||||
@ -300,6 +304,15 @@ namespace NxWM
|
|||||||
|
|
||||||
inline void checkFileSelection(void);
|
inline void checkFileSelection(void);
|
||||||
|
|
||||||
|
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||||
|
/**
|
||||||
|
* Update fast forward/rewind speed indicator. Called on each state
|
||||||
|
* change and after each change in the speed of motion.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void updateMotionIndicator(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a widget action event. For this application, that means image
|
* Handle a widget action event. For this application, that means image
|
||||||
* pre-release events.
|
* pre-release events.
|
||||||
|
@ -125,6 +125,9 @@ CMediaPlayer::CMediaPlayer(CTaskbar *taskbar, CApplicationWindow *window)
|
|||||||
m_rewind = (NXWidgets::CStickyImage *)0;
|
m_rewind = (NXWidgets::CStickyImage *)0;
|
||||||
m_fforward = (NXWidgets::CStickyImage *)0;
|
m_fforward = (NXWidgets::CStickyImage *)0;
|
||||||
m_volume = (NXWidgets::CGlyphSliderHorizontal *)0;
|
m_volume = (NXWidgets::CGlyphSliderHorizontal *)0;
|
||||||
|
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||||
|
m_speed = (NXWidgets::CLabel *)0;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Nullify bitmaps that will be instantiated when the window is started
|
// Nullify bitmaps that will be instantiated when the window is started
|
||||||
|
|
||||||
@ -144,7 +147,7 @@ CMediaPlayer::CMediaPlayer(CTaskbar *taskbar, CApplicationWindow *window)
|
|||||||
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
||||||
m_level = 0;
|
m_level = 0;
|
||||||
#endif
|
#endif
|
||||||
#ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD
|
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||||
m_subSample = 0;
|
m_subSample = 0;
|
||||||
#endif
|
#endif
|
||||||
m_fileReady = false;
|
m_fileReady = false;
|
||||||
@ -208,6 +211,13 @@ CMediaPlayer::~CMediaPlayer(void)
|
|||||||
delete m_volume;
|
delete m_volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||||
|
if (m_speed)
|
||||||
|
{
|
||||||
|
delete m_speed;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Destroy bitmaps
|
// Destroy bitmaps
|
||||||
|
|
||||||
if (m_playBitmap)
|
if (m_playBitmap)
|
||||||
@ -332,6 +342,9 @@ void CMediaPlayer::stop(void)
|
|||||||
m_rewind->disableDrawing();
|
m_rewind->disableDrawing();
|
||||||
m_fforward->disableDrawing();
|
m_fforward->disableDrawing();
|
||||||
m_volume->disableDrawing();
|
m_volume->disableDrawing();
|
||||||
|
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||||
|
m_speed->disableDrawing();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1011,6 +1024,32 @@ bool CMediaPlayer::createPlayer(void)
|
|||||||
m_volume->addWidgetEventHandler(this);
|
m_volume->addWidgetEventHandler(this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||||
|
// Create the speed of motion indicator
|
||||||
|
// The bounding box is determined by the font size
|
||||||
|
|
||||||
|
nxgl_coord_t motionW = (nxgl_coord_t)(3 * m_font->getMaxWidth());
|
||||||
|
nxgl_coord_t motionH = (nxgl_coord_t)(m_font->getHeight());
|
||||||
|
|
||||||
|
// Horizontal position: aligned with the right size of volume slider
|
||||||
|
// Vertical postion: same as the motion controls
|
||||||
|
|
||||||
|
m_speed = new NXWidgets::CLabel(control,
|
||||||
|
volumeControlX + volumeControlW - motionW,
|
||||||
|
controlTop + (controlH - motionH) / 2,
|
||||||
|
motionW, motionH, "");
|
||||||
|
|
||||||
|
// Configure the speed indicator
|
||||||
|
|
||||||
|
m_speed->disableDrawing();
|
||||||
|
m_speed->setBorderless(true);
|
||||||
|
m_speed->setRaisesEvents(false);
|
||||||
|
m_speed->setFont(m_font);
|
||||||
|
m_speed->setTextAlignmentHoriz(NXWidgets::CLabel::TEXT_ALIGNMENT_HORIZ_RIGHT);
|
||||||
|
m_speed->setTextAlignmentVert(NXWidgets::CLabel::TEXT_ALIGNMENT_VERT_CENTER);
|
||||||
|
m_speed->hide();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Make sure that all widgets are setup for the STOPPED state. Among other this,
|
// Make sure that all widgets are setup for the STOPPED state. Among other this,
|
||||||
// this will enable drawing in the play widget (only)
|
// this will enable drawing in the play widget (only)
|
||||||
|
|
||||||
@ -1098,6 +1137,11 @@ void CMediaPlayer::redrawWidgets(void)
|
|||||||
m_fforward->enableDrawing();
|
m_fforward->enableDrawing();
|
||||||
m_fforward->redraw();
|
m_fforward->redraw();
|
||||||
|
|
||||||
|
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||||
|
m_speed->enableDrawing();
|
||||||
|
m_speed->redraw();
|
||||||
|
#endif
|
||||||
|
|
||||||
m_volume->enableDrawing();
|
m_volume->enableDrawing();
|
||||||
m_volume->redraw();
|
m_volume->redraw();
|
||||||
}
|
}
|
||||||
@ -1147,9 +1191,9 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
|
|||||||
m_rewind->disable();
|
m_rewind->disable();
|
||||||
m_rewind->setStuckSelection(false);
|
m_rewind->setStuckSelection(false);
|
||||||
|
|
||||||
|
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
||||||
// Volume slider is available
|
// Volume slider is available
|
||||||
|
|
||||||
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
|
||||||
m_volume->enable();
|
m_volume->enable();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
@ -1182,9 +1226,9 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
|
|||||||
m_rewind->disable();
|
m_rewind->disable();
|
||||||
m_rewind->setStuckSelection(false);
|
m_rewind->setStuckSelection(false);
|
||||||
|
|
||||||
|
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
||||||
// Volume slider is available
|
// Volume slider is available
|
||||||
|
|
||||||
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
|
||||||
m_volume->enable();
|
m_volume->enable();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
@ -1353,6 +1397,12 @@ void CMediaPlayer::setMediaPlayerState(enum EMediaPlayerState state)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||||
|
// Update the motion indicator for the new state
|
||||||
|
|
||||||
|
updateMotionIndicator();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Re-enable drawing and redraw all widgets for the new state
|
// Re-enable drawing and redraw all widgets for the new state
|
||||||
|
|
||||||
redrawWidgets();
|
redrawWidgets();
|
||||||
@ -1470,6 +1520,57 @@ void CMediaPlayer::checkFileSelection(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update fast forward/rewind speed indicator. Called on each state change
|
||||||
|
* and after each change in the speed of motion.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
|
||||||
|
void CMediaPlayer::updateMotionIndicator(void)
|
||||||
|
{
|
||||||
|
m_speed->disableDrawing();
|
||||||
|
if (m_state == MPLAYER_FFORWARD || m_state == MPLAYER_FREWIND)
|
||||||
|
{
|
||||||
|
// Set the new speed string
|
||||||
|
|
||||||
|
char buffer[8];
|
||||||
|
(void)std::snprintf(buffer, 8, "%dX", g_motionSteps[m_subSample]);
|
||||||
|
|
||||||
|
NXWidgets::CNxString speed(buffer);
|
||||||
|
m_speed->setText(speed);
|
||||||
|
|
||||||
|
// Show (un-hide) the speed indicator
|
||||||
|
|
||||||
|
m_speed->show();
|
||||||
|
|
||||||
|
// Redraw the speed indicator
|
||||||
|
|
||||||
|
m_speed->enableDrawing();
|
||||||
|
m_speed->redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
// No, then the speed indicator should be hidden. But don't redraw if
|
||||||
|
// it is already hidden
|
||||||
|
|
||||||
|
else if (!m_speed->isHidden())
|
||||||
|
{
|
||||||
|
// Clear the new speed string
|
||||||
|
|
||||||
|
NXWidgets::CNxString nospeed("");
|
||||||
|
m_speed->setText(nospeed);
|
||||||
|
|
||||||
|
// Redraw the empty speed indicator
|
||||||
|
|
||||||
|
m_speed->enableDrawing();
|
||||||
|
m_speed->redraw();
|
||||||
|
|
||||||
|
// Hide the speed indicator
|
||||||
|
|
||||||
|
m_speed->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a widget action event. For this application, that means image
|
* Handle a widget action event. For this application, that means image
|
||||||
* pre-release events.
|
* pre-release events.
|
||||||
@ -1528,10 +1629,10 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
|
|||||||
{
|
{
|
||||||
dbg("ERROR: nxplayer_rewind failed: %d\n", ret);
|
dbg("ERROR: nxplayer_rewind failed: %d\n", ret);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
// Update the speed indicator
|
||||||
setMediaPlayerState(m_prevState);
|
|
||||||
}
|
updateMotionIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should not be in a STOPPED state here, but let's check anyway
|
// We should not be in a STOPPED state here, but let's check anyway
|
||||||
@ -1578,6 +1679,10 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
|
|||||||
{
|
{
|
||||||
dbg("ERROR: nxplayer_fforward failed: %d\n", ret);
|
dbg("ERROR: nxplayer_fforward failed: %d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the speed indicator
|
||||||
|
|
||||||
|
updateMotionIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should not be in a STOPPED state here, but let's check anyway
|
// We should not be in a STOPPED state here, but let's check anyway
|
||||||
|
Loading…
Reference in New Issue
Block a user