// Copyright 2014-2025 Jesper Larsson
//
// This file is part of Klipspringer, <https://klipspringer.avadeaux.net/>
//
// Klipspringer is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// Klipspringer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
// even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with Klipspringer. If
// not, see <https://www.gnu.org/licenses/>.

package net.avadeaux.klipspringer;

import net.avadeaux.klipspringer.codec.PcmFormat;

/** Status inspector for playing. */
public interface PlayMonitor {
    interface Info {
        /** Gets name of current track or file, or null if nothing is playing. */
        String trackName();

        /** Gets index of current track or file, or -1 if nothing is playing. */
        int trackIndex();

        /** Gets format of current track or file, or null if nothing is playing. */
        PcmFormat format();

        /** Describes quality if lossy compressed, empty string if lossless, null if unknown. */
        String quality();

        /** True if the player is monomixing audio. */
        default boolean monomixing() { return false; }

        /** True if the player is paused. */
        default boolean paused() { return false; }

        /** Gets track time, or NaN if not applicable. */
        double time();
    }

    /** Gets a status container to use with this status inspector. */
    Info getInfoObject();

    /** Potentially waits for an update newer than the one already set in the given data record,
      * then sets the record fields.
      */
    void getStatus(Info info, long timeoutMillis);

    /** Gets current playing time from the start of the track list, or NaN if nothing is playing. */
    double playingTime();

    /** Gets index of currently playing track, or -1 if nothing is playing. */
    int playingTrackIndex();

    /** Checks if playback is currently paused. */
    default boolean paused() { return false; }

    /** Checks if playback is currently monomixed. */
    default Query.Onoff monomixing() { return Query.Onoff.DETECT; }

    /** Checks if playback is currently in fading mode. */
    default Query.Onoff fading() { return Query.Onoff.DETECT; }
}

