"use strict";
cc._RF.push(module, '9e07cb6Vq5LIaFBXNo5jgsy', 'NewScript');
// resources/aaa/NewScript.ts

// Learn TypeScript:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var NewClass = /** @class */ (function (_super) {
    __extends(NewClass, _super);
    function NewClass() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.test_music = null;
        _this.mp3_music = null;
        // @property(cc.AudioClip)
        // mp3_music: {
        //     default: null,
        //     type: cc.AudioClip,  // use 'type:' to define Asset object directly
        // };
        _this._musicId = -1;
        return _this;
        // update (dt) {}
    }
    // LIFE-CYCLE CALLBACKS:
    // onLoad () {}
    NewClass.prototype.start = function () {
        // cc.loader.loadRes('snd_bg', cc.AudioClip, (err, clip) => {
        //     // cc.audioEngine.play(clip);
        //     if (err) {
        //         cc.error(err);
        //     } else {
        //         this.playMusic(clip, true);
        //     }
        // });
        this.playMusic(this.mp3_music, true);
    };
    NewClass.prototype.playMusic = function (clip, loop) {
        loop = typeof loop !== 'undefined' ? loop : true;
        if (this._musicId !== -1) {
            cc.audioEngine.stop(this._musicId);
        }
        this._musicId = cc.audioEngine.play(clip, loop, this._musicVolume);
        cc.log('start   _musicId:', this._musicId);
    };
    NewClass.prototype.onCallButton = function (event, customEventData) {
        var num = event.progress.toFixed(2);
        cc.log("this._musicId:", this._musicId);
        cc.log("this._musicVolume:", this._musicVolume);
        cc.log("num:", num);
        this._musicVolume = num;
        if (this._musicId !== -1 && this._musicVolume) {
            cc.audioEngine.setVolume(this._musicId, this._musicVolume);
        }
    };
    __decorate([
        property(cc.Slider)
    ], NewClass.prototype, "test_music", void 0);
    __decorate([
        property(cc.AudioClip)
    ], NewClass.prototype, "mp3_music", void 0);
    NewClass = __decorate([
        ccclass
    ], NewClass);
    return NewClass;
}(cc.Component));
exports.default = NewClass;

cc._RF.pop();