AndrewPVI Posted December 9, 2019 Share Posted December 9, 2019 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. Link to comment Share on other sites More sharing options...
shaili_shah Posted March 24, 2020 Share Posted March 24, 2020 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now