import { Action, createAction } from "redux-act";

export interface Title {
    name: string;
    artist: string;
    album: string;
    /**
     * The length of the title in nanoseconds.
     */
    length: number;
}

export interface MusicState {
    muted: boolean;
    playing: boolean;
    title: Title;
    playTime: number;
    source?: string;
}

export const setTitle: (_title: Title) => Action<null, null> = createAction(
    "set currently playing title"
);

export const setPlayTime: (_time: number) => Action<null, null> =
    createAction("set the play time");

export const toggleMute: () => Action<null, null> = createAction("toggle mute");

export const togglePlay: () => Action<null, null> = createAction("toggle play");

export const setSource: (_source: string) => Action<null, null> =
    createAction("set the title");
