html5做视频直播 Android可以获取到数据并发送到后台 iphone手机不支持 主要在这一块 navigator.getUserMedia 各位大神有什么好的办法能解决这个问题
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<video autoplay id="sourcevid" playsinline style="width:640px;height:480px"></video>
<canvas id="output" style="display:none"></canvas>
<script type="text/javascript" charset="utf-8">
if( document.createElement('canvas').getContext ) {
var socket = new WebSocket("ws://***.***.***.***:9502"),
back = document.getElementById('output'),
backcontext = back.getContext('2d'),
video = document.getElementsByTagName('video')[0];
socket.onopen = function() {
draw();
}
var success = function(stream) {
alert(stream);
video.src = window.URL.createObjectURL(stream);
}
var draw = function() {
try {
backcontext.drawImage(video,0,0, back.width, back.height);
} catch(e) {
if (e.name == "NS_ERROR_NOT_AVAILABLE") {
return setTimeout(draw, 100);
} else {
throw e;
}
}
socket.send(back.toDataURL("image/jpeg", 0.5));
setTimeout(draw, 100);
}
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia||navigator.mozGetUserMedia || navigator.msGetUserMedia;
//alert(navigator.getUserMedia);
navigator.getUserMedia({video:true, audio:false}, success, console.log);
} else {
alert('你的浏览器不支持html5,请先更换浏览器。。');
}
</script>
</body>
</html>
有没有可能是canvas的问题,我之前引用了一个关于canvas的插件,在安卓能显示,在ios上挂掉了