npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jaeger-html5video

v1.0.0

Published

A Phonegap plugin that allows playback of local video files using html 5 video tags

Downloads

2

Readme

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 <video> 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:

<video id="myvideo" loop></video>

The next changes should be done inside your ProjectName/platforms/android folder

Enable Hardware Acceleration in AndroidManifest.xml

Android Webview disables video for none-hardware accelerated applications. Thus, make sure your manifest tag in AndroidManifest.xml contains:

android:hardwareAccelerated="true"

Consult the official Android documentation if you require more help. This is enabled by default in newer versions of cordova.

Move video files

Create a folder called raw inside the res folder ($PROJECT_ROOT/platforms/android/res/raw) where you place your videos. Due to limitations in how Android uses the res folder, make sure:

  1. Your filenames doesn't contain spaces and special characters
  2. That all filenames are unique and doesn't contain period (.) delimiters. Android considers video.lowres.mp4 and video.highres.mp4 the same file

If your file doesn't meet the above requirements cordova build will fail to compile your application.

Client-side code (javascript)

After deviceReady callback from Cordova, initialize your videos with:

window.plugins.html5Video.initialize( { "id":"path", ... } ) 

Example:

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

Playing a video

Anytime you wish to play a video, call:

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:

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

Play video1 and call function finished:

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

Play video1 with anonymous function:

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