【结束】JS如何不通过input的onInputFileChange使用本地mp4文件并播放,nextjs下放入public文件的视频用video标签无法打开

本地不用input标签获取video视频并播放

浏览器没有像JAVA这些语言之类的IO

代码:

html 复制代码
<div>
  <video id="video_id" width="750" height="500" controls>
    Your browser does not support the video tag.
  </video>
</div>


<script>
    function show() {
        fetch("file:///E:/video/test1.mp4")
	        .then(response => {
	            return response.arrayBuffer()
	        })
	        .then(ab => {
		        const vdo = URL.createObjectURL(
			        new Blob([ab], { type: "video/mp4"}),
			    )
	          document.getElementById("video_id").src = vdo
	        })
	        .catch(err => console.log(err));
    }
    show()
</script>

命令行执行:

看情况需要给浏览器指定访问本地文件权限--allow-file-access-from-files

powershell 执行chrome:
Start-Process "C:\allUserApplication\portableApp\PortableApps\GoogleChromePortable\App\Chrome-bin\chrome.exe" -ArgumentList '"C:\Users\mammon\Desktop\anyt.html" --allow-file-access-from-files --disable-web-security'

nextjs下放入public文件的视频用video标签无法打开

我遇到的问题是浏览器不支持,我的浏览器是Chromium,版本 : 131.0.6778.33(正式版本) (64 位) ,它支持webm格式,增加个source就行

html 复制代码
<video  controls width="600" height="300">  
	<source src="/video/test1.mp4" type="video/mp4" />
	<source src="/video/test1.webm" type="video/webm" />
	Your browser does not support the video tag.  
</video>
相关推荐
祁同伟.19 小时前
【C++】多态
开发语言·c++
朱嘉鼎20 小时前
C语言之可变参函数
c语言·开发语言
aesthetician21 小时前
Node.js v25 重磅发布!革新与飞跃:深入探索 JavaScript 运行时的未来
javascript·node.js·vim
北冥湖畔的燕雀1 天前
C++泛型编程(函数模板以及类模板)
开发语言·c++
demi_meng1 天前
reactNative 遇到的问题记录
javascript·react native·react.js
QX_hao1 天前
【Go】--map和struct数据类型
开发语言·后端·golang
你好,我叫C小白1 天前
C语言 循环结构(1)
c语言·开发语言·算法·while·do...while
千码君20161 天前
React Native:从react的解构看编程众多语言中的解构
java·javascript·python·react native·react.js·解包·解构
Evand J1 天前
【MATLAB例程】基于USBL和DVL的线性回归误差补偿,对USBL和DVL导航数据进行相互补偿,提高定位精度,附代码下载链接
开发语言·matlab·线性回归·水下定位·usbl·dvl
爱喝白开水a1 天前
LangChain 基础系列之 Prompt 工程详解:从设计原理到实战模板_langchain prompt
开发语言·数据库·人工智能·python·langchain·prompt·知识图谱