【问题标题】:HTML/Javascript: How to add a live video stream from another websiteHTML/Javascript:如何添加来自另一个网站的实时视频流
【发布时间】:2013-05-26 04:25:39
【问题描述】:

为了方便起见,我目前正在尝试将来自另一个网站的实时视频流添加到我自己的网站上,但似乎无法正常工作。我已经使用选择和选项编写了一个下拉列表,选择 id="select camera" onchange="traffic()。有人可以告诉我下面的脚本做错了什么吗?

function traffic() <br>
    { <br>
    location[0] = "<img src='http://131940.qld.gov.au/DMR.Controls/WebCams/DisplayImage.ashx?FilePath=\Metropolitan\mecure.jpg&R=1369294224610' alt='Brisbane City Traffic Camera is Currently Unavailable'width='500' height='400'>"; <br>
    location[1] = "<img src='http://131940.qld.gov.au/DMR.Controls/WebCams/DisplayImage.ashx?FilePath=\Metropolitan\Rochedale_Pac_Mwy_Sth.jpg&R=1369294358098' alt='Rochedale Traffic Camera is Currently Unavailable'width='500' height='400'>"; <br>
    location[2] = "<b>Select a Traffic Camera</b>" <br>
    list=document.getElementById("select camera"); <br>
    index=list.selectedIndex; <br>
document.getElementById("traffic").innerHTML=location[index]; <br>
    }

提前感谢您!

【问题讨论】:

  • 仔细看网站提供的API。

标签: javascript html video-streaming live-streaming


【解决方案1】:

当您更改选项时,它将创建一个对服务器的请求:

POST:
 + URL:
         http://131940.qld.gov.au/DMRServices/WebCam/WebcamService.svc/GetNextRegionImage
 + Data: regionId=104
         webcamId=204

它会响应如下内容:

{"d":{"__type":"WebCamDTO:#DMR.Web.DMRServices.WebCam","CurrentId":0,"CurrentIndex":0,"Description":"Toowoomba - Bottom of Range looking East. ","HasRedAlert":true,"RedAlertDescription":"Warrego Highway, Redwood - Congestion: Both Directions - On...","RedAlertLocation":"Darling Downs - REDWOOD","RedAlertTime":"03:00 PM","RedAlertUrl":"\/Regions\/DarlingDowns\/Road-Conditions.aspx?regionId=104&tab=incident","Url":"\/DMR.Controls\/WebCams\/DisplayImage.ashx?FilePath=Darling_Downs\/toowoomba-range-bottom-helidon.jpg"}}

你可以在响应结果中看到

"Url":"\/DMR.Controls\/WebCams\/DisplayImage.ashx?FilePath=Darling_Downs\/toowoomba-range-bottom-helidon.jpg"

这是你需要的图片链接

http://131940.qld.gov.au/DMR.Controls/WebCams/DisplayImage.ashx?FilePath=Darling_Downs/toowoomba-range-bottom-helidon.jpg

【讨论】:

  • Jerry 先生,您是说我需要将图片链接更改为:
    \\location[0] = "131940.qld.gov.au/DMR.Controls/WebCams/…\Metropolitan\mecure.jpg&R =1369294224610' alt='布里斯班市交通摄像头目前不可用'width='500' height='400'>"
猜你喜欢
  • 2020-06-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-26
  • 2014-07-21
  • 1970-01-01
相关资源
最近更新 更多