Search the Community
Showing results for tags 'caching'.
-
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