D-Link Forums

The Graveyard - Products No Longer Supported => IP Cameras => DCS-2330L => Topic started by: TheMaf2014 on December 19, 2017, 12:21:51 PM

Title: Embedding Live Stream in persona web page
Post by: TheMaf2014 on December 19, 2017, 12:21:51 PM
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
Title: Re: Embedding Live Stream in persona web page
Post by: FurryNutz on December 19, 2017, 02:27:02 PM
Not sure if any of this might be helpful:
http://forums.dlink.com/index.php?topic=50328.0 (http://forums.dlink.com/index.php?topic=50328.0) and http://forums.dlink.com/index.php?topic=64975.0 (http://forums.dlink.com/index.php?topic=64975.0)
Title: Re: Embedding Live Stream in persona web page
Post by: TheMaf2014 on December 20, 2017, 09:44:23 AM
Unfortunately, both the first and the second example don't work as expected...
they behave as i said in my initial post...:

WORKS FINE if launched via:  file:///path/to/the/htmlfile.html

DON'T WORK if launched via:  http://localhost/etc..etc../htmlfile.html

anyway thanks for the hints

Marzio

Regards

Title: Re: Embedding Live Stream in persona web page
Post by: FurryNutz on December 20, 2017, 09:45:44 AM
Good Luck.  ;)