Accessible HTML5 Video Player

Overview

Accessible HTML5 Video Player

paypal javascript

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 (updated link). Also see 7 Lessons from Developing an Accessible HTML 5 Video Player.

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.
  • Text strings for the controls are externalized to allow for internationalization (fall 2015).
  • No dependencies. Written in "vanilla" JavaScript.
  • When JavaScript is unavailable, the browser's native controls are used.
  • React support

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 two JavaScript files 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:

option description dataType default
videoId the value of the ID of the widget container string required
captionsOnDefault denotes whether to show or hide caption upon loading boolean optional true
seekInterval the number of seconds to rewind and fast forward number optional 10
videoTitle short title of video; used for aria-label attribute on Play button to clarify to screen reader user what will be played string optional Play
debug turn console logs on or off boolean optional false
<script src="js/strings.js"></script>
<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>

View Demo

React Version

The React version has been designed to be integrated into your react codebase easily. The video React component is named PXvideo and has the below API:

<PXVideo
    sources={[
    'https://www.paypalobjects.com/webstatic/mktg/videos/PayPal_AustinSMB_baseline.mp4',
    'https://www.paypalobjects.com/webstatic/mktg/videos/PayPal_AustinSMB_baseline.webm'
  ]}
  caption={{
    label: 'English captions',
    source: 'media/captions_PayPal_Austin_en.vtt',
    lang: 'EN',
    default: true
  }}
  poster="media/poster_PayPal_Austin2.jpg"
  width="640"
  height="360"
  controls={true}
  id="myvid"
  fallback={true}
  seekInterval={20}
  debug={true}
/>

A demo could be reached at: View Demo

Development

npm install // install dependencies
npm run react // transpile .jsx into valid .js using Babel

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 No longer exists.

Authors/Maintainer

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

Projects influenced by the PayPal Accessible HTML5 Video Player

Copyright and License

Copyright 2019, PayPal under the BSD license.

Comments
  • Added fullscreen functionality.

    Added fullscreen functionality.

    Added fullscreen functionality addressing issue #6. I made it so that it will utilize the same video controls (note the styling may need to be tweaked on these) and it also blows up the captions to make them bigger. I didn't have a fullscreen icon to add so I simply reused the captions icon in place of it. If someone could add a new icon to the spritesheet and then update the styles, that would be great :)

    I made it so that you can also press Enter to go into fullscreen mode (this you can probably remove if you wish). Also I was required to set a keyup event on the Esc because for some reason the Fullscreen API doesn't let you e.preventDefault() so it wouldn't let me revert styles when hitting Esc unless I did that.

    More information on Fullscreen API can be found here: https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode

    Please note the Fullscreen API is not supported in IE 10 and lower.

    This hasn't been fully tested in all browsers. Let me know if there's anything else I can help with! Thanks a lot for the awesome video player!

    opened by augbog 16
  • Responsive player dimensions

    Responsive player dimensions

    This player as-is is not responsive. Javascript writes a fixed width in px to the wrapper div, and also to the video element when escaping from full-screen. Ideally width should be 100% and height auto. Maximum width could be handled by CSS and/or wrapper elements.

    opened by dripl 12
  • why does docs/ have duplicate versions of css and js?

    why does docs/ have duplicate versions of css and js?

    it seems that docs/css/ and docs/js/ are duplicates of css/ and js/.

    Does it make sense to symlink one of them so we have 1 copy? Happy to submit a PR for this

    opened by mreinstein 11
  • Captions are not automatically read by screen readers when they appear/change

    Captions are not automatically read by screen readers when they appear/change

    On the element which holds the captions, add the following attributes:

    • aria-live="polite"
    • aria-atomic="true"

    I'd be happy to help test this with both Jaws and NVDA.

    opened by cannona 8
  • add responsiveness. support svg controls. #76

    add responsiveness. support svg controls. #76

    Merged all of the code changes from https://source.ind.ie/project/video-player back into this original project (except for the license changes and branding which remain the same.)

    Let me know if you have any issues or changes that you need prior to merging, happy to help!

    opened by mreinstein 7
  • Seek bar is 20 seconds off from mouse location

    Seek bar is 20 seconds off from mouse location

    When I'm trying to use the seek bar, the progress is being applied 20s (approximately an inch to the right) of where I'm clicking.

    Upon inspection, it looks like this.offsetLeft is always producing 0, not the offset from the side of the screen.

    screen shot 2017-11-07 at 10 32 56 am

    opened by dstrivelli 7
  • open to using a sass compiler for css?

    open to using a sass compiler for css?

    @hozefaj wondering if y'all would be open to moving the css to https://sass-lang.com

    Would be happy to send a PR with this if it would be welcome. Definitely not looking to override library/design decisions, so no biggie if this really isn't wanted. I do think it could be a nice addition and cut down on some of the repeated boilerplate in the .css though.

    opened by mreinstein 6
  • Bug: disabled CC shown again when exiting full screen mode

    Bug: disabled CC shown again when exiting full screen mode

    When CC are disabled by the user, and the user enters full screen mode, and exits it again, the CCs are shown again, even the CC button is clearly in the disabled state. Can this be fixed? :)

    opened by medonja 6
  • Seeking unreliable if users wish to position video-player-controls elsewhere

    Seeking unreliable if users wish to position video-player-controls elsewhere

    As of right now the way the progress bar has been implemented is if a user wishes to seek, the library will determine where the user wishes to seek based on where the user has clicked relative to the page.

    // Skip when clicking progress bar
    obj.progressBar.addEventListener('click', function(e) {
        obj.pos = (e.pageX - this.offsetLeft)/ this.offsetWidth;
        obj.movie.currentTime = obj.pos * obj.movie.duration;
    
        // Special handling for "manual" captions
        if (!obj.isTextTracks) {
            adjustManualCaptions(obj);
        }
    });
    

    If a user wants to move the video-player to a different location on the screen, I have found issues with seeking.

    To be honest, I actually feel a slider (input[type="range"]) might be more appropriate for showing the progress of the video?

    Pros:

    • you can change the value similar to how you change the <progress> element to show progress while the video is playing
    • you can easily retrieve the value the user seeks to.

    Cons:

    • trouble adding color before slider thumb -- might have to use JS? currently solution I have only works in webkit and not Firefox
    • it seems that input[type="range"] doesn't interpret floats so the progress of the video looks jumpy

    Was hoping to get thoughts on this? I might submit a pull request when I have more done. I started a branch on my repository here and got some partial functionality going.

    opened by augbog 6
  • React Demo link broken

    React Demo link broken

    Under "React Version" heading: A demo could be reached at: View Demo

    The link is: http://paypal.github.io/accessible-html5-video-player/index.react.html

    opened by weboverhauls 4
  • IE 11 Issue on full screen view

    IE 11 Issue on full screen view

    The video player does'nt work well in IE11 Full screen view. The view size of the video doesnt change but stick to the right.

    On IE inspect, the screen flickers a lot.

    opened by tondesign 4
  • screen reader read 'midnight' when reading out 00:00 instead of reading it as a timestamp

    screen reader read 'midnight' when reading out 00:00 instead of reading it as a timestamp

    The windows screen reader reads timestamps as a time of day rather than a time since the start of the video.

    This should be updated to not confuse users who use screen readers.

    opened by joshjm 0
  • Demo Sizing Doesn't show Caption display

    Demo Sizing Doesn't show Caption display

    When I opened the demo for the first time and scrolled down, I started the video. I toggled CC on an off, not seeing an effect, realizing later that the captions were turning on and off, out of viewport.

    1. Captions not in the 'expected' location
    2. Captions were not near the control, so the action was not evident.

    I think the main issue is just the full-width setting of the demo, allows the top player to go offscreen, so the full video and controls are not contained in the viewport.

    To reproduce, view the demo in FF responsive design mode, 1440x900 display.

    CroppedScreenShotOfDemo

    opened by miwebguy 0
  • General Features Inquiry

    General Features Inquiry

    Wanted to ask a few questions about feature support:

    • what types of streams are supported? HLS? DASH?
    • is there in-built tracking?
    • native mobile support?
    • is there a test runner like karma?
    • what audio types are supported?
    • are there thumbnail previews?
    • mirroring/ over the air support?
    • external video support?
    • i18n?
    • VR?
    • what's the build system?
    • is it extendable?
    opened by iqradada 2
  • How to add VR play button?

    How to add VR play button?

    Very good, but I think it would be even better if you add the VR button function. Just separate the screen from the middle, there is no 360° gyroscope function. This way I can watch VR on my phone.

    opened by ancct 0
  • How to use the react version?

    How to use the react version?

    When I tried to install the react module, unable to find the corresponding module

    npm i PXvideo × Install fail! Error: GET http://registry.npm.taobao.org/PXvideo response 404 status

    opened by Kunoky 2
HTML5

One file. Any browser. Same UI. Author: John Dyer http://j.hn/ Website: http://mediaelementjs.com/ License: MIT Meaning: Use everywhere, keep copyrigh

MediaElement.js 8k Jan 8, 2023
Video.js - open source HTML5 & Flash video player

Video.js - HTML5 Video Player Video.js is a web video player built from the ground up for an HTML5 world. It supports HTML5 video and Media Source Ext

Video.js 34.8k Jan 5, 2023
SRS Player is a video streaming player, supports HLS/HTTP-FLV/WebRTC etc.

WordPress-Plugin-SrsPlayer SRS Player is a video streaming player, supports HLS/HTTP-FLV/WebRTC etc. Usage First, you should get your own video stream

ossrs 3 Jul 27, 2022
SRS Player is a video streaming player, supports HLS/HTTP-FLV/WebRTC etc.

SRS Player is a video streaming player, supports HLS/HTTP-FLV/WebRTC etc.

ossrs 12 Oct 15, 2022
The HTML5 video player for the web

Flowplayer website | demos | docs For the impatient Download Flowplayer Unzip Drop the folder under your server Minimal setup <!DOCTYPE html> <head>

Flowplayer 1.9k Dec 30, 2022
A web video player built for the HTML5 world using React library.

video-react Video.React is a web video player built from the ground up for an HTML5 world using React library. Installation Install video-react and pe

null 2.4k Jan 6, 2023
Music-Player - Music player application built with HTML, CSS and vanilla JavaScript

Music-Player Music player application built with HTML, CSS and vanilla JavaScrip

Karthik Umashankar 1 Feb 10, 2022
An online stem player. Inspired by but not affiliated with YEEZY TECH X KANO Stem Player.

Stem Player Online An online stem player. Inspired by but not affiliated with YEEZY TECH X KANO Stem Player. https://stemplayeronline.com See the proj

Luke Weiler 23 Nov 13, 2022
Movie focused HTML5 Player

Movie focused HTML5 Player

Bruno Vieira 1.6k Dec 29, 2022
A simple HTML5, YouTube and Vimeo player

Plyr is a simple, lightweight, accessible and customizable HTML5, YouTube and Vimeo media player that supports modern browsers. Checkout the demo - Do

Sam Potts 23.1k Jan 3, 2023
AmplitudeJS: Open Source HTML5 Web Audio Library. Design your web audio player, the way you want. No dependencies required.

Documentation • Examples • Tutorials • Support Us • Get Professional Help AmplitudeJS is a lightweight JavaScript library that allows you to control t

Server Side Up 3.9k Jan 2, 2023
HTML5 fmp4 live stream (ll-fmp4) player written in TypeScript

umataste HTML5 fmp4 live stream (ll-fmp4) player written in TypeScript Feature Playback for fmp4 stream Extremely low latency of less than 0.1 second

もにょ~ん 5 Oct 21, 2022
Modern browsers already had a vivid player for video

Modern browsers already had a vivid player for video. However, web developers and designers still want to custom their own style player for different situations. Sounds like web component will do a lot favor for this purpose. With <msc-ez-video /> support, customize control panel will become a piece of cake. <msc-ez-video /> adopts CSS custom properties, developers could style them as they want.

Paul 1 Dec 29, 2021
Custom full screen video player

Video Player Native video player in html View Demo · Report Bug · Request Feature About The Project This is a custom video player for the web built on

Oscar Castaneda ⬢ 5 Feb 3, 2022
a video player framework aims to bring wonderful experience on browser

Chimee English | 中文 Introduction Chimee is a web video player created by the Qiwoo Team. It's based on the web video element. It supports multiple med

ChimeeJS 2.4k Dec 22, 2022
A high-performance, interactive and customizable video player control, built upon Reanimated v2 & GestureHandler v2

`JSThread` to `JSThread`, `UIThread` to `UIThread`. React Native Reanimated Expo Player 100% written in Typescript video player component, interaction

Alan Toa 58 Jan 4, 2023
This is a simple web based media player for playing video and audio. Build with pure HTML, CSS and Javascript. No framework or library included.

Aim-Player This is a simple web based media player for playing video and audio. Build with pure HTML, CSS and Javascript. No framework or library incl

Aim Mikel 2 Jun 27, 2021
Video Player

aksVideoPlayer.js Video Player View the Demo on CodePen → Getting Started Compiled and production-ready code can be found in the dist directory. 1. In

Ahmet Aksungur 5 Oct 22, 2021
jPlayer : HTML5 Audio & Video for jQuery

jPlayer : HTML5 Audio & Video for jQuery Gitter Support for Zepto 1.0+ compiled with the data module. What is jPlayer? jPlayer is a jQuery/Zepto plugi

jPlayer 4.6k Dec 27, 2022