NxWM::CMediaPlayer: successive presses on fast forward or rewind button now increase the subsampling, wrapping back to 2X when the maximum of 16x is reached.
This commit is contained in:
parent
4353ca97b2
commit
af3ba4fb9a
@ -2,7 +2,9 @@
|
||||
* NxWidgets/nxwm/include/cmediaplayer.hxx
|
||||
*
|
||||
* Copyright (C) 2013 Ken Pettit. All rights reserved.
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Ken Pettit <pettitkd@gmail.com>
|
||||
* Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -93,8 +95,8 @@ namespace NxWM
|
||||
* STAGED | STAGED | STOPPED | PLAYING | X | X | X |
|
||||
* PLAYING | X | X | X | PAUSED |FFORWARD2 | REWIND2 |
|
||||
* PAUSED | STAGED | STOPPED | PLAYING | X |FFORWARD1 | REWIND1 |
|
||||
* FFORWARD1| X | X | PAUSED | X | PAUSED | REWIND1 |
|
||||
* REWIND1 | X | X | PAUSED | X |FFORWARD1 | PAUSED |
|
||||
* FFORWARD1| X | X | PAUSED | X |FFORWARD1 | REWIND1 |
|
||||
* REWIND1 | X | X | PAUSED | X |FFORWARD1 | REWIND1 |
|
||||
* FFORWARD2| X | X | X | PLAYING | PLAYING | REWIND1 |
|
||||
* REWIND2 | X | X | X | PLAYING |FFORWARD1 | PLAYING |
|
||||
* ---------+----------+----------+----------+----------+----------+----------+
|
||||
@ -152,11 +154,14 @@ namespace NxWM
|
||||
enum EMediaPlayerState m_prevState; /**< Media player previous state */
|
||||
enum EPendingRelease m_pending; /**< Pending image release event */
|
||||
NXWidgets::CNxString m_filePath; /**< The full path to the selected file */
|
||||
unsigned int m_fileIndex; /**< Last selected text box selection */
|
||||
int m_fileIndex; /**< Last selected text box selection */
|
||||
bool m_fileReady; /**< True: Ready to play */
|
||||
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
||||
uint8_t m_level; /**< Current volume level, range 0-100 */
|
||||
#endif
|
||||
#ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD
|
||||
uint8_t m_subSample; /**< Current FFFORWARD subsampling */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Media player geometry.
|
||||
|
@ -136,6 +136,9 @@ CMediaPlayer::CMediaPlayer(CTaskbar *taskbar, CApplicationWindow *window)
|
||||
m_fileIndex = -1;
|
||||
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
||||
m_level = 0;
|
||||
#endif
|
||||
#ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD
|
||||
m_subSample = AUDIO_SUBSAMPLE_NONE;
|
||||
#endif
|
||||
m_fileReady = false;
|
||||
|
||||
@ -1504,13 +1507,22 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
|
||||
|
||||
if (m_state == MPLAYER_FREWIND)
|
||||
{
|
||||
// Yes.. then revert to the previous play/pause state
|
||||
// REVISIT: Or just increase rewind speed?
|
||||
// Yes.. then just increase rewind rate (by specifying a
|
||||
// higher level of sub-sampling)
|
||||
|
||||
int ret = nxplayer_cancel_motion(m_player, m_prevState == MPLAYER_PAUSED);
|
||||
if (m_subSample >= AUDIO_SUBSAMPLE_MAX)
|
||||
{
|
||||
m_subSample = AUDIO_SUBSAMPLE_MIN;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_subSample++;
|
||||
}
|
||||
|
||||
int ret = nxplayer_rewind(m_player, m_subSample);
|
||||
if (ret < 0)
|
||||
{
|
||||
dbg("ERROR: nxplayer_cancel_motion failed: %d\n", ret);
|
||||
dbg("ERROR: nxplayer_rewind failed: %d\n", ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1522,9 +1534,11 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
|
||||
|
||||
else if (m_state != MPLAYER_STOPPED && m_state != MPLAYER_STAGED)
|
||||
{
|
||||
// Start rewinding
|
||||
// Start rewinding at the minimum rate
|
||||
|
||||
int ret = nxplayer_rewind(m_player, SUBSAMPLE_4X);
|
||||
m_subSample = AUDIO_SUBSAMPLE_MIN;
|
||||
|
||||
int ret = nxplayer_rewind(m_player, m_subSample);
|
||||
if (ret < 0)
|
||||
{
|
||||
dbg("ERROR: nxplayer_rewind failed: %d\n", ret);
|
||||
@ -1546,17 +1560,22 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
|
||||
|
||||
if (m_state == MPLAYER_FFORWARD)
|
||||
{
|
||||
// Yes.. then revert to the previous play/pause state
|
||||
// REVISIT: Or just increase fast forward speed?
|
||||
// Yes.. then just increase fast forward rate (by specifying a
|
||||
// level level of sub-sampling)
|
||||
|
||||
int ret = nxplayer_cancel_motion(m_player, m_prevState == MPLAYER_PAUSED);
|
||||
if (ret < 0)
|
||||
if (m_subSample >= AUDIO_SUBSAMPLE_MAX)
|
||||
{
|
||||
dbg("ERROR: nxplayer_cancel_motion failed: %d\n", ret);
|
||||
m_subSample = AUDIO_SUBSAMPLE_MIN;
|
||||
}
|
||||
else
|
||||
{
|
||||
setMediaPlayerState(m_prevState);
|
||||
m_subSample++;
|
||||
}
|
||||
|
||||
int ret = nxplayer_fforward(m_player, m_subSample);
|
||||
if (ret < 0)
|
||||
{
|
||||
dbg("ERROR: nxplayer_fforward failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1564,9 +1583,11 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
|
||||
|
||||
else if (m_state != MPLAYER_STOPPED && m_state != MPLAYER_STAGED)
|
||||
{
|
||||
// Start fast forwarding
|
||||
// Start fast forwarding at the minimum rate
|
||||
|
||||
int ret = nxplayer_fforward(m_player, SUBSAMPLE_4X);
|
||||
m_subSample = AUDIO_SUBSAMPLE_MIN;
|
||||
|
||||
int ret = nxplayer_fforward(m_player, m_subSample);
|
||||
if (ret < 0)
|
||||
{
|
||||
dbg("ERROR: nxplayer_fforward failed: %d\n", ret);
|
||||
@ -1663,6 +1684,8 @@ void CMediaPlayer::handleReleaseEvent(const NXWidgets::CWidgetEventArgs &e)
|
||||
// In these states, stop the fast motion action and return to the
|
||||
// previous state
|
||||
|
||||
m_subSample = AUDIO_SUBSAMPLE_NONE;
|
||||
|
||||
int ret = nxplayer_cancel_motion(m_player, m_prevState == MPLAYER_PAUSED);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -1714,6 +1737,8 @@ void CMediaPlayer::handleReleaseEvent(const NXWidgets::CWidgetEventArgs &e)
|
||||
// Otherwise, we must be fast forwarding or rewinding. In these
|
||||
// cases, stop the action and return to the previous state
|
||||
|
||||
m_subSample = AUDIO_SUBSAMPLE_NONE;
|
||||
|
||||
int ret = nxplayer_cancel_motion(m_player, m_prevState == MPLAYER_PAUSED);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user