From 37317ad77cc8f1373007a2ff57aec7ee8880029c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 27 Jul 2014 10:46:00 -0600 Subject: NxWM::CMediaPlayer: Need to remember last text box selection or else each new Value Change event from the volume slider is confused with a new file selection --- NxWidgets/nxwm/include/cmediaplayer.hxx | 1 + NxWidgets/nxwm/src/cmediaplayer.cxx | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/NxWidgets/nxwm/include/cmediaplayer.hxx b/NxWidgets/nxwm/include/cmediaplayer.hxx index 1b9b98a66..ea1133f98 100644 --- a/NxWidgets/nxwm/include/cmediaplayer.hxx +++ b/NxWidgets/nxwm/include/cmediaplayer.hxx @@ -152,6 +152,7 @@ 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 */ bool m_fileReady; /**< True: Ready to play */ #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME uint8_t m_level; /**< Current volume level, range 0-100 */ diff --git a/NxWidgets/nxwm/src/cmediaplayer.cxx b/NxWidgets/nxwm/src/cmediaplayer.cxx index b43139f79..cd76e5a9c 100644 --- a/NxWidgets/nxwm/src/cmediaplayer.cxx +++ b/NxWidgets/nxwm/src/cmediaplayer.cxx @@ -133,6 +133,7 @@ CMediaPlayer::CMediaPlayer(CTaskbar *taskbar, CApplicationWindow *window) m_state = MPLAYER_STOPPED; m_prevState = MPLAYER_STOPPED; m_pending = PENDING_NONE; + m_fileIndex = -1; #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME m_level = 0; #endif @@ -1401,6 +1402,7 @@ void CMediaPlayer::checkFileSelection(void) // No file is selected m_fileReady = false; + m_fileIndex = -1; // Nothing is selected.. If we are not stopped, then stop now @@ -1417,8 +1419,16 @@ void CMediaPlayer::checkFileSelection(void) setMediaPlayerState(MPLAYER_STOPPED); } } - else + + // Ignore the file selection if it is the same file that was selected + // last time. + + else if (newFileIndex != m_fileIndex) { + // Remember the file selection + + m_fileIndex = newFileIndex; + // A media file is selected. Were we in a STOPPED state before? // Make sure that we are not already playing. Should be okay if // are in a STOPPED or STAGED state. We are not really playing -- cgit v1.2.3