Hi!
I'm attempting to write a component that updates a status with my currently playing song, and I want it to mention when I'm paused or just not say anything when the song is stopped. However, even with just a single console::printf statement in on_playback_pause, nothing ever gets printed to the console. on_playback_new_track works just fine, however on_playback_pause and on_playback_stop don't. My playback_handler code is here:
class playback_handler : public play_callback_static {
char* curr_song = new char[1024];
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) {
update_song("");
}
void on_playback_seek(double p_time) {}
void on_playback_time(double p_time) {}
void on_playback_pause(bool p_state) {
char buff[1024];
snprintf(buff, sizeof(buff), "🎵 Paused: %s 🎵", curr_song);
console::printf("%s", buff);
update_song(buff);
}
void on_playback_edited(metadb_handle_ptr p_track) {}
void on_playback_dynamic_info(const file_info& p_info) {}
void on_playback_dynamic_info_track(const file_info& p_info) {}
void on_volume_change(float p_new_val) {}
unsigned get_flags() { return flag_on_playback_new_track; }
void on_playback_new_track(metadb_handle_ptr p_track) {
file_info_impl info;
p_track->get_info(info);
snprintf(curr_song, 1024, "%s by %s", info.meta_get("Title", 0), info.meta_get("Artist", 0));
char buff[1024];
snprintf(buff, sizeof(buff), "🎵 Listening To: %s 🎵", curr_song);
console::printf("%s", buff);
update_song(buff);
}
};
static play_callback_static_factory_t<playback_handler> foo_playback;