Coder Social home page Coder Social logo

williamren / accessible-html5-video-player Goto Github PK

View Code? Open in Web Editor NEW

This project forked from weboverhauls/accessible-html5-video-player

0.0 1.0 0.0 479 KB

Accessible HTML5 Video Player

Home Page: http://paypal.github.io/accessible-html5-video-player/

License: BSD 3-Clause "New" or "Revised" License

CSS 20.58% HTML 9.43% JavaScript 69.99%

accessible-html5-video-player's Introduction

PayPal accessibility logo

#Accessible HTML5 Video Player

by the PayPal Accessibility Team

See the Authors section below for details.

What is it?

A lightweight HTML5 video player which includes support for captions and screen reader accessibility. For details, read the blog post Introducing an Accessible HTML5 Video Player on the PayPal Engineering blog.

Features

  • Provides an HTML5 video player with custom controls.
  • Supports captions; simply denote a VTT caption file using the standard HTML5 video syntax.
  • Uses native HTML5 form controls for volume (range input) and progress indication (progress element).
  • Accessible to keyboard-only users and screen reader users.
  • Option provided to set captions on or off by default (upon loading).
  • Option provided to set number of seconds by which to rewind and forward.
  • The width adjusts to the width of the video element.
  • No dependencies. Written in "vanilla" JavaScript.
  • When JavaScript is unavailable, the browser's native controls are used.

Implementation

###CSS and Image Insert the CSS in the Head of your HTML document. You'll also need to upload the sprite image (or use your own) and adjust the path in the CSS file.

<link rel="stylesheet" href="/css/px-video.css" />

###HTML Insert the HTML5 video markup in the Body of your HTML document. Replace the video, poster, and caption URLs. Modify the sizes of video and fallback image as needed.

<div class="px-video-container" id="myvid">
	<div class="px-video-img-captions-container">
		<div class="px-video-captions hide" aria-hidden="true"></div>
		<video width="640" height="360" poster="media/foo.jpg" controls>
			<source src="foo.mp4" type="video/mp4" />
			<source src="foo.webm" type="video/webm" />
			<track kind="captions" label="English captions" src="media/foo.vtt" srclang="en" default />
			<div>
				<a href="foo.mp4">
					<img src="media/foo.jpg" width="640" height="360" alt="download video" />
				</a>
			</div>
		</video>
	</div>
	<div class="px-video-controls"></div>
</div>

###JavaScript Insert the JavaScript file right before the closing Body element of your HTML document. Add a Script element to initialize the video. Options are passed in JSON format. The options are:

  • videoId: the value of the ID of the widget container (string) [required]
  • captionsOnDefault: denotes whether to show or hide caption upon loading (boolean) [optional, default is true]
  • seekInterval: the number of seconds to rewind and fast forward (whole number) [optional, default is 10]
  • videoTitle: short title of video; used for aria-label attribute on Play button to clarify to screen reader user what will be played (text) [optional, default is "Play"]
  • debug: turn console logs on or off (boolean) [optional, default is false]
<script src="js/px-video.js"></script>
<script>
// Initialize
new InitPxVideo({
	"videoId": "myvid",
	"captionsOnDefault": true,
	"seekInterval": 20,
	"videoTitle": "clips of stand-up comedy",
	"debug": true
});
</script>

Live Demo

View Demo

Feedback and Contributions

If you experience any errors or if you have ideas for improvement, please feel free to open an issue or send a pull request.

You can also follow and contact the PayPal Accessibility team on Twitter: @PayPalInclusive

Authors

Browser Support

  • Chrome: full support.
  • Safari: full support.
  • Firefox: full support.
  • Internet Explorer 10, 11: full support.
  • Internet Explorer 9: native video player used (aesthetic choice since HTML5 range input and progress element are not supported).
  • Internet Explorer 8: renders fallback content of video element (in the demo, this is an image linked to the video file).
  • Smartphones and tablets: controls and captions are not customized as both are natively supported in latest versions.

Limitations and Known Issues

  • Currently, only one caption file per video is supported.
  • Only VTT caption files are supported (not SRT nor TTML). VTT cue settings are not supported but inline styles function (see first few lines of example).
  • The controls have a minimum width of 360px.

Related Resources

Copyright and License

Copyright 2014, eBay Software Foundation under the BSD license.

accessible-html5-video-player's People

Contributors

antonjb avatar pborreli avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.