foobar2000 SDK  2015-08-03
Public Types | Public Member Functions | Data Fields
CPlaybackStateDemo
+ Inheritance diagram for CPlaybackStateDemo:

Public Types

enum  { IDD = IDD_PLAYBACK_STATE }
 

Public Member Functions

 BEGIN_MSG_MAP (CPlaybackStateDemo) MSG_WM_INITDIALOG(OnInitDialog) COMMAND_HANDLER_EX(IDC_PATTERN
 
OnPatternChange COMMAND_HANDLER_EX (IDCANCEL, BN_CLICKED, OnCancel) COMMAND_HANDLER_EX(IDC_PLAY
 
OnPatternChange OnPlayClicked COMMAND_HANDLER_EX (IDC_PAUSE, BN_CLICKED, OnPauseClicked) COMMAND_HANDLER_EX(IDC_STOP
 
OnPatternChange OnPlayClicked OnStopClicked COMMAND_HANDLER_EX (IDC_PREV, BN_CLICKED, OnPrevClicked) COMMAND_HANDLER_EX(IDC_NEXT
 
OnPatternChange OnPlayClicked OnStopClicked OnNextClicked COMMAND_HANDLER_EX (IDC_RAND, BN_CLICKED, OnRandClicked) MSG_WM_CONTEXTMENU(OnContextMenu) END_MSG_MAP() private
 
void on_playback_dynamic_info (const file_info &p_info)
 
void on_playback_dynamic_info_track (const file_info &p_info)
 
void on_playback_edited (metadb_handle_ptr p_track)
 
void on_playback_new_track (metadb_handle_ptr p_track)
 
void on_playback_pause (bool p_state)
 
void on_playback_seek (double p_time)
 
void on_playback_stop (play_control::t_stop_reason p_reason)
 
void on_playback_time (double p_time)
 
void on_volume_change (float p_new_val)
 
void OnCancel (UINT, int, CWindow)
 
void OnContextMenu (CWindow wnd, CPoint point)
 
BOOL OnInitDialog (CWindow, LPARAM)
 
void OnNextClicked (UINT, int, CWindow)
 
void OnPatternChange (UINT, int, CWindow)
 
void OnPauseClicked (UINT, int, CWindow)
 
void OnPlayClicked (UINT, int, CWindow)
 
void OnPrevClicked (UINT, int, CWindow)
 
void OnRandClicked (UINT, int, CWindow)
 
void OnStopClicked (UINT, int, CWindow)
 
void update ()
 

Data Fields

OnPatternChange BN_CLICKED
 
OnPatternChange OnPlayClicked BN_CLICKED
 
OnPatternChange OnPlayClicked OnStopClicked BN_CLICKED
 
 EN_CHANGE
 
static_api_ptr_t< playback_controlm_playback_control
 
titleformat_object::ptr m_script
 

Additional Inherited Members

- Private Types inherited from play_callback
enum  {
  flag_on_playback_starting = 1 << 0, flag_on_playback_new_track = 1 << 1, flag_on_playback_stop = 1 << 2, flag_on_playback_seek = 1 << 3,
  flag_on_playback_pause = 1 << 4, flag_on_playback_edited = 1 << 5, flag_on_playback_dynamic_info = 1 << 6, flag_on_playback_dynamic_info_track = 1 << 7,
  flag_on_playback_time = 1 << 8, flag_on_volume_change = 1 << 9, flag_on_playback_all
}
 
- Private Member Functions inherited from play_callback_impl_base
 play_callback_impl_base (unsigned p_flags=~0)
 
 ~play_callback_impl_base ()
 
void on_playback_dynamic_info (const file_info &p_info)
 
void on_playback_dynamic_info_track (const file_info &p_info)
 
void on_playback_edited (metadb_handle_ptr p_track)
 
void on_playback_new_track (metadb_handle_ptr p_track)
 
void on_playback_pause (bool p_state)
 
void on_playback_seek (double p_time)
 
void on_playback_starting (play_control::t_track_command p_command, bool p_paused)
 
void on_playback_stop (play_control::t_stop_reason p_reason)
 
void on_playback_time (double p_time)
 
void on_volume_change (float p_new_val)
 
void play_callback_reregister (unsigned flags, bool refresh=false)
 
 play_callback ()
 
 ~play_callback ()
 

Detailed Description

Definition at line 4 of file playback_state.cpp.

Member Enumeration Documentation

anonymous enum
Enumerator
IDD 

Definition at line 6 of file playback_state.cpp.

6 {IDD = IDD_PLAYBACK_STATE};

Member Function Documentation

CPlaybackStateDemo::BEGIN_MSG_MAP ( CPlaybackStateDemo  )
OnPatternChange CPlaybackStateDemo::COMMAND_HANDLER_EX ( IDCANCEL  ,
BN_CLICKED  ,
OnCancel   
)
OnPatternChange OnPlayClicked CPlaybackStateDemo::COMMAND_HANDLER_EX ( IDC_PAUSE  ,
BN_CLICKED  ,
OnPauseClicked   
)
OnPatternChange OnPlayClicked OnStopClicked CPlaybackStateDemo::COMMAND_HANDLER_EX ( IDC_PREV  ,
BN_CLICKED  ,
OnPrevClicked   
)
OnPatternChange OnPlayClicked OnStopClicked OnNextClicked CPlaybackStateDemo::COMMAND_HANDLER_EX ( IDC_RAND  ,
BN_CLICKED  ,
OnRandClicked   
)
inline

Definition at line 17 of file playback_state.cpp.

20  :
21 
22  // Playback callback methods.
23  void on_playback_starting(play_control::t_track_command p_command,bool p_paused) {update();}
void on_playback_starting(play_control::t_track_command p_command, bool p_paused)
Playback process is being initialized. on_playback_new_track() should be called soon after this when ...
Definition: play_callback.h:83
void CPlaybackStateDemo::on_playback_dynamic_info ( const file_info p_info)
inlinevirtual

Dynamic info (VBR bitrate etc) change.

Implements play_callback.

Definition at line 29 of file playback_state.cpp.

29 {update();}
void CPlaybackStateDemo::on_playback_dynamic_info_track ( const file_info p_info)
inlinevirtual

Per-track dynamic info (stream track titles etc) change. Happens less often than on_playback_dynamic_info().

Implements play_callback.

Definition at line 30 of file playback_state.cpp.

30 {update();}
void CPlaybackStateDemo::on_playback_edited ( metadb_handle_ptr  p_track)
inlinevirtual

Called when currently played file gets edited.

Implements play_callback.

Definition at line 28 of file playback_state.cpp.

28 {update();}
void CPlaybackStateDemo::on_playback_new_track ( metadb_handle_ptr  p_track)
inlinevirtual

Playback advanced to new track.

Implements play_callback.

Definition at line 24 of file playback_state.cpp.

24 {update();}
void CPlaybackStateDemo::on_playback_pause ( bool  p_state)
inlinevirtual

Called on pause/unpause.

Implements play_callback.

Definition at line 27 of file playback_state.cpp.

27 {update();}
void CPlaybackStateDemo::on_playback_seek ( double  p_time)
inlinevirtual

User has seeked to specific time.

Implements play_callback.

Definition at line 26 of file playback_state.cpp.

26 {update();}
void CPlaybackStateDemo::on_playback_stop ( play_control::t_stop_reason  p_reason)
inlinevirtual

Playback stopped.

Implements play_callback.

Definition at line 25 of file playback_state.cpp.

25 {update();}
void CPlaybackStateDemo::on_playback_time ( double  p_time)
inlinevirtual

Called every second, for time display.

Implements play_callback.

Definition at line 31 of file playback_state.cpp.

31 {update();}
void CPlaybackStateDemo::on_volume_change ( float  p_new_val)
inlinevirtual

User changed volume settings. Possibly called when not playing.

Parameters
p_new_valnew volume level in dB; 0 for full volume.

Implements play_callback.

Definition at line 32 of file playback_state.cpp.

32 {}
void CPlaybackStateDemo::OnCancel ( UINT  ,
int  ,
CWindow   
)

Definition at line 55 of file playback_state.cpp.

55  {
56  DestroyWindow();
57 }
void CPlaybackStateDemo::OnContextMenu ( CWindow  wnd,
CPoint  point 
)

Definition at line 89 of file playback_state.cpp.

89  {
90  try {
91  if (wnd == GetDlgItem(IDC_CONTEXTMENU)) {
92 
93  // handle the context menu key case - center the menu
94  if (point == CPoint(-1, -1)) {
95  CRect rc;
96  WIN32_OP(wnd.GetWindowRect(&rc));
97  point = rc.CenterPoint();
98  }
99 
100  metadb_handle_list items;
101 
102  { // note: we would normally just use contextmenu_manager::init_context_now_playing(), but we go the "make the list ourselves" route to demonstrate how to invoke the menu for arbitrary items.
103  metadb_handle_ptr item;
104  if (m_playback_control->get_now_playing(item)) items += item;
105  }
106 
107  CMenuDescriptionHybrid menudesc(*this); //this class manages all the voodoo necessary for descriptions of our menu items to show in the status bar.
108 
110  CMenu menu;
111  WIN32_OP(menu.CreatePopupMenu());
112  enum {
113  ID_TESTCMD = 1,
114  ID_CM_BASE,
115  };
116  menu.AppendMenu(MF_STRING, ID_TESTCMD, _T("Test command"));
117  menudesc.Set(ID_TESTCMD, "This is a test command.");
118  menu.AppendMenu(MF_SEPARATOR);
119 
120  if (items.get_count() > 0) {
121  api->init_context(items, 0);
122  api->win32_build_menu(menu, ID_CM_BASE, ~0);
123  menudesc.SetCM(api.get_ptr(), ID_CM_BASE, ~0);
124  } else {
125  menu.AppendMenu(MF_STRING|MF_GRAYED|MF_DISABLED, (UINT)0, _T("No items selected"));
126  }
127 
128  int cmd = menu.TrackPopupMenu(TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,point.x,point.y,menudesc,0);
129  if (cmd > 0) {
130  if (cmd >= ID_CM_BASE) {
131  api->execute_by_id(cmd - ID_CM_BASE);
132  } else switch(cmd) {
133  case ID_TESTCMD:
134  popup_message::g_show("Blah!", "Test");
135  break;
136  }
137  }
138 
139  }
140  } catch(std::exception const & e) {
141  console::complain("Context menu failure", e); //rare
142  }
143 }
t_interface * get_ptr() const
Definition: service.h:541
static_api_ptr_t< playback_control > m_playback_control
t_size get_count() const
Definition: list.h:365
void complain(const char *what, const char *msg)
Definition: console.cpp:21
static void g_show(const char *p_msg, const char *p_title, t_icon p_icon=icon_information)
Static helper function instantiating the service and activating the message dialog. See show() for description of parameters.
Definition: popup_message.h:26
std::exception exception
Definition: primitives.h:193
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
Definition: service.h:533
BOOL CPlaybackStateDemo::OnInitDialog ( CWindow  ,
LPARAM   
)

Definition at line 64 of file playback_state.cpp.

64  {
65  update();
66  SetDlgItemText(IDC_PATTERN, _T("%codec% | %bitrate% kbps | %samplerate% Hz | %channels% | %playback_time%[ / %length%]$if(%ispaused%, | paused,)"));
67  ::ShowWindowCentered(*this,GetParent()); // Function declared in SDK helpers.
68  return TRUE;
69 }
static BOOL ShowWindowCentered(CWindow wnd, CWindow wndParent)
void CPlaybackStateDemo::OnNextClicked ( UINT  ,
int  ,
CWindow   
)
inline

Definition at line 43 of file playback_state.cpp.

static_api_ptr_t< playback_control > m_playback_control
Plays the next track from the current playlist according to the current playback order.
void CPlaybackStateDemo::OnPatternChange ( UINT  ,
int  ,
CWindow   
)

Definition at line 59 of file playback_state.cpp.

59  {
60  m_script.release(); // pattern has changed, force script recompilation
61  update();
62 }
titleformat_object::ptr m_script
void CPlaybackStateDemo::OnPauseClicked ( UINT  ,
int  ,
CWindow   
)
inline

Definition at line 41 of file playback_state.cpp.

41 {m_playback_control->toggle_pause();}
static_api_ptr_t< playback_control > m_playback_control
void CPlaybackStateDemo::OnPlayClicked ( UINT  ,
int  ,
CWindow   
)
inline

Definition at line 39 of file playback_state.cpp.

39 {m_playback_control->start();}
static_api_ptr_t< playback_control > m_playback_control
void CPlaybackStateDemo::OnPrevClicked ( UINT  ,
int  ,
CWindow   
)
inline

Definition at line 42 of file playback_state.cpp.

static_api_ptr_t< playback_control > m_playback_control
Plays the previous track from the current playlist according to the current playback order...
void CPlaybackStateDemo::OnRandClicked ( UINT  ,
int  ,
CWindow   
)
inline

Definition at line 44 of file playback_state.cpp.

static_api_ptr_t< playback_control > m_playback_control
Plays a random track from the current playlist.
void CPlaybackStateDemo::OnStopClicked ( UINT  ,
int  ,
CWindow   
)
inline

Definition at line 40 of file playback_state.cpp.

40 {m_playback_control->stop();}
static_api_ptr_t< playback_control > m_playback_control
void CPlaybackStateDemo::update ( )

Definition at line 71 of file playback_state.cpp.

71  {
72  if (m_script.is_empty()) {
73  pfc::string8 pattern;
74  uGetDlgItemText(*this, IDC_PATTERN, pattern);
75  static_api_ptr_t<titleformat_compiler>()->compile_safe_ex(m_script, pattern);
76  }
78  if (m_playback_control->playback_format_title(NULL, state, m_script, NULL, playback_control::display_level_all)) {
79  //Succeeded already.
80  } else if (m_playback_control->is_playing()) {
81  //Starting playback but not done opening the first track yet.
82  state = "Opening...";
83  } else {
84  state = "Stopped.";
85  }
86  uSetDlgItemText(*this, IDC_STATE, state);
87 }
BOOL SHARED_EXPORT uSetDlgItemText(HWND wnd, UINT id, const char *p_text)
static_api_ptr_t< playback_control > m_playback_control
BOOL SHARED_EXPORT uGetDlgItemText(HWND wnd, UINT id, pfc::string_base &out)
display_level_titles + timing + VBR bitrate display etc
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
Definition: service.h:533
titleformat_object::ptr m_script

Field Documentation

OnPatternChange CPlaybackStateDemo::BN_CLICKED

Definition at line 12 of file playback_state.cpp.

OnPatternChange OnPlayClicked CPlaybackStateDemo::BN_CLICKED

Definition at line 14 of file playback_state.cpp.

OnPatternChange OnPlayClicked OnStopClicked CPlaybackStateDemo::BN_CLICKED

Definition at line 16 of file playback_state.cpp.

CPlaybackStateDemo::EN_CHANGE

Definition at line 10 of file playback_state.cpp.

static_api_ptr_t<playback_control> CPlaybackStateDemo::m_playback_control

Definition at line 52 of file playback_state.cpp.

titleformat_object::ptr CPlaybackStateDemo::m_script

Definition at line 50 of file playback_state.cpp.


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