• October 16, 2018, 11:09:44 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

This Forum Beta is ONLY for registered owners of D-Link products in the USA for which we have created boards at this time.

Author Topic: Embedding Live Stream in persona web page  (Read 1373 times)

TheMaf2014

  • Level 1 Member
  • *
  • Posts: 5
Embedding Live Stream in persona web page
« 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
Logged

FurryNutz

  • Poweruser
  •   ▲
    ▲ ▲
  • *****
  • Posts: 45964
  • D-Link Global Forum Moderator
    • New DIR-890L Router with SmartConnect™ Technology
Re: Embedding Live Stream in persona web page
« Reply #1 on: December 19, 2017, 02:27:02 PM »

Logged
"Nothing Funny about It...." We are not here to Impress anyone! You have a be a COMPETENT user first to under stand COMPETENT help!

TheMaf2014

  • Level 1 Member
  • *
  • Posts: 5
Re: Embedding Live Stream in persona web page
« Reply #2 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

Logged

FurryNutz

  • Poweruser
  •   ▲
    ▲ ▲
  • *****
  • Posts: 45964
  • D-Link Global Forum Moderator
    • New DIR-890L Router with SmartConnect™ Technology
Re: Embedding Live Stream in persona web page
« Reply #3 on: December 20, 2017, 09:45:44 AM »

Good Luck.  ;)
Logged
"Nothing Funny about It...." We are not here to Impress anyone! You have a be a COMPETENT user first to under stand COMPETENT help!