cc.Class({
    extends: cc.Component,
    editor: {
        executionOrder: -1,
    },
    properties: {
        audio: [cc.AudioClip],
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        cc.game.addPersistRootNode(this.node);
        window.au = this;
        this.list = {};
        this.audio.forEach(function (key) {
            this.list[key.name] = key;
        }.bind(this));
    },

    play(name) {
        if (local.getData('audio', true) == 0) {
            return false;
        }
        cc.audioEngine.play(this.list[name], false, 1);
    },

    backAudio(name) {
        if (this.back) {
            if (local.getData('audio', true) == 0) {
                cc.audioEngine.pauseMusic();
            } else {
                cc.audioEngine.resumeMusic();
            }
        } else {
            if (local.getData('audio', true) == 0) {
            } else {
                cc.audioEngine.playMusic(this.list[name], true);
                this.back = true;
            }
        }
    },

    start() {

    },

    // update (dt) {},
});
