JSFiddle - React, Tailwind, and code Playground

HTML

<video id="id_tag_video">
  
</video>
<script>
var streamVideo=new streamVideo("id_tag_video", độ_dài_mỗi_file_cắt, số_luọng_file_tối_đa(cái này để 1000), chạy_bao_nhiêu_phần_trăm_thì_load(để 50%),"url",số_gói_tin_load_trước,"6445C6AA282016C");
streamVideo.start();
</script>

JavaScript

function streamVideo(tag_video, time_cut, max_chuck, load_percent, link_connect, load_before = 1,id="") {
    this.arrayOfBlobs = [];
    this.index_insert = 0;
    this.time_cut = time_cut;
    this.max_chuck = max_chuck;
    this.load_percent = load_percent;
    this.link_connect = link_connect;
    this.load_before = load_before;
    this.id=id;
    this.arrayLoader = new Array();
    this.mediaSource = new MediaSource();
    this.url = URL.createObjectURL(this.mediaSource);
    this.video = document.getElementById(tag_video);
    this.video.src = this.url;
    this.sourceBuffer = null;
    this.start = function () {
        console.log(this.video);
        
        this.addevent();
        this.nextChunk(0);
    }
    this.addevent = function () {
        static = this;
        static.video.addEventListener("seeking", function () {
            time_index = parseInt(static.video.currentTime / static.time_cut);
            for (i = 0; i <= static.load_before; i++) {
                check = true;
                for (j = 0; j < static.arrayLoader.length; j++) {
                    if (static.arrayLoader[j] == (time_index + i)) {
                        check = false;
                    }
                }
                if (check) {
                    static.nextChunk(time_index + i);
                }
            }
        });
        static.video.addEventListener("timeupdate", function () {
            if (static.video.currentTime % time_cut >= parseInt((time_cut * load_percent) / 100)) {
                time_index = parseInt(static.video.currentTime / static.time_cut) + 1;

                for (i = 0; i <= static.load_before; i++) {
                    check = true;
                    for (j = 0; j < static.arrayLoader.length; j++) {
                        if (static.arrayLoader[j] == (time_index + i)) {
                            check = false;
                        }
                    }
                    if (check) {
                       ...