hello,
i'm trying to embedding live stream from my DCS-2330L into my webpage..
i'm using the following two simple file :
1) mycam.html:
favorite
i'm trying to capture live stream from my IPCAM (Dlink DCS-2330L) and embedding it into my weather webpage. i'm using these two simple pieces of code: 1) HTML FILE-->mycam.html:
<html>
<head>
<title>My Ip Cam</title>
<meta charset="utf-8"/>
<script type="text/javascript" src="https://code.jquery.com/jquery- 3.2.1.min.js"></script>
<script type="text/javascript" src="mycam.js"></script>
</head>
<body>
<img id="mycam" src="" width='' alt=''/>
</body>
</html>
2) JS File:
$(document).ready(function() {
function refr(){
$("#mycam").attr('src','http://myipcamaddr:portNumber /video1.mjpg');
}
setInterval(refr,1000)
});
OS:MacOsHighSierra
Hardware:MacBook Pro
both file are in the same folder in this path: /Users/username/Sites/vscode/html/
Everything works fine if i open the html file in a web browser in this way:
file:///Users/username/Sites/vscode/html/mycam.html
but it doesn't work if i try to open the same html file via server web (localhost), in this way:
http://localhost/~<username>/vscode/html/mycam2.html
in this case in the console log of the browser appear repeatedly every 1 sec the following error and near the error the resource url (of my webcam stream...):
"failed to load resource the server responded with a status of 403 (Forbidden) http://myipcamaddress:portNumber/video1.mjpg"
the problem is not connected to the access credential of my IpCam because as soon as i load the the page in both way :
file:///..etc... and http://localhost...etc... a pop up appear asking me the user and the password of the IpCam. and i type in the right log-in
all the permission of directory and file in the DocumentRoot (for Apache) are correct... infact i tried with other scritps and they works smoothly
i think the problem depends on the fact that the JS file needs to connect to the ipcam url... and for some reason the browser doesn't allow this
(but only when i launch the html file via http://localhost...etc... as above stated, if the html is launched directly
in this way --> file:///Users/<username>/Sites/vscode/html/mycam.html... everythings works again well)
but i need to show the streaming live via php so i need it to work via http://localhost/...etc... etc..
hope someone could give me some hint!!!
Thanks in advance
Best Regards
Marzio