"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const html_1 = __importDefault(require("../../../../../client/html"));
class Audio_ extends html_1.default {
    constructor($props, $system) {
        super($props, $system, $system.api.document.createElement('audio'), $system.style['audio'], {
            controls: true,
        }, {
            src: (src) => {
                if (src === undefined) {
                    this.$element.pause();
                    this.$element.removeAttribute('src'); // empty source
                    this.$element.load();
                }
                else {
                    this.$element.src = src;
                }
            },
            stream: (stream) => {
                if (stream === undefined) {
                    this.$element.srcObject = null;
                }
                else {
                    stream.$mediaStream({}, (_stream) => {
                        this.$element.srcObject = _stream;
                    });
                }
            },
            controls: (controls) => {
                if (controls === undefined) {
                    this.$element.removeAttribute('controls');
                }
                else {
                    this.$element.controls = controls;
                }
            },
        });
        this.$input = {
            stream: ['MS'],
        };
        const { src, controls = true } = this.$props;
        this.$element.controls = controls;
        if (src) {
            this.$element.src = src;
        }
    }
    play() {
        void this.$element.play();
    }
    pause() {
        this.$element.pause();
    }
    reset() {
        super.reset();
        this.$element.pause();
        this.$element.currentTime = 0;
    }
    captureStream(opt) {
        // @ts-ignore
        if (this.$element.captureStream) {
            // @ts-ignore
            return this.$element.captureStream();
        }
        return null;
    }
}
exports.default = Audio_;
//# sourceMappingURL=Component.js.map