const hzybStore={
    namespaced: true,
    state:{
        audioData:{
            INS:null,
            list:[],
            index:0,
            paused:true,//音频是否在暂停
            show:false,// 显示音频弹窗
            videoCtime:0,//音频当前播放时间
        }
    },
    mutations: {
        // 点击播放音频
        addAudio(state,e){
            state.audioData.list=e.list
            state.audioData.index=e.index||0
            state.audioData.INS.play()
            state.audioData.show=true
        },
        // 更新音频播放状态
        upateAudioStatus(state,e){
            if(e==='end'){
                if(state.audioData.list.length-1==state.audioData.index){
                    // 最后一首
                    state.audioData.show=false
                    state.audioData.INS=null 
                    state.audioData.list=[]
                    state.audioData.index=0
                    state.audioData.paused=true
                }else{
                    state.audioData.index++
                }

            }else if(e==='play'){
                state.audioData.paused=false
            }else if(e==='paused'){
                state.audioData.paused=true
            }
        },
        // 切换音频
        changeAudioIndex(state,e){
            console.log(e);
            state.audioData.index=e
        },
        //关闭音频弹窗
        closeAudioPop(state){
            state.audioData.show=false
            state.audioData.INS=null 
            state.audioData.list=[]
            state.audioData.index=0
            state.audioData.paused=true
        },
        showAudioPop(state){
            state.audioData.show=true
        },
        // 更新音频播放时间
        updateAudioCtime(state,e){
            state.videoCtime=e
        }

    }
}

export default hzybStore
