首页 > 解决方案 > 为 iFrame 创建 Blob URL

问题描述

我一直在谷歌搜索,试图找出为 iFrame 创建 blob URL,虽然我对 javascript 完全陌生,但我设法将一些主要工作的代码拼接在一起,但它没有加载视频。

HTML:

<iframe class="test" width="500" height="300" />

JAVASCIPT:

var url = `https://www.sample-videos.com/video123/mp4/720/big_buck_bunny_720p_30mb.mp4`;

var blob = new Blob([url], {type: 'video/mp4'});
var iframe = document.querySelector(".test");
iframe.src = URL.createObjectURL(blob);

有人能指出为什么这对我不起作用吗?就像我说我是新手,所以如果可能的话,你能不能解释一下,而不是仅仅提供答案。

谢谢,保罗。

Uncaught TypeError: Failed to construct 'Blob': The provided value cannot be converted to a sequence.
at window.onload

(index):34 Uncaught ReferenceError: html is not defined
at window.onload

标签: javascript

解决方案


推荐阅读