'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-acbe72ca.js');

const akordVideoStreamViewerCss = "akord-video-stream-viewer{}";

let AkordVideoStreamViewer = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.loading = false;
  }
  componentDidLoad() {
    this.initVideo();
    this.stream();
  }
  initVideo() {
    this.mediaSource = new MediaSource();
    this.mediaSource.addEventListener('sourceopen', () => {
      console.log('open', this.mediaSource);
      this.videoSourceBuffer = this.mediaSource.addSourceBuffer('video/mp4; codecs="avc1.64001e"');
      console.log('added source buffer');
      console.log(this.mediaSource);
    });
    this.mediaSourceUrl = URL.createObjectURL(this.mediaSource);
    this.videoEl.src = this.mediaSourceUrl;
    console.log(this.videoEl);
  }
  onCanPlay() {
    this.loading = false;
  }
  stream() {
    console.log("streaming");
    fetch(this.src)
      .then((response) => response.arrayBuffer())
      .then((videoData) => {
      console.log(this.videoSourceBuffer);
      console.log(videoData);
      this.videoSourceBuffer.appendBuffer(videoData);
      console.log(this.videoSourceBuffer);
    });
  }
  render() {
    if (this.loading)
      return (null);
    return (index.h("video", { controls: true, onCanPlay: () => this.onCanPlay(), ref: (el) => {
        this.videoEl = el;
        console.log(this.videoEl);
      } }, "Video playback is not supported by your browser."));
  }
};
AkordVideoStreamViewer.style = akordVideoStreamViewerCss;

exports.akord_video_stream_viewer = AkordVideoStreamViewer;
