package com.jld.vod.viewmodel

import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData
import androidx.room.Room
import com.jld.vod.db.MusicByMidDatabase
import com.jld.vod.model.bean.BaseBean
import com.jld.vod.model.bean.MusicByMidBean


/**
 * @author ZhaoFuXin
 * @Email：18276061387@163.com
 * @description:
 * @date :2020/1/10 13:40
 */
class MusicPlayViewModel(app: Application)  : AndroidViewModel(app) {


    val musicbymiddb = Room.databaseBuilder(app, MusicByMidDatabase::class.java, "musicbymid").build()

    val findMovieByMidliveData: MutableLiveData<List<MusicByMidBean>> = MutableLiveData()
    val findMovieMidliveData: MutableLiveData<List<MusicByMidBean>> = MutableLiveData()

    /**
     * 获取单个音乐信息
     */
    fun findMusicByMid(movidId:Long) {
        Thread(Runnable {
            findMovieByMidliveData!!.postValue(musicbymiddb.musicByMidDao().loadAllByIds(movidId))
        }).start()
    }
    /**
     * 获取音乐信息
     */
    fun findMusicMid() {
//        Thread(Runnable {
//            findMovieMidliveData!!.postValue(musicbymiddb.musicByMidDao().getAll())
//        }).start()

    }
}