百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
H

Html5Video

> 编程语言
开源

一个 Phonegap 插件,可使用 HTML 5 视频标签播放本地视频文件

100 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个 Phonegap 插件,可使用 HTML 5 视频标签播放本地视频文件

Cordova Html5Video Plugin

Description

This plugin enables the use of normal HTML5 tags for local video - otherwise not functional in Cordova for Android. If you are looking to simply play videos in full screen started by JS, try the VideoPlayer plugin for Phonegap

Android Webview (which Cordova is based upon) limits access to local files (such as videos) and prohibits reading them, both via relative files and file:/// URIs. Cordova Html5Video Plugin solves this by giving each of you video a android.resource:// path and updating your `` tags accordingly.

Limitations

For Android only. Tested on Android API 15-19.

For API >= 19, a workaround is employed to copy the video files over to your application's data directory, as world-readable.

WARNING: this is potentially insecure - other apps will be able to read your videos! However it is the only way to get around Chrome's strict limitations on content:// URLs. See Issue #20 for details.

Install

cordova plugin add https://github.com/jaeger25/Html5Video.git

For more help on installing Cordova plugins, please read the official documentation

HTML

Create any video tags withing your html pages as normal, but:

  1. Give each video tag a unique ID.
  2. The video tags should be empty (i.e no tags inside)
  3. Add any poster image files to your www folder
  4. Autoplay is not enabled, but controlled via JS instead

Example:

…

javascript window.plugins.html5Video.initialize( { "id":"path", ... } [, callback] )


Where callback is optional and is triggered when initialization finished (at the end)

Examples:

Initialization for video1 and video2 with no callback:

```javascript
window.plugins.html5Video.initialize({
      "video1" : "video1file.mp4", 
     "video2" : "video2file.mp4"
  })

Initialize video1 and call function finished:

javascript
window.plugins.html5Video.initialize({
      "video1" : "video1file.mp4"
  }, finished)

Initialize video1 with anonymous function (usefull for playing a video at statup):

javascript
window.plugins.html5Video.initialize({
      "video1" : "video1file.mp4"
  }, function initializeIsFinished() {
  window.plugins.html5Video.play("video1")
})

Playing a video

Anytime you wish to play a video, call:

javascript
window.plugins.html5Video.play("video1" [, callback ])

Where callback is optional and is triggered when the video is finished (at the end)

Examples:

Play video1 with no callback:

javascript
window.plugins.html5Video.play("video1")

Play video1 and call function finished:

javascript
window.plugins.html5Video.play("video1", finished).

Play video1 with anonymous function:

javascript
window.plugins.html5Video.play("video1", function videoIsFinished() {
  console.log("Video is finished")
})

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言