NxWM::CMediaPlayer: Now uses CStickyImages for fast forward and rewind

This commit is contained in:
Gregory Nutt 2014-07-15 09:48:47 -06:00
parent 0dceeb81b4
commit e38731585d
2 changed files with 30 additions and 7 deletions

View File

@ -47,6 +47,7 @@
#include <nuttx/nx/nxconsole.h> #include <nuttx/nx/nxconsole.h>
#include "cimage.hxx" #include "cimage.hxx"
#include "cstickyimage.hxx"
#include "clabel.hxx" #include "clabel.hxx"
#include "cnxfont.hxx" #include "cnxfont.hxx"
#include "cglyphsliderhorizontal.hxx" #include "cglyphsliderhorizontal.hxx"
@ -122,9 +123,9 @@ namespace NxWM
NXWidgets::CLabel *m_text; /**< Some text in the app for now */ NXWidgets::CLabel *m_text; /**< Some text in the app for now */
NXWidgets::CNxFont *m_font; /**< The font used in the media player */ NXWidgets::CNxFont *m_font; /**< The font used in the media player */
NXWidgets::CImage *m_rew; /**< Rewind control */ NXWidgets::CStickyImage *m_rew; /**< Rewind control */
NXWidgets::CImage *m_playPause; /**< Play/Pause control */ NXWidgets::CImage *m_playPause; /**< Play/Pause control */
NXWidgets::CImage *m_fwd; /**< Forward control */ NXWidgets::CStickyImage *m_fwd; /**< Forward control */
NXWidgets::CGlyphSliderHorizontal *m_volume; /**< Volume control */ NXWidgets::CGlyphSliderHorizontal *m_volume; /**< Volume control */
/** /**

View File

@ -460,8 +460,8 @@ bool CMediaPlayer::createPlayer(void)
CONFIG_NXWM_MEDIAPLAYER_XSPACING; CONFIG_NXWM_MEDIAPLAYER_XSPACING;
m_rew = new NXWidgets:: m_rew = new NXWidgets::
CImage(control, rewControlX, (nxgl_coord_t)controlY, CStickyImage(control, rewControlX, (nxgl_coord_t)controlY,
rewButtonW, buttonH, rewBitmap); rewButtonW, buttonH, rewBitmap);
// Configure the Rewind image // Configure the Rewind image
@ -483,9 +483,8 @@ bool CMediaPlayer::createPlayer(void)
CONFIG_NXWM_MEDIAPLAYER_XSPACING; CONFIG_NXWM_MEDIAPLAYER_XSPACING;
m_fwd = new NXWidgets:: m_fwd = new NXWidgets::
CImage(control, fwdControlX, (nxgl_coord_t)controlY, CStickyImage(control, fwdControlX, (nxgl_coord_t)controlY,
fwdButtonW, buttonH, fwdBitmap); fwdButtonW, buttonH, fwdBitmap);
// Configure the Forward image // Configure the Forward image
@ -564,6 +563,8 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
{ {
printf("Play/pause clicked\n"); printf("Play/pause clicked\n");
// Playing or pausing?
if (m_state == MPLAYER_PLAYING) if (m_state == MPLAYER_PLAYING)
{ {
printf("Media player is now paused\n"); printf("Media player is now paused\n");
@ -576,6 +577,11 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
m_state = MPLAYER_PLAYING; m_state = MPLAYER_PLAYING;
m_prevState = MPLAYER_PLAYING; m_prevState = MPLAYER_PLAYING;
} }
// In any case, we are certainly no longer fast forwarding or rewinding
m_rew->setStuckSelection(false);
m_fwd->setStuckSelection(false);
} }
if (m_rew->isClicked()) if (m_rew->isClicked())
@ -587,12 +593,20 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
// Or increase rewind speed? // Or increase rewind speed?
printf("Reverting to previous Play/Pause state\n"); printf("Reverting to previous Play/Pause state\n");
m_state = m_prevState; m_state = m_prevState;
// Show that we are no longer rewinding
m_rew->setStuckSelection(false);
} }
else else
{ {
printf("Rewinding...\n"); printf("Rewinding...\n");
m_state = MPLAYER_FREWIND; m_state = MPLAYER_FREWIND;
} }
// In any case, we are certainly no longer fast forwarding
m_fwd->setStuckSelection(false);
} }
if (m_fwd->isClicked()) if (m_fwd->isClicked())
@ -604,12 +618,20 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
// Or increase fast forward speed? // Or increase fast forward speed?
printf("Reverting to previous Play/Pause state\n"); printf("Reverting to previous Play/Pause state\n");
m_state = m_prevState; m_state = m_prevState;
// Show that we are no longer fast forwarding
m_fwd->setStuckSelection(false);
} }
else else
{ {
printf("Fast forwarding...\n"); printf("Fast forwarding...\n");
m_state = MPLAYER_FFORWARD; m_state = MPLAYER_FFORWARD;
} }
// In any case, we are certainly no longer rewinding
m_rew->setStuckSelection(false);
} }
if (m_volume->isClicked()) if (m_volume->isClicked())