import Foundation

enum PlaybackStatus: Equatable {
    case stopped
    case connecting
    case buffering
    case playing
    case paused
    case failed(PlaybackError)

    var isPlaying: Bool {
        self == .playing || self == .connecting || self == .buffering
    }

    var title: String {
        switch self {
        case .stopped:
            String(localized: "Stopped")
        case .connecting:
            String(localized: "Connecting...")
        case .buffering:
            String(localized: "Buffering...")
        case .playing:
            String(localized: "Playing")
        case .paused:
            String(localized: "Paused")
        case let .failed(error):
            error.title
        }
    }

    var detail: String? {
        if case let .failed(error) = self {
            return error.detail
        }
        return nil
    }
}
