Webpage playback m3u8

Why can"t you play m3u8 directly using the video tag, but you can play m3u8 with an h5-wrapped player?

Jul.27,2021

ideo-dev/hls.js" rel=" nofollow noreferrer "> https://github.com/video-dev/.

import * as Hls from "hls.js";

const video = document.querySelector("-sharpyour-video-id");
const url = "";

if(video.canPlayType("application/vnd.apple.mpegurl")){
    // 
    video.src = url;
    video.addEventListener("loadedmetadata", function() {
        try {
            video.play();
        } catch (error) {
            console.log(error);
        }
    });
}else if (Hls.isSupported()){
    const hls = new Hls({
        //  AAC LC 
        defaultAudioCodec: "mp4a.40.2",
    });
    hls.loadSource(url);
    hls.attachMedia(video);
    hls.on(Hls.Events.MANIFEST_PARSED, function() {
        try {
            video.play();
        } catch (error) {
            console.log(error);
        }
    });
}else{
    // 
    console.log("");
}
Menu