NXWidgets: NxWM::CMediaPlayer Class Reference

NXWidgets 1.19

Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
NxWM::CMediaPlayer Class Reference

`#include <cmediaplayer.hxx>`

Inheritance diagram for NxWM::CMediaPlayer:

## Classes
struct | SPendingOperation

## Public Member Functions
| CMediaPlayer (CTaskbar *taskbar, CApplicationWindow *window)
| ~CMediaPlayer (void)
IApplicationWindow * | getWindow (void) const
NXWidgets::IBitmap * | getIcon (void)
NXWidgets::CNxString | getName (void)
bool | run (void)
void | stop (void)
void | destroy (void)
void | hide (void)
void | redraw (void)
bool | isFullScreen (void) const
Public Member Functions inherited from NxWM::IApplication
virtual | ~IApplication (void)
void | setMinimized (bool minimized)
void | setTopApplication (bool topapp)
bool | isMinimized (void) const
bool | isTopApplication (void) const

## Private Types
enum | EMediaPlayerState { MPLAYER_STOPPED = 0, MPLAYER_STAGED, MPLAYER_PLAYING, MPLAYER_PAUSED, MPLAYER_FFORWARD, MPLAYER_FREWIND }
enum | EPendingRelease { PENDING_NONE = 0, PENDING_PLAY_RELEASE, PENDING_PAUSE_RELEASE }

## Private Member Functions
bool | getMediaFile (const NXWidgets::CListBoxDataItem *item)
bool | openMediaFile (const NXWidgets::CListBoxDataItem *item)
void | stopPlaying (void)
void | setGeometry (void)
bool | showMediaFiles (FAR const char *mediaPath)
bool | setDevice (FAR const char *devPath)
bool | configureNxPlayer (void)
bool | createPlayer (void)
void | minimize (void)
void | close (void)
void | redrawWidgets (void)
void | setMediaPlayerState (enum EMediaPlayerState state)
void | setVolumeLevel (void)
void | checkFileSelection (void)
void | updateMotionIndicator (void)
void | handleActionEvent (const NXWidgets::CWidgetEventArgs &e)
void | handleReleaseEvent (const NXWidgets::CWidgetEventArgs &e)
void | handleReleaseOutsideEvent (const NXWidgets::CWidgetEventArgs &e)
void | handleValueChangeEvent (const NXWidgets::CWidgetEventArgs &e)
Private Member Functions inherited from NXWidgets::CWidgetEventHandler
| CWidgetEventHandler ()
virtual | ~CWidgetEventHandler ()
virtual void | handleClickEvent (const CWidgetEventArgs &e)
virtual void | handleDragEvent (const CWidgetEventArgs &e)
virtual void | handleDropEvent (const CWidgetEventArgs &e)
virtual void | handleKeyPressEvent (const CWidgetEventArgs &e)
virtual void | handleCursorControlEvent (const CWidgetEventArgs &e)
virtual void | handleFocusEvent (const CWidgetEventArgs &e)
virtual void | handleBlurEvent (const CWidgetEventArgs &e)
virtual void | handleCloseEvent (const CWidgetEventArgs &e)
virtual void | handleHideEvent (const CWidgetEventArgs &e)
virtual void | handleShowEvent (const CWidgetEventArgs &e)
virtual void | handleEnableEvent (const CWidgetEventArgs &e)
virtual void | handleDisableEvent (const CWidgetEventArgs &e)
virtual void | handleResizeEvent (const CWidgetEventArgs &e)
virtual void | handleMoveEvent (const CWidgetEventArgs &e)
virtual void | handleScrollEvent (const CWidgetEventArgs &e)
virtual void | handleDoubleClickEvent (const CWidgetEventArgs &e)

## Private Attributes
FAR struct nxplayer_s * | m_player
enum EMediaPlayerState | m_state
enum EMediaPlayerState | m_prevState
enum EPendingRelease | m_pending
NXWidgets::CNxString | m_filePath
int | m_fileIndex
bool | m_fileReady
uint8_t | m_level
uint8_t | m_subSample
struct nxgl_size_s | m_windowSize
CTaskbar * | m_taskbar
CApplicationWindow * | m_window
NXWidgets::CListBox * | m_listbox
NXWidgets::CNxFont * | m_font
NXWidgets::CImage * | m_play
NXWidgets::CImage * | m_pause
NXWidgets::CStickyImage * | m_rewind
NXWidgets::CStickyImage * | m_fforward
NXWidgets::CGlyphSliderHorizontal * | m_volume
NXWidgets::CLabel * | m_speed
NXWidgets::CRlePaletteBitmap * | m_playBitmap
NXWidgets::CRlePaletteBitmap * | m_pauseBitmap
NXWidgets::CRlePaletteBitmap * | m_rewindBitmap
NXWidgets::CRlePaletteBitmap * | m_fforwardBitmap
NXWidgets::CRlePaletteBitmap * | m_volumeBitmap

## Additional Inherited Members
Protected Attributes inherited from NxWM::IApplication
bool | m_minimized
bool | m_topapp

## Detailed Description

This class implements the CMediaPlayer application.

Definition at line 82 of file cmediaplayer.hxx.

## Member Enumeration Documentation

## ◆ EMediaPlayerState

enum NxWM::CMediaPlayer::EMediaPlayerState
| private

This enumeration identifies the state of the media player

                        State Transition Table

------—+-------—+-------—+-------—+-------—+-------—+-------—+ | FILE | FILE | | | FAST | | STATE | SELECTED |DESELECTED| PLAY | PAUSE | FORWARD | REWIND | ------—+-------—+-------—+-------—+-------—+-------—+-------—+ STOPPED | STAGED | X | X | X | X | X | 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 |FFORWARD1 | REWIND1 | REWIND1 | X | X | PAUSED | X |FFORWARD1 | REWIND1 | FFORWARD2| X | X | X | PLAYING | PLAYING | REWIND1 | REWIND2 | X | X | X | PLAYING |FFORWARD1 | PLAYING | ------—+-------—+-------—+-------—+-------—+-------—+-------—+

Configuration Dependencies. States in the above state transition table may not be supported if any of the following features are excluded from the configuration:

CONFIG_AUDIO_EXCLUDE_STOP CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME CONFIG_AUDIO_EXCLUDE_VOLUME CONFIG_AUDIO_EXCLUDE_FFORWARD CONFIG_AUDIO_EXCLUDE_REWIND

Enumerator
MPLAYER_STOPPED | No media file has been selected
MPLAYER_STAGED | Media file selected, not playing
MPLAYER_PLAYING | Playing a media file
MPLAYER_PAUSED | Playing a media file but paused
MPLAYER_FFORWARD | Fast forwarding through a media file
MPLAYER_FREWIND | Rewinding a media file

Definition at line 116 of file cmediaplayer.hxx.

## ◆ EPendingRelease

enum NxWM::CMediaPlayer::EPendingRelease
| private

Describes the state of an image touch. Some image touch cannot be processed until the image contact is lost. This enumeration arms and manages those cases.

Enumerator
PENDING_NONE | Nothing is pending
PENDING_PLAY_RELEASE | Expect play image to be released
PENDING_PAUSE_RELEASE | Expect pause image to be released

Definition at line 132 of file cmediaplayer.hxx.

## Constructor & Destructor Documentation

## ◆ CMediaPlayer()

CMediaPlayer::CMediaPlayer | ( | CTaskbar * | taskbar,
|  | CApplicationWindow * | window
| ) |  |

CMediaPlayer constructor

Parameters

  window. | The application window
  taskbar. | A pointer to the parent task bar instance
  window. | The window to be used by this application.

CMediaPlayer constructor

Parameters

  window. | The application window

Definition at line 113 of file cmediaplayer.cxx.

## ◆ ~CMediaPlayer()

CMediaPlayer::~CMediaPlayer | ( | void |  | ) |

CMediaPlayer destructor

CMediaPlayer destructor

Parameters

  window. | The application window

Definition at line 176 of file cmediaplayer.cxx.

## Member Function Documentation

## ◆ checkFileSelection()

void CMediaPlayer::checkFileSelection | ( | void |  | ) |
| inlineprivate

Check if a new file has been selected (or de-selected) in the list box

Definition at line 1454 of file cmediaplayer.cxx.

## ◆ close()

void CMediaPlayer::close | ( | void |  | ) |
| privatevirtual

Called when the window minimize close is pressed.

Called when the window close image is pressed.

Implements NxWM::IApplicationCallback.

Definition at line 1092 of file cmediaplayer.cxx.

## ◆ configureNxPlayer()

bool CMediaPlayer::configureNxPlayer | ( | void |  | ) |
| inlineprivate

Configure the NxPlayer.

Definition at line 691 of file cmediaplayer.cxx.

## ◆ createPlayer()

bool CMediaPlayer::createPlayer | ( | void |  | ) |
| inlineprivate

Create the Media Player controls. Only start as part of the application start method.

Create the media player widgets. Only start as part of the application start method.

Definition at line 720 of file cmediaplayer.cxx.

## ◆ destroy()

void CMediaPlayer::destroy | ( | void |  | ) |
| virtual

Destroy the application and free all of its resources. This method will initiate blocking of messages from the NX server. The server will flush the window message queue and reply with the blocked message. When the block message is received by CWindowMessenger, it will send the destroy message to the start window task which will, finally, safely delete the application.

Implements NxWM::IApplication.

Definition at line 360 of file cmediaplayer.cxx.

## ◆ getIcon()

NXWidgets::IBitmap * CMediaPlayer::getIcon | ( | void |  | ) |
| virtual

Get the icon associated with the application

Returns
  An instance if IBitmap that may be used to rend the application's icon. This is an new IBitmap instance that must be deleted by the caller when it is no long needed.

Implements NxWM::IApplication.

Definition at line 280 of file cmediaplayer.cxx.

## ◆ getMediaFile()

bool CMediaPlayer::getMediaFile | ( | const NXWidgets::CListBoxDataItem * | item | ) |
| private

Get the full media file path and make ready for playing. Called after a file has been selected from the list box.

Definition at line 427 of file cmediaplayer.cxx.

## ◆ getName()

NXWidgets::CNxString CMediaPlayer::getName | ( | void |  | ) |
| virtual

Get the name string associated with the application

Returns
  A copy if CNxString that contains the name of the application.

Implements NxWM::IApplication.

Definition at line 294 of file cmediaplayer.cxx.

## ◆ getWindow()

IApplicationWindow * CMediaPlayer::getWindow | ( | void |  | ) | const
| virtual

Each implementation of IApplication must provide a method to recover the contained CApplicationWindow instance.

Implements NxWM::IApplication.

Definition at line 267 of file cmediaplayer.cxx.

## ◆ handleActionEvent()

void CMediaPlayer::handleActionEvent | ( | const NXWidgets::CWidgetEventArgs & | e | ) |
| privatevirtual

Handle a widget action event. For this application, that means image pre-release events.

Parameters

  e | The event data.

Reimplemented from NXWidgets::CWidgetEventHandler.

Definition at line 1583 of file cmediaplayer.cxx.

## ◆ handleReleaseEvent()

void CMediaPlayer::handleReleaseEvent | ( | const NXWidgets::CWidgetEventArgs & | e | ) |
| privatevirtual

Handle a widget release event. Only the play and pause image release are of interest.

Reimplemented from NXWidgets::CWidgetEventHandler.

Definition at line 1718 of file cmediaplayer.cxx.

## ◆ handleReleaseOutsideEvent()

void CMediaPlayer::handleReleaseOutsideEvent | ( | const NXWidgets::CWidgetEventArgs & | e | ) |
| privatevirtual

Handle a widget release event when the widget WAS dragged outside of its original bounding box. Only the play and pause image release are of interest.

Reimplemented from NXWidgets::CWidgetEventHandler.

Definition at line 1875 of file cmediaplayer.cxx.

## ◆ handleValueChangeEvent()

void CMediaPlayer::handleValueChangeEvent | ( | const NXWidgets::CWidgetEventArgs & | e | ) |
| privatevirtual

Handle value changes. This will get events when there is a change in the volume level or a file is selected or deselected.

Reimplemented from NXWidgets::CWidgetEventHandler.

Definition at line 1885 of file cmediaplayer.cxx.

## ◆ hide()

void CMediaPlayer::hide | ( | void |  | ) |
| virtual

The application window is hidden (either it is minimized or it is maximized, but not at the top of the hierarchy

Implements NxWM::IApplication.

Definition at line 376 of file cmediaplayer.cxx.

## ◆ isFullScreen()

bool CMediaPlayer::isFullScreen | ( | void |  | ) | const
| virtual

Report of this is a "normal" window or a full screen window. The primary purpose of this method is so that window manager will know whether or not it show draw the task bar.

Returns
  True if this is a full screen window.

Implements NxWM::IApplication.

Definition at line 417 of file cmediaplayer.cxx.

## ◆ minimize()

void CMediaPlayer::minimize | ( | void |  | ) |
| privatevirtual

Called when the window minimize image is pressed.

Implements NxWM::IApplicationCallback.

Definition at line 1083 of file cmediaplayer.cxx.

## ◆ openMediaFile()

bool NxWM::CMediaPlayer::openMediaFile | ( | const NXWidgets::CListBoxDataItem * | item | ) |
| private

Get the full media file path and make ready for playing. Called after a file has been selected from the list box.

## ◆ redraw()

void CMediaPlayer::redraw | ( | void |  | ) |
| virtual

Redraw the entire window. The application has been maximized or otherwise moved to the top of the hierarchy. This method is call from CTaskbar when the application window must be displayed

Redraw the entire window. The application has been maximized or otherwise moved to the top of the hierarchy. This method is call from CTaskbar when the application window must be displayed.

Implements NxWM::IApplication.

Definition at line 389 of file cmediaplayer.cxx.

## ◆ redrawWidgets()

void CMediaPlayer::redrawWidgets | ( | void |  | ) |
| private

Redraw all widgets. Called from redraw() and also on any state change.

Parameters

  state | The new state to enter.

Definition at line 1104 of file cmediaplayer.cxx.

## ◆ run()

bool CMediaPlayer::run | ( | void |  | ) |
| virtual

Start the application (perhaps in the minimized state).

Returns
  True if the application was successfully started.

Implements NxWM::IApplication.

Definition at line 305 of file cmediaplayer.cxx.

## ◆ setDevice()

bool CMediaPlayer::setDevice | ( | FAR const char * | devPath | ) |
| inlineprivate

Set the preferred audio device for playback

Definition at line 634 of file cmediaplayer.cxx.

## ◆ setGeometry()

void CMediaPlayer::setGeometry | ( | void |  | ) |
| inlineprivate

Select the geometry of the media player given the current window size. Only called as part of construction.

Select the geometry of the media player given the current window size.

Definition at line 521 of file cmediaplayer.cxx.

## ◆ setMediaPlayerState()

void CMediaPlayer::setMediaPlayerState | ( | enum EMediaPlayerState | state | ) |
| private

Transition to a new media player state.

Parameters

  state | The new state to enter.

Definition at line 1157 of file cmediaplayer.cxx.

## ◆ setVolumeLevel()

void CMediaPlayer::setVolumeLevel | ( | void |  | ) |
| private

Set the new volume level based on the position of the volume slider.

Definition at line 1418 of file cmediaplayer.cxx.

## ◆ showMediaFiles()

bool CMediaPlayer::showMediaFiles | ( | FAR const char * | mediaPath | ) |
| inlineprivate

Load media files into the list box.

Definition at line 536 of file cmediaplayer.cxx.

## ◆ stop()

void CMediaPlayer::stop | ( | void |  | ) |
| virtual

Stop the application.

Implements NxWM::IApplication.

Definition at line 336 of file cmediaplayer.cxx.

## ◆ stopPlaying()

void CMediaPlayer::stopPlaying | ( | void |  | ) |
| private

Stop playing the current file. Called when a new media file is selected, when a media file is de-selected, or when destroying the media player instance.

Definition at line 499 of file cmediaplayer.cxx.

## ◆ updateMotionIndicator()

void CMediaPlayer::updateMotionIndicator | ( | void |  | ) |
| private

Update fast forward/rewind speed indicator. Called on each state change and after each change in the speed of motion.

Definition at line 1531 of file cmediaplayer.cxx.

## Member Data Documentation

## ◆ m_fforward

NXWidgets::CStickyImage* NxWM::CMediaPlayer::m_fforward
| private

Fast forward control

Definition at line 189 of file cmediaplayer.hxx.

## ◆ m_fforwardBitmap

NXWidgets::CRlePaletteBitmap* NxWM::CMediaPlayer::m_fforwardBitmap
| private

Bitmap for the fast forward control

Definition at line 205 of file cmediaplayer.hxx.

## ◆ m_fileIndex

int NxWM::CMediaPlayer::m_fileIndex
| private

Last selected text box selection

Definition at line 158 of file cmediaplayer.hxx.

## ◆ m_filePath

NXWidgets::CNxString NxWM::CMediaPlayer::m_filePath
| private

The full path to the selected file

Definition at line 157 of file cmediaplayer.hxx.

## ◆ m_fileReady

bool NxWM::CMediaPlayer::m_fileReady
| private

True: Ready to play

Definition at line 159 of file cmediaplayer.hxx.

## ◆ m_font

NXWidgets::CNxFont* NxWM::CMediaPlayer::m_font
| private

The font used in the media player

Definition at line 185 of file cmediaplayer.hxx.

## ◆ m_level

uint8_t NxWM::CMediaPlayer::m_level
| private

Current volume level, range 0-100

Definition at line 161 of file cmediaplayer.hxx.

## ◆ m_listbox

NXWidgets::CListBox* NxWM::CMediaPlayer::m_listbox
| private

WidgetsList box containing media files selections

Definition at line 184 of file cmediaplayer.hxx.

## ◆ m_pause

NXWidgets::CImage* NxWM::CMediaPlayer::m_pause
| private

Pause control

Definition at line 187 of file cmediaplayer.hxx.

## ◆ m_pauseBitmap

NXWidgets::CRlePaletteBitmap* NxWM::CMediaPlayer::m_pauseBitmap
| private

Bitmap for the pause control

Definition at line 203 of file cmediaplayer.hxx.

## ◆ m_pending

enum EPendingRelease NxWM::CMediaPlayer::m_pending
| private

Pending image release event

Definition at line 156 of file cmediaplayer.hxx.

## ◆ m_play

NXWidgets::CImage* NxWM::CMediaPlayer::m_play
| private

Play control

Definition at line 186 of file cmediaplayer.hxx.

## ◆ m_playBitmap

NXWidgets::CRlePaletteBitmap* NxWM::CMediaPlayer::m_playBitmap
| private

Bitmaps

These are retained only so that they can be released when the media is closed playerBitmap for the play control

Definition at line 202 of file cmediaplayer.hxx.

## ◆ m_player

FAR struct nxplayer_s* NxWM::CMediaPlayer::m_player
| private

Media player state data.NxPlayer handle

Definition at line 153 of file cmediaplayer.hxx.

## ◆ m_prevState

enum EMediaPlayerState NxWM::CMediaPlayer::m_prevState
| private

Media player previous state

Definition at line 155 of file cmediaplayer.hxx.

## ◆ m_rewind

NXWidgets::CStickyImage* NxWM::CMediaPlayer::m_rewind
| private

Rewind control

Definition at line 188 of file cmediaplayer.hxx.

## ◆ m_rewindBitmap

NXWidgets::CRlePaletteBitmap* NxWM::CMediaPlayer::m_rewindBitmap
| private

Bitmap for the rewind control

Definition at line 204 of file cmediaplayer.hxx.

## ◆ m_speed

NXWidgets::CLabel* NxWM::CMediaPlayer::m_speed
| private

FForward/rewind speed

Definition at line 192 of file cmediaplayer.hxx.

## ◆ m_state

enum EMediaPlayerState NxWM::CMediaPlayer::m_state
| private

Media player current state

Definition at line 154 of file cmediaplayer.hxx.

## ◆ m_subSample

uint8_t NxWM::CMediaPlayer::m_subSample
| private

Current FFFORWARD subsampling index

Definition at line 164 of file cmediaplayer.hxx.

## ◆ m_taskbar

CTaskbar* NxWM::CMediaPlayer::m_taskbar
| private

Cached constructor parameters.Reference to the "parent" taskbar

Definition at line 177 of file cmediaplayer.hxx.

## ◆ m_volume

NXWidgets::CGlyphSliderHorizontal* NxWM::CMediaPlayer::m_volume
| private

Volume control

Definition at line 190 of file cmediaplayer.hxx.

## ◆ m_volumeBitmap

NXWidgets::CRlePaletteBitmap* NxWM::CMediaPlayer::m_volumeBitmap
| private

Volume control grip bitmap

Definition at line 206 of file cmediaplayer.hxx.

## ◆ m_window

CApplicationWindow* NxWM::CMediaPlayer::m_window
| private

Reference to the application window

Definition at line 178 of file cmediaplayer.hxx.

## ◆ m_windowSize

struct nxgl_size_s NxWM::CMediaPlayer::m_windowSize
| private

Media player geometry.The size of the media player window

Definition at line 171 of file cmediaplayer.hxx.

The documentation for this class was generated from the following files:

- cmediaplayer.hxx
- cmediaplayer.cxx