47 lines
1.5 KiB
C
47 lines
1.5 KiB
C
#ifndef PERSONAL_PLAYER_H
|
|
#define PERSONAL_PLAYER_H
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct Player Player;
|
|
typedef enum PlayerStatus {
|
|
PLAYER_EMPTY, PLAYER_OPENING, PLAYER_PAUSED, PLAYER_PLAYING,
|
|
PLAYER_ENDED, PLAYER_ERROR
|
|
} PlayerStatus;
|
|
typedef struct PlayerState {
|
|
PlayerStatus status;
|
|
double position;
|
|
double duration;
|
|
bool has_audio;
|
|
bool has_video;
|
|
// Display width / height, including sample aspect ratio; zero without video.
|
|
double video_aspect_ratio;
|
|
uint64_t revision;
|
|
char error[512];
|
|
} PlayerState;
|
|
|
|
// Playback commands are asynchronous. False means invalid input or a full command queue.
|
|
// Paths are copied before returning. All other calls require a live handle.
|
|
Player *player_create(void);
|
|
bool player_open(Player *player, const char *path);
|
|
bool player_play(Player *player);
|
|
bool player_pause(Player *player);
|
|
bool player_seek(Player *player, double seconds);
|
|
bool player_close(Player *player);
|
|
// Synchronous, thread-safe gain; survives open, seek, and close. Zero mutes.
|
|
// Rejects null handles and non-finite/out-of-range values without changing gain.
|
|
bool player_set_volume(Player *player, float normalized0to1);
|
|
// Returns the target gain immediately; zero for a null handle.
|
|
float player_get_volume(Player *player);
|
|
PlayerState player_get_state(Player *player);
|
|
// Joins the worker and stops audio; never invoke from an audio callback.
|
|
void player_destroy(Player *player);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|