//
//  MusicViewModel.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/4/1.
//

import UIKit
///音乐展示分类
enum MusicShowType:Int {
    case First = 1
    case Second = 2
    case Third = 3
    ///对应标题
    var title:String{
        switch self {
        case .First:
            return "Real human voice"
        case .Second:
            return "Sounds of appliances"
        case .Third:
            return "Sounds of nature"
        }
    }
}
///音乐ViewModel
class MusicViewModel: NSObject {
    ///展示封面
    var cover:UIImage!
    ///标题
    var title:String = ""
    ///时长字符串
    var duration:String = ""
    ///播放状态(对照单例状态)
//    var isPlay:Bool = false
    ///音乐实体数据
    var music:MusicModel
    ///分类
    var type:MusicShowType!
    init(_ music: MusicModel) {
        self.music = music
        super.init()
        setUIDataLayout()
    }
    //实现数据与ui适配
    private func setUIDataLayout() {
        cover = UIImage(data: music.cover)
        title = music.title ?? ""
        duration = setTimesToMinSeconds(music.duration)
        type = .init(rawValue: Int(music.album))
    }
}
