#ifndef SMQ_H #define SMQ_H #include #include #ifdef __cplusplus extern "C" { #endif #if defined(_WIN32) || defined(__CYGWIN__) # ifdef SMQ_BUILD # define SMQ_API __declspec(dllexport) # else # define SMQ_API __declspec(dllimport) # endif #else # if defined(__GNUC__) || defined(__clang__) # define SMQ_API __attribute__((visibility("default"))) # else # define SMQ_API # endif #endif typedef struct smq_ctx smq_ctx; /* Repeat modes */ #define SMQ_REPEAT_OFF 0 #define SMQ_REPEAT_ALL 1 #define SMQ_REPEAT_ONE 2 /* Sleep timer modes */ #define SMQ_SLEEP_OFF 0 #define SMQ_SLEEP_COUNTDOWN 1 #define SMQ_SLEEP_END_OF_TRACK 2 /* Navigation return codes */ #define SMQ_NAV_PLAY_NEW 0 /* Start playing the new current track */ #define SMQ_NAV_STOP 1 /* Reached end of queue with repeat off */ #define SMQ_NAV_SEEK_ZERO 2 /* Stay on current track and seek to 0 */ #define SMQ_NAV_SLEEP_STOP 3 /* Sleep timer (end-of-track) fired: pause & reset to 0 */ #define SMQ_NAV_ERROR -1 SMQ_API const char *smq_version(void); SMQ_API int smq_abi_version(void); SMQ_API const char *smq_last_error(void); SMQ_API void smq_free(void *ptr); SMQ_API int smq_selftest(void); SMQ_API smq_ctx *smq_create(void); SMQ_API void smq_destroy(smq_ctx *ctx); /* Load a JSON array of track objects and select start_index (0-based). * Respects current shuffle flag (when shuffled, places selected track at index 0). */ SMQ_API int smq_set_tracks_json(smq_ctx *ctx, const char *tracks_json, int start_index, uint64_t seed); /* Insert a single track JSON object immediately after the current track (or start queue if empty). */ SMQ_API int smq_play_next_json(smq_ctx *ctx, const char *track_json); /* Append a single track JSON object to the end of the queue (or start queue if empty). */ SMQ_API int smq_add_to_queue_json(smq_ctx *ctx, const char *track_json); /* Explicit user Next / Previous / Track-ended / Jump commands. */ SMQ_API int smq_next(smq_ctx *ctx); SMQ_API int smq_on_track_ended(smq_ctx *ctx); SMQ_API int smq_previous(smq_ctx *ctx, double current_time_sec); SMQ_API int smq_jump(smq_ctx *ctx, int index); /* Up Next manipulation (offsets are 0-based relative to currentIndex + 1). */ SMQ_API int smq_remove_up_next(smq_ctx *ctx, int up_next_offset); SMQ_API int smq_move_up_next(smq_ctx *ctx, int from_offset, int to_offset); SMQ_API int smq_clear_up_next(smq_ctx *ctx); /* Shuffle, repeat & playback rate controls. */ SMQ_API int smq_set_shuffle(smq_ctx *ctx, int enabled, uint64_t seed); SMQ_API int smq_set_repeat(smq_ctx *ctx, int mode); SMQ_API int smq_cycle_repeat(smq_ctx *ctx); SMQ_API float smq_set_rate(smq_ctx *ctx, float rate); /* Sleep timer controls. check_sleep_timer returns remaining seconds (>=1), 0 if fired, -1 if off. */ SMQ_API int smq_set_sleep_timer(smq_ctx *ctx, int mode, int64_t duration_sec, int64_t now_epoch); SMQ_API int64_t smq_check_sleep_timer(smq_ctx *ctx, int64_t now_epoch); /* Snapshot & session resume serialization. Caller frees returned JSON with smq_free(). */ SMQ_API char *smq_state_json(smq_ctx *ctx); SMQ_API char *smq_export_resume_json(smq_ctx *ctx, double current_time_sec); SMQ_API int smq_restore_resume_json(smq_ctx *ctx, const char *resume_json, const char *library_tracks_json, double *out_resume_time); #ifdef __cplusplus } #endif #endif /* SMQ_H */