The new version of Unity packs the webgl version to play the hls video stream, and uses the AVPro plug-in to play

The new version mentioned here probably refers to the version after 2020, because I found that the webgl packaged by unity after 2019 and 2020 is very different. Many of the online finds are about the 2019 version or the previous hls playback method. So here is a record of the new version of the unity webgl version packaged playback method. I have never learned how to use html, but just wrote it out according to the example, and the personal test is actually available, so I will record it here, maybe it can help someone who also encounters the same problem.

First create your own webgl template, download the hls.min.js file from the Internet , and put it in the TemplateData folder of your own template, as shown in the figure below. (For how to create your own template, just copy a template that comes with unity)

The more critical step is to modify the Index.html file in the template, let it load the hls.min.js file, and add text

 

var hlsUrl="TemplateData"+"/hls.min.js";
var script1 = document.createElement("script");
      script1.src = hlsUrl;
      script1.onload = () => { };
      document.body.appendChild(script1);

The modified place is shown in the figure below

 

 

I am using the AvPro ​​plug-in here, and I need to set the webgl playback mode to support hls, as shown below

 Select Absolute Path Or URL as the path type, and pass in your .m3u8 video path.

 Finally, choose your own configured webgl template package

 

Guess you like

Origin blog.csdn.net/qq_20991149/article/details/129856692