text/plain
•
1.64 KB
•
57 lines
#pragma once
#include <stdbool.h>
#include <stdint.h>
typedef enum {
AUDIO_STATE_STOPPED,
AUDIO_STATE_PLAYING,
AUDIO_STATE_PAUSED,
AUDIO_STATE_ERROR,
} audio_state_t;
// Initialize the audio player subsystem
// Must be called before any other audio_player functions
bool audio_player_init(void);
// Start playing an audio file
// path: Path to the audio file (relative to storage root)
// Returns true on success, false on failure
bool audio_player_play(const char *path);
// Stop playback completely
void audio_player_stop(void);
// Pause playback (can be resumed)
void audio_player_pause(void);
// Resume paused playback
void audio_player_resume(void);
// Get current playback state
audio_state_t audio_player_get_state(void);
// Set playback volume (0-100)
void audio_player_set_volume(uint8_t volume);
// Get current filename being played (or NULL if stopped)
const char *audio_player_get_filename(void);
// Get display title: "Artist - Title" if metadata available, otherwise filename
const char *audio_player_get_title(void);
// Update function - call from main loop
// Required for platforms that need polling
void audio_player_update(void);
// Get current playback position in milliseconds (accurate, based on PCM output)
uint32_t audio_player_get_position_ms(void);
// Get total duration in milliseconds (estimated from file size and bitrate)
uint32_t audio_player_get_duration_ms(void);
// Get progress as percentage 0-100 (accurate, based on file byte position)
uint8_t audio_player_get_progress(void);
// Seek to a position in milliseconds
// Returns true on success, false if seek is not supported
bool audio_player_seek_ms(uint32_t position_ms);