Jump to content
Sign in to follow this  
AndrewPVI

Use JS to Call HTML5 Video URL

Recommended Posts

Hello, 

I'm trying to use a simple Javascript to call a function of the local IP address of a host for a video player that auto-updates its IP address whenever the user modifies the IP of the Host. 

 

I've been using the Built-in HTML 5 player to play an Apple HLS video that streams from the host and it works but I want to dynamically update the video src using the javascript. 

I hope this makes sense. 

 

The code has ive been trying to piece together looks like this: 

 

function myFunction() {
  var hostip = location.host;
  document.getElementById("videohls").innerHTML = hostip ;

this gets the host IP: 192.168.0.1 example. 

 

I need to take this IP and combine it with http:// + hostip + /1.m3u8 

That output needs to be the HTML5 players src 

 

How can I make this possible? I feel like its really simple but I'm not a javascript expert at all. 

 

 

Share this post


Link to post
Share on other sites
function myFunction() {
  var hostip = location.host;
  document.getElementById("videohls").innerHTML = hostip ;
var url = " http:// "+ hostip + /"1.m3u8 ";
$("#id-of-video-tag> source").attr("src", url);}

I think this will work.

Hope this will help you.

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...