export default <LibMixins>{

    inject:['getUseAgora'],

    data(){
        return {
            voiceValue:100,
            voiceMute:false,
            voiceIcon:{
                default:require('../images/voice.png'),
                disabled:require('../images/disabled-voice.png')
            }
        }
    },

    methods:{

        voiceChange(value){
            this.useAgora.setVolume(value);
            if (value <= 0) {
                return this.toggleVoice(true,false);
            } else {
                return this.toggleVoice(false,false);
            }
        },

        toggleVoice(value,set=true){

            if (value === undefined) {
                value = !this.voiceMute;
            }

            if (this.voiceMute !== value) {
                this.voiceMute = value;

                if (set) {
                    if (value) {
                        this.useAgora.setVolume(0);
                    } else {
                        this.useAgora.setVolume(this.voiceValue);
                    }
                }

            }



        }

    },

    mounted(){
        this.useAgora = this.getUseAgora();
        this.voiceValue = this.useAgora.volume;
    }



}