//
//  AudioQueue.swift
//  Werkout_ios
//
//  Created by Trey Tartt on 8/12/23.
//

import Foundation

enum AudioType {
    case shortBeep
    case finishBeep
    case remoteURL(URL)
}

struct AudioQueue: Codable, Identifiable, Equatable {
    var id = UUID()
    
    let playAt: Int
    let audioURL: String
    
    enum CodingKeys: String, CodingKey {
        case playAt = "play_at"
        case audioURL = "audio_url"
    }
    
    var audioType: AudioType {
        if audioURL == "short_beep" {
            return .shortBeep
        } else if audioURL == "long_beep" {
            return .finishBeep
        } else {
            if let url = URL(string: BaseURLs.currentBaseURL + audioURL) {
                return .remoteURL(url)
            } else {
                return .shortBeep
            }
        }
    }
}
