沒有深入瞭解爲什麼我使用XHR的細節,誰能告訴我如何讓下面的工作這樣做?我的目標是首先加載視頻數據,然後將其放入視頻標籤的源代碼中。XHR加載視頻
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
window.onload = function() {
var elem = document.getElementById("myVideo");
var req = new XMLHttpRequest();
req.onload = function() {
var blob_uri = URL.createObjectURL(this.response);
elem.appendChild(document.createElement("source"))
.src = blob_uri;
};
req.responseType = "blob";
req.open('GET', 'http://www.latentmotion.com/player/h264/clips/16154_2832659676_170_180.mp4', false);
req.send(null);
};
</script>
</head>
<body>
<video id="myVideo" width="600" height="334" controls></video>
</body>
</html>
感謝您花時間回覆。我閱讀了您的筆記和鏈接,指向Chrome的解決方法,但預計Firefox會在沒有解決方法的情況下運行。 – Matrym 2011-05-16 18:08:30