我在尝试在Chrome for Android中录制和播放视频时遇到了一个不寻常的问题。 (相同的代码在Chrome for Desktop上运行正常)。
首先,一些信息:
我的目标是从平板电脑的相机录制视频,然后播放录制的视频。 这是一个示例代码:
<!DOCTYPE html>
<html>
<head>
<title>Camera Test</title>
<script type="text/javascript" src="//cdn.WebRTC-Experiment.com/RecordRTC.js"></script>
</head>
<body>
<script>
var cameraStream;
var cameraEl;
var cameraRecorder;
var cameraBlobURL;
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia = ( navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
function askForCamera(){
navigator.getUserMedia(
{
video : true
},
function(stream) {
cameraStream = stream;
cameraEl = document.getElementById("vidCamera");
cameraEl.src = window.URL.createObjectURL(stream);
},
function(){
alert('fail camera');
}
);
}
function playCamera(){
cameraEl.play();
}
function startRec(){
cameraRecorder = RecordRTC(
cameraStream,
{
type: 'video',
disableLogs : true
}
);
cameraRecorder.startRecording();
}
function stopRec(){
cameraRecorder.stopRecording(function(blobURL){
cameraBlobURL = blobURL;
console.log(cameraBlobURL);
alert(cameraRecorder.getBlob().type + ' ' +cameraRecorder.getBlob().size);
});
}
function setBlob(){
cameraEl.src = cameraBlobURL;
}
</script>
<p>Buttons:</p>
<button type="button" onclick="askForCamera()">Ask for camera</button>
<button type="button" onclick="playCamera()">Play camera</button>
<button type="button" onclick="startRec()">Start Rec</button>
<button type="button" onclick="stopRec()">Stop Rec</button>
<button type="button" onclick="setBlob()">Set blob to camera</button>
<button type="button" onclick="playCamera()">Play camera</button>
<br/>
<p>Camera:</p>
<video id="vidCamera" width="200" height="200">
</video>
</body>
</html>
我应该如何处理,以确保它适用于Android版Chrome? 希望可以有人帮帮我。 谢谢大家!
答案 0 :(得分:4)
我也在Chrome 41上遇到过这个问题并且相信它是一个错误。可能是这个问题: