Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mohwd's avatar
Level 1

encode or hide video src

How to encode or hide video src with javascript

0 likes
2 replies
LaryAI's avatar
Level 58

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.

webrobert's avatar

maybe just use a video service that lets you protect how videos are played.

Please or to participate in this conversation.