Login
1 branch 0 tags
Ben (Desktop/Arch) Smoother UI bb6b2c1 1 month ago 72 Commits
moon / src / playlist.h
#pragma once
#include <stdbool.h>
#include "storage.h"

typedef enum {
	PLAYLIST_MUSIC,
	PLAYLIST_AUDIOBOOK,
} playlist_type_t;

typedef struct {
	playlist_type_t type;
	char path[STORAGE_MAX_PATH];
} playlist_entry_t;

typedef struct {
	int index;
	int count;
	playlist_entry_t entries[PLAYLIST_MAX_ENTRIES];
} playlist_t;

extern playlist_t playlist;

// Load playlist from .onigiri/playlist.toml
void playlist_load(void);

// Save playlist to .onigiri/playlist.toml
void playlist_save(void);

// Add entry to end of playlist
void playlist_add(const char* path, playlist_type_t type);

// Clear all entries, reset index to 0
void playlist_clear(void);

// Return pointer to entry at current index (or NULL if empty)
playlist_entry_t* playlist_current(void);

// Advance to next entry. Returns false if at end.
bool playlist_next(void);

// Go to previous entry. Returns false if at beginning.
bool playlist_prev(void);

bool playlist_is_empty(void);
int playlist_count(void);

// Set current index
void playlist_set_index(int i);

// Call from main loop — periodically saves audiobook bookmark
void playlist_tick(void);