foobar2000 SDK  2015-01-14
playback_control.h
Go to the documentation of this file.
1 class NOVTABLE playback_control : public service_base {
6  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(playback_control);
7 public:
8 
9  // Playback stop reason enum.
11  stop_reason_user = 0,
15  };
16 
17  // Playback start mode enum.
19  track_command_default = 0,
29 
32  };
33 
36  virtual bool get_now_playing(metadb_handle_ptr & p_out) = 0;
40  virtual void start(t_track_command p_command = track_command_play,bool p_paused = false) = 0;
42  virtual void stop() = 0;
44  virtual bool is_playing() = 0;
46  virtual bool is_paused() = 0;
49  virtual void pause(bool p_state) = 0;
50 
52  virtual bool get_stop_after_current() = 0;
54  virtual void set_stop_after_current(bool p_state) = 0;
55 
58  virtual void set_volume(float p_value) = 0;
61  virtual float get_volume() = 0;
63  virtual void volume_up() = 0;
65  virtual void volume_down() = 0;
67  virtual void volume_mute_toggle() = 0;
70  virtual void playback_seek(double p_time) = 0;
73  virtual void playback_seek_delta(double p_delta) = 0;
75  virtual bool playback_can_seek() = 0;
77  virtual double playback_get_position() = 0;
78 
89  };
90 
98  virtual bool playback_format_title(titleformat_hook * p_hook,pfc::string_base & p_out,const service_ptr_t<class titleformat_object> & p_script,titleformat_text_filter * p_filter,t_display_level p_level) = 0;
99 
100 
101 
104  if (p_item.is_empty()) return playback_format_title(p_hook,p_out,p_script,p_filter,p_level);
105  metadb_handle_ptr temp;
106  if (get_now_playing(temp)) {
107  if (temp == p_item) {
108  return playback_format_title(p_hook,p_out,p_script,p_filter,p_level);
109  }
110  }
111  p_item->format_title(p_hook,p_out,p_script,p_filter);
112  return true;
113  }
114 
116  double playback_get_length();
117  // Extended version: queries dynamic track info for the rare cases where that is different from static info.
118  double playback_get_length_ex();
119 
121  void toggle_stop_after_current() {set_stop_after_current(!get_stop_after_current());}
123  void toggle_pause() {pause(!is_paused());}
124 
126  void play_or_pause() {if (is_playing()) toggle_pause(); else start();}
127  void play_or_unpause() { if (is_playing()) pause(false); else start();}
128 
129  void previous() { start(track_command_prev); }
130  void next() { start(track_command_next); }
131 
132  //deprecated
133  inline void play_start(t_track_command p_command = track_command_play,bool p_paused = false) {start(p_command,p_paused);}
134  //deprecated
135  inline void play_stop() {stop();}
136 
137  bool is_muted() {return get_volume() == volume_mute;}
138 
139  static const int volume_mute = -100;
140 };
141 
144 public:
146  virtual float get_volume_step() = 0;
147 };
148 
152 public:
160  virtual bool custom_volume_is_active() = 0;
163  virtual int custom_volume_get() = 0;
167  virtual void custom_volume_set(int val) = 0;
169  virtual int custom_volume_min() = 0;
171  virtual int custom_volume_max() = 0;
172 
173  virtual void restart() = 0;
174 };
175 
176 //for compatibility with old code
virtual int custom_volume_min()=0
Returns the minimum custom volume value for the current output device.
display_level_basic + dynamic track titles on e.g. live streams
For internal use only, do not use.
void toggle_stop_after_current()
Toggles stop-after-current state.
virtual int custom_volume_max()=0
Returns the maximum custom volume value for the current output device.
bool is_empty() const
Definition: service.h:120
void toggle_pause()
Toggles pause state.
Plays the next track from the current playlist according to the current playback order.
virtual void custom_volume_set(int val)=0
Sets the current volume value for the custom volume mode. The volume units are arbitrary and specifi...
display_level_titles + timing + VBR bitrate display etc
FB2K_MAKE_SERVICE_INTERFACE(playback_control_v3, playback_control_v2)
Provides control for various playback-related operations. All methods provided by this interface work...
void play_start(t_track_command p_command=track_command_play, bool p_paused=false)
virtual void restart()=0
virtual float get_volume_step()=0
Returns user-specified the step dB value for volume decrement/increment.
For internal use only, do not use.
Static info and is_playing/is_paused stats.
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333
t_display_level
Type used to indicate level of dynamic playback-related info displayed. Safe to use with <> opereator...
bool playback_format_title_ex(metadb_handle_ptr p_item, titleformat_hook *p_hook, pfc::string_base &p_out, const service_ptr_t< class titleformat_object > &p_script, titleformat_text_filter *p_filter, t_display_level p_level)
Helper; renders info about any item, including currently playing item info if the item is currently p...
playback_control play_control
virtual bool custom_volume_is_active()=0
Custom volume API - for use with specific output devices only. Note that custom volume SHOULD NOT EV...
No playback-related info.
FB2K_MAKE_SERVICE_INTERFACE(playback_control_v2, playback_control)
void play_or_pause()
Starts playback if playback is inactive, otherwise toggles pause.
virtual int custom_volume_get()=0
Retrieves the current volume value for the custom volume mode. The volume units are arbitrary and sp...
Plays a random track from the current playlist.
Plays the previous track from the current playlist according to the current playback order...