andyhill Posted March 29, 2021 Posted March 29, 2021 Searching the web I found this code for implementing video caching:- ' <script>'+ ' // -- Create a MediaSource and attach it to the video'+ ' const videoTag = document.getElementById("MyVideoTag");'+ ' const myMediaSource = new MediaSource();'+ ' const url = URL.createObjectURL(myMediaSource);'+ ' videoTag.src = url;'+ ' // 1. add source buffers'+ ' const audioSourceBuffer = myMediaSource.addSourceBuffer(''audio/mp4; codecs="mp4a.40.2"'');'+ ' const videoSourceBuffer = myMediaSource.addSourceBuffer(''video/mp4; codecs="avc1.64001e"'');'+ ' // 2. download and add our audio/video to the SourceBuffers for the audio SourceBuffer'+ ' fetch("https://mydomain.com/audio.mp4").then (function(response)'+ ' {'+ ' // The data has to be a JavaScript ArrayBuffer'+ ' return response.arrayBuffer();'+ ' }'+ ' ).then (function(audioData) '+ ' {'+ ' audioSourceBuffer.appendBuffer(audioData);'+ ' }'+ ' );'+ ' // the same for the video SourceBuffer'+ ' fetch("https://mydomain.com/video.mp4").then (function(response)'+ ' {'+ ' // The data has to be a JavaScript ArrayBuffer'+ ' return response.arrayBuffer();'+ ' }'+ ' ).then (function(videoData)'+ ' {'+ ' videoSourceBuffer.appendBuffer(videoData);'+ ' }'+ ' );'+ ' </script>'+ I have added this script to the HtmlFrame that contains the video tag with the id="MyVideoTag" and ask if any other code is required to activate this javascript caching ? Thanks in advance Quote
Sherzod Posted April 2, 2021 Posted April 2, 2021 8 hours ago, andyhill said: please advise Hello, Please explain what is the main purpose? Quote
andyhill Posted April 2, 2021 Author Posted April 2, 2021 HTMLFrame contains a Large Video, rather than download as a File stream contents in blocks. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.