It is not possible to completely hide or encode the video source using JavaScript as the source code is visible in the browser's developer tools. However, you can make it more difficult for someone to access the source by obfuscating it. One way to do this is by using a JavaScript function to generate the video source dynamically.
Here's an example:
<video id="my-video"></video>
<script>
function generateSrc() {
// Generate the video source dynamically
return "https://example.com/my-video.mp4";
}
// Set the video source
var video = document.getElementById("my-video");
video.src = generateSrc();
</script>
In this example, the generateSrc function generates the video source dynamically, making it more difficult for someone to access the source directly. However, it's important to note that this is not a foolproof solution and determined users can still access the source if they really want to.