我有以下代碼可直接通過公共訪問鏈接查看我的攝像頭。HTML5視頻鏈接在Chrome中不起作用
<!DOCTYPE html>
<html>
<head>
<title>webRTC Test</title>
</head>
<script type = "text/javascript">
function init()
{
if(navigator.webkitGetUserMedia)
{
navigator.webkitGetUserMedia({video:true}, onSuccess, onFail);
}
else
{
alert('webRTC not available');
}
}
function onSuccess(stream)
{
document.getElementById('camFeed').src = webkitURL.createObjectURL(stream);
var src = document.getElementById('camFeed').getAttribute('src');
document.getElementById('streamLink').href = src;
}
function onFail()
{
alert('could not connect stream');
}
</script>
<body onload = "init();" style="background-color:#ababab;">
<div style="width:352px; height:625px; margin:0 auto; background-color:#fff;">
<div>
<video id ="camFeed" width="320" height="240" autoplay>
</video>
</div>
<div>
<canvas id="photo" width="320" height="240">
</canvas>
</div>
<div style="margin: 0 auto; width:82px;">
<a id="streamLink">Visit Stream</a>
</div>
</div>
</div>
</body>
</html>
在錨標記中生成的鏈接是這樣的:
blob:http%3A//sitename.com/7989e43a-334r-4319-b9c5-9dfu00b00cd0
而且在訪問鉻告訴我:「哎呀這個鏈接似乎被打破!」。
幫助感謝!
什麼是_actual_有問題的鏈接? –
Visit Stream此鏈接轉到該blob url並在訪問時中斷...它也是我相信代碼中的唯一鏈接。謝謝! – algorithmicCoder
我的選擇不好。什麼是URL? –