使用HTML5视频标签播放本地(硬盘)视频文件? [英] Play local (hard-drive) video file with HTML5 video tag?

查看:1123
本文介绍了使用HTML5视频标签播放本地(硬盘)视频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现以下目标。

 < video src =file:/// Users / username / folder /video.webm\"> 
< / video>

目的是用户可以从他/她的硬盘中选择一个文件。 / p>

不上传的原因当然是传输成本和存储配额。没有理由保存文件。



有可能吗?

解决方案

可以播放本地视频文件。

 < input type =fileaccept =video / */> 
<视频控件自动播放>< / video>

通过输入选择文件时,元素:


  1. '更改'事件被触发

  2. 获取第一个 File object from input.files FileList

  3. 创建指向File对象的对象URL
  4. 设置对象 video.src 属性的网址

  5. 向后倾斜并观看:)





http://jsfiddle.net/dsbonev/cCCZ2/embedded/result,js,html,css/


I want to achieve the following.

<video src="file:///Users/username/folder/video.webm">
</video>

The intent is that the user will be able to select a file from his/her hard drive.

And the reason for not uploading is of course transmission costs and storage quota. There will be no reason to save the file.

Is it possible?

解决方案

It is possible to play a local video file.

<input type="file" accept="video/*"/>
<video controls autoplay></video>

When a file is selected via the input element:

  1. 'change' event is fired
  2. Get the first File object from the input.files FileList
  3. Make an object URL that points to the File object
  4. Set the object URL to the video.src property
  5. Lean back and watch :)

http://jsfiddle.net/dsbonev/cCCZ2/embedded/result,js,html,css/

这篇关于使用HTML5视频标签播放本地(硬盘)视频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆