const { ccclass, property } = cc._decorator;
@ccclass
export default class Helloworld extends cc.Component {
    // @property(cc.Label)
    // label: cc.Label = null;

    // @property
    // text: string = 'hello';

    // @property(cc.ToggleContainer)
    // ToggleContainer: cc.ToggleContainer = null

    // @property(cc.Node)
    // toggleitem: cc.Node = null

    // @property(cc.Sprite)
    // ttestspf: cc.Sprite = null

    @property(cc.Node)
    A: cc.Node = null;

    @property(cc.Node)
    B: cc.Node = null;

    // @property(cc.AudioClip)
    // mymusic: cc.AudioClip = null


    private _ListToggle: Array<cc.Toggle> = [];

    private _isc = false;

    private _audioSource: cc.AudioSource = null

    private _musicId = -1

    start() {
        this.A.on('click', () => {
            cc.director.loadScene('A')
        })
        // setTimeout(() => {
        //     if (!cc.audioEngine.isMusicPlaying()) {
        //         cc.audioEngine.playMusic(this.mymusic, false)
        //     }
        // }, 1000);
        // this._audioSource = this.node.getComponent(cc.AudioSource)
        // this._audioSource.volume = 0.5
        cc.loader.loadRes('lobbyBg',cc.AudioClip,(err,sound:cc.AudioClip)=>{
            if(err){
                console.log('err');
                return
            }
            cc.audioEngine.stopAll()
            this._musicId = cc.audioEngine.playMusic(sound,true)
        })
    }
    onLoad() {

    }
    sliderCall(target: cc.Slider) {
        console.log(target.progress);
        // this._audioSource.volume = target.progress
        cc.audioEngine.setMusicVolume(target.progress)
        // cc.audioEngine.setVolume(this._musicId,target.progress)
    }
    onDestroy() {
        cc.audioEngine.stop(this._musicId)
    }
    reload() {
        location.reload()
    }
    // click() {
    //     // cc.director.loadScene('Helloscene')
    //     let a = !this._isc
    //     this._ListToggle[0].check()
    // }
    joinChanel() {
        // agora.joinChannel(null, "123456789");
    }
}
cc.game.on(cc.game.EVENT_HIDE,()=>{
    console.log('cc.game.EVENT_HIDE');
    
    // cc.audioEngine.pauseMusic()
    // cc.audioEngine.pauseAllEffects()
    cc.audioEngine.setMusicVolume(0)
})
cc.game.on(cc.game.EVENT_SHOW,()=>{
    console.log('cc.game.EVENT_SHOW');
    cc.audioEngine.setMusicVolume(1)
    // cc.audioEngine.resumeMusic()
    // cc.audioEngine.resumeAllEffects()
})