Movie focused HTML5 Player

Overview

Demo ▪️ Installation ▪️ Shortcuts ▪️ API ▪️ WebTorrent ▪️ Events ▪️ Styling ▪️ Settings

◼️ Features:

  • 🔧 Fully customizable
  • 💎 Built-in caption offset adjust on the fly
  • 🌠 Adjust speed on the fly
  • 🎬 Built-in support for .vtt and .srt caption files
  • 🖊 Add tracks/captions dynamically
  • 🛠 Standardized events / shortcuts / API
  • 🖌 Caption customization
  • 💪 No dependencies, built with VanillaJS
  • 🌎 Tested in all modern browsers
  • 💻 Responsive

◼️ Demo:

https://bmsvieira.github.io/moovie.js/

◼️ Installation:

1 - Include JavaScript Source.

<script src="path/to/moovie.js"></script>

2 - Include Styles.

<link rel="stylesheet" href="path/to/moovie.css">

3 - Set HTML.

<video id="example" poster="<>">
  <source src="<>" type="video/mp4">
  <track kind="captions" label="Portuguese" srclang="pt" src="<>">
  <track kind="captions" label="English" srclang="en" src="<>">
  Your browser does not support the video tag.
video>

4 - Initilize.

document.addEventListener("DOMContentLoaded", function() {
   var demo = new Moovie({
     selector: "#example",
     dimensions: {
          width: "100%"
     }
   });
});
Note: Do not forget to include "icons" folder.

◼️ CDN:

You can use our CDN (provided by JSDelivr) for the JavaScript and CSS files.

// Javascript
<script src="https://cdn.jsdelivr.net/gh/BMSVieira/moovie.js@latest/js/moovie.min.js">script>

// CSS
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/BMSVieira/moovie.js@latest/css/moovie.min.css">

◼️ Captions:

Currently it has full support for WebVTT(.vtt) and SubRip(.srt).
To add a track use the standard html as the example below.

<track kind="captions" label="<>" srclang="<>" src="<>">

◼️ Caption Offset Adjust:

It is possible to adjust the offset by a total of 10 seconds (-5 / +5) on the fly.

◼️ Shortcuts:

A player will bind the following keyboard shortcuts when it has focus.

Key Description
SpaceBar Toggle Play
K Toggle Play
F Toggle Fullscreen
C Toggle Captions
M Toggle Mute
ArrowRight Forward 5s
ArrowLeft Backward 5s
Shift+W Increase caption's size
Shift+S Decrease caption's size

◼️ API > Methods:

togglePlay: Play/Pause video

demo.togglePlay();

toggleSubtitles: Enable/Disable subtitles

demo.toggleSubtitles();

toggleFullscreen: Enable/Disable fullscreen

demo.toggleFullscreen();

destroy: Remove current player and unbinds all its events

demo.destroy();

build: Build a new player

demo.build();

addTrack: Add multiple/single captions to player

Name Type Default Description
label string New Subtitle Name of the new subtitle in the caption box
srclang string New Country designation
src string --- Path to the file [Can not be empty]
demo.addTrack({
  options : {
        0: {
            label: 'Italian',
            srclang: "it",
            src: "<
        },
        1: {
            label: 'Spanish',
            srclang: "es",
            src: "<
        }
    },
    onComplete: function(){
      console.log("Completed!");
    } 
});

change: Apply changes to current player.

Name Type Description
video > videoSrc string New video's source
video > posterSrc string New poster's source
captions > clearCaptions boolean Remove all available captions in the menu
demo.change({
     video: {
         videoSrc: "<>",
         posterSrc: "<>"
     },
     captions:{
         clearCaptions: true
     },
    onComplete: function(){
      console.log("Completed!");
    } 
});

◼️ API > Gets:

// Returns player DOM element
demo.playerElement

// Returns a boolean indicating if the current player is playing.
demo.playing

// Returns a boolean indicating if the current player is paused.
demo.paused

// Returns a boolean indicating if the current player is stopped.
demo.stopped  

// Returns a boolean indicating if the current player has finished playback.
demo.ended    

// Returns currentTime of the player. 
demo.currentTime

// Returns the duration for the current media.
demo.duration

// Returns a boolean indicating if the current player is seeking.
demo.seeking

// Returns the volume of the player.
demo.volume

// Returns a boolean indicating if the current player is muted.
demo.muted

// Returns current playRate 
demo.speed

// Returns mininum speed allowed
demo.minimumSpeed

// Returns maximum speed allowed
demo.maximumSpeed

// Returns mininum caption offset allowed
demo.minimumOffset

// Returns maximum caption offset allowed
demo.maximumOffset

// Returns current caption offset
demo.captionOffset

// Returns current source of the player
demo.source

◼️ API > Sets:

// Set currentTime to given number(seconds)
demo.currentTime = 60

// Set player's volume to given number (0.5 is half the volume)
demo.volume = 0.5

// Set player's playbackRate to given number (0.1 to 8)
demo.speed = 2

// Set player's caption offset to given number (-5 to 5)
demo.captionOffset = 2

◼️ WebTorrent:

To use moovie.js with WebTorrent, check the example below:
For more info read WebTorrent documentation.


<script src="//cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js">script>
// Initialize moovie
var demo = new Moovie({ selector: "#example"});

// Get new generated player id
var videoElement = demo.playerElement.id;

// Intialize webtorrent
var client = new WebTorrent();
 
// Torrent hash
var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.webtorrent.io&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel-1024-surround.mp4';

// Find .mp4 content from torrent hash and render to moovie element
client.add(torrentId, function (torrent) {
  var file = torrent.files.find(function(file) {
     return file.name.endsWith('.mp4');
  });
   
  // Render to
  var container = document.getElementById(videoElement);
  file.renderTo(container);
});

◼️ Events:

Using Standard Media Events you can listen for events on the target element you setup. check the example below:

demo.video.addEventListener("canplay", function() {
    // Your Code Here
}, true);
Event Description
abort Sent when playback is aborted; for example, if the media is playing and is restarted from the beginning, this event is sent.
canplay Sent when enough data is available that the media can be played, at least for a couple of frames.
canplaythrough Sent when the readyState changes to HAVE_ENOUGH_DATA, indicating that the entire media can be played without interruption, assuming the download rate remains at least at the current level.
durationchange The metadata has loaded or changed, indicating a change in duration of the media.
emptied The media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the load() method is called to reload it.
error Sent when an error occurs. The element's error attribute contains more information.
interruptbegin Sent when audio playing on a Firefox OS device is interrupted, either because the app playing the audio is sent to the background, or audio in a higher priority audio channel begins to play.
interruptend Sent when previously interrupted audio on a Firefox OS device commences playing again — when the interruption ends.
loadeddata The first frame of the media has finished loading.
loadedmetadata The media's metadata has finished loading; all attributes now contain as much useful information as they're going to.
loadstart Sent when loading of the media begins.
pause Sent when the playback state is changed to paused (paused property is true).
play Sent when the playback state is no longer paused, as a result of the play method, or the autoplay attribute.
playing Sent when the media has enough data to start playing, after the play event, but also when recovering from being stalled, when looping media restarts, and after seeked, if it was playing before seeking.
progress Sent periodically to inform interested parties of progress downloading the media. Information about the current amount of the media that has been downloaded is available in the media element's buffered attribute.
ratechange Sent when the playback speed changes.
seeked Sent when a seek operation completes.
seeking Sent when a seek operation begins.
stalled Sent when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming.
suspend Sent when loading of the media is suspended; this may happen either because the download has completed or because it has been paused for any other reason.
timeupdate The time indicated by the element's currentTime attribute has changed.
volumechange Sent when the audio volume changes (both when the volume is set and when the muted attribute is changed).
waiting Sent when the requested operation (such as playback) is delayed pending the completion of another operation (such as a seek).

◼️ Styling > Colors:

Using CSS Custom Properties you can easily customize your own player.
Check below a list of variables and what they are used for:

Name Description Default
--moovie_main_color Moovie main color #3191f7
--moovie_bg_controls Background color when hover the buttons rgba(16, 34, 62, 0.6)
--moovie_bg_submenu Submenu background color #f7f7f7
--moovie_bg_cuetimer Cuetimer background color #2b2b2b
--moovie_submenu_options_fcolor Submenu text color #515151
--moovie_topic_submenu_fcolor Submenu topic text color #797979
--moovie_currenttime_color CurrentTime text color white
--moovie_submenu_options_fsize Submenu options font size 10pt
--moovie_topic_submenu_fsize Submenu topic font size 9pt
--moovie_currenttime_fsize CurrentTime font size 11pt
--moovie_cuetimer_fsize Cuetimer font size 9pt
--moovie_svgicons_width Icons size 15px
--moovie_padding_controls Control bar padding 13px
--moovie_caption_fcolor Captions text color white
--moovie_cuetimer_fcolor Cuetimer text color white

◼️ Styling > Icons:

moovie uses .svg icons that are stored in the icons folder that is located by default in the root, however, you can specify a new location in the config options.

config: {
    icons: {
        path: "./path/to/folder/"
    }
}

Folder structure:

moovie/
├── icons/
│   ├── back.svg
│   ├── caption.svg
│   ├── cc.svg
│   ├── cog.svg
│   ├── fullscreen.svg
│   ├── mute.svg
│   ├── next.svg
│   ├── pause.svg
│   ├── play.svg
│   ├── volume.svg
|
├── css/
│   ├── moovie.css
|
├── js/
│   ├── moovie.js

◼️ Settings:

Option Type Description
selector String Specify ID of the element
dimensions > width string Width of the player (you must specify the type: px, %, etc..)
config > storage > captionOffset boolean Indicates whether caption's offset adjust will be stored or not
config > storage > playrateSpeed boolean Indicates whether Play Speed will be stored or not
config > storage > captionSize boolean Indicates whether caption's size will be stored or not
config > icons > path string Specify icons folder location

Full Example:

document.addEventListener("DOMContentLoaded", function() {
  var demo = new Moovie({
    selector: "#example",
    dimensions: {
         width: "100%"
    },
    config: {
        storage: {
           captionOffset: false,
           playrateSpeed: false,
           captionSize: false
        }
    },
    icons: {
        path: "./path/to/folder/"
    }
  });
});
Comments
  • Add Option for skip certain parts of the video

    Add Option for skip certain parts of the video

    It would be a nice feature to have, having a button that would appear if the option was selected or had any value, being able to skip from a certain time to another, like when its a recap or the intro of a episode, or even for the next episode at a certain time.

    Something like the netflix player or the amazon prime.

    for the settings would be like this:

    var demo = new Moovie({
        selector: "#example",
        dimensions: {
             width: "100%"
        },
        config: {
            ...
        },
        skip: [
            {
                begin: 20, //seconds
                end: 60 //seconds
            },
            {
                begin: 2400, //seconds
                link: "source.of/next.video.mp4" //seconds
            },
        ]
    
    enhancement 
    opened by SrPatinhas 4
  • Scrubbing unmutes the sound

    Scrubbing unmutes the sound

    If you mute the audio, then scrub to a new location of the video, this unmutes the audio. This seems unintuitive to me. I believe the audio should stay muted while scrubbing until the user unmutes it.

    bug 
    opened by impressivewebs 4
  • Loading and progress bar problems

    Loading and progress bar problems

    When seeking a new position on the progress bar, the loading does not appear, or any type of information.

    image And when using another type of media, like with the webtorrent example, the progress bar should be fulfilling the parts that are available, or at least, follow the current time ball.

    bug 
    opened by SrPatinhas 1
  • Mute sound in demo then unmute sound sometimes results in no sound.

    Mute sound in demo then unmute sound sometimes results in no sound.

    Hello,

    I found this while checking out the demo. When i mute the demo and then unmute, sometimes the sound does not come back until i adjust the volume even though the volume is all the way up.

    Mac Catalina 10.15.7 Google Chrome Version 89.0.4389.114 (Official Build) (x86_64)

    1. Open demo in a fresh incognito browser session
    2. Play demo
    3. Skip forward
    4. Click mute sound button
    5. Click unmute sound button
    6. Note that sound is no longer muted, and volume is still all the way up. But there is no sound.

    I don't have a tool on my mac to show you the actual sound feedback so you can also observe the loss of sound. The issue is consistent in fresh browser session.

    moviejs 2021-04-12 at 09 56 04

    bug 
    opened by travis5491811 1
  • syntax clean up

    syntax clean up

    Great project! This PR cleans up some of the spacings and syntax differences found throughout the main file with the intention of making this awesome project more maintainable.

    Another option might be to look into using something StandardJS to prevent any bike-shedding among devs.

    opened by jveldboom 1
  • Play from a websocket stream

    Play from a websocket stream

    I have implemented a service for a "filesystem over websocket", which is a service that accepts calls in the form of JSON messages. So you have functions like "exists", "read", "write" etc etc all implemented as JSON RPC over websocket. The "real" filesystem just being the users home folder -- so that i can access that from https/ws remotely.

    Would it be possible to use your video player to handle data from websocket?

    For example, if i could have an event like this in my websocket client:

    on["data"] = function (tagId, streamId, bytes) { mooviePlayer.buffer.push (bytes); }

    Basically, pushing data into a buffer that the movieplayer is streaming from, then that would make moovie.js by par the most versatile and cool movie player out there.

    Hope you think about this, im not the only one having to use WSS for data transport

    enhancement 
    opened by quartexNOR 1
  • Subtitles settings

    Subtitles settings

    We could be able to costumize the captions, like, text-border, color, position

    When the controls are showing, the subtitles should update the position to be seen every time.

    image

    Even when in fullscreen, the subtitles size, are bigger then it should. maybe calculate with a smaller ratio?

    enhancement 
    opened by SrPatinhas 1
  • I'm building a video streaming site for Opera

    I'm building a video streaming site for Opera

    I'm building a video streaming site for Operas (2-3 hours long). I had never considered that the <video> element was not suitable for this. Moovie.js calls itself a "Movie focused HTML5 Player". What does that mean, and what's wrong with the HTML5 <video> element?

    question 
    opened by ISNIT0 1
  • This project is in desperate need of specs

    This project is in desperate need of specs

    Thanks for putting it together - looking really neat, with lots of features too. But if you don't figure out specs shortly you may end up fixing what has been fixed over and over again. And the more features are to be introduced, the more likely everything is to start falling apart... believe me I've been there.

    documentation 
    opened by nskazki 1
  • Fixes togglePlay() unhandled exception in promise

    Fixes togglePlay() unhandled exception in promise

    Brief

    Fixes the new autoplay restrictions where Play() can fail due to Chrome/Safari not registering a user interaction before the video plays (with sound).

    Summary

    Suppose a video is in an html, which will call video.play to auto-start the video. This video.html is embedded as a same-host iframe. If the user has been using the app then no problem the video autoplays fine.

    HOWEVER

    If this user takes this link and sends it to one of their friends the video autoplay will fail. In this scenario, chrome/firefox/safaria etc will actually block the video play because the user hasn't click anything yet. The clue that this has happened is that the browser invoke an exception to the promise of video.play(). However, moovie doesn't handle this because the promise is not returned to the caller.

    The solution is to change togglePlay() such that the promise is returned to the caller, where the error condition can be gracefully handled.

    This enables an attempt at autoplay, with a fallback behavior such as displaying the play.svg button to cue the user to play click the play button. Infact this is exactly the solution I'm using.

    opened by zackees 0
  • please update npm package

    please update npm package

    I found the new version tag is 1.1.6. it's turn scrubTime change from const into let. But the npm package is not updated,still 1.1.5. This caused my program to fail. Please upadate this

    bug 
    opened by hahaxiaowai 2
Releases(1.1.6)
  • 1.1.6(Apr 28, 2021)

  • 1.1.5(Apr 19, 2021)

  • 1.1.4(Apr 16, 2021)

    Release v1.1.4

    Added i18n support Added new custom event listeners captionchange, offsetchange, togglecaption CSS Improvements (#16 ) Fixed minor bugs Code Update

    Source code(tar.gz)
    Source code(zip)
  • 1.1.3(Apr 13, 2021)

    Release v1.1.3

    Added tooltips Added smooth transitions Added new API > Set (muted) Reworked Fullscreen and Sound functions Loading bar is smaller (height) Fixed minor bugs

    Source code(tar.gz)
    Source code(zip)
  • 1.1.2(Apr 10, 2021)

  • 1.1.1(Apr 10, 2021)

    Release v1.1.1

    Launched official website (https://mooviejs.com) Controls can now be hidden individually Reworked menu functions Captions can now be loaded locally (no server or upload required) Caption's Engine Improved Fixed minor bugs

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Apr 5, 2021)

    Release v1.1.0

    Introduced Plugins to Moovie Added Playlist plugin, you can now build a list of videos to be played. Overall Reworked Functions Fixed minor bugs

    Plugins: By adding plugins, it allows us to add more features to moovie without compromising the main functions, it also allows the user to select only the code they want for the features they want, making it much lighter.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.8(Mar 31, 2021)

    Release v1.0.8

    Fixed bug that when the audio is muted if scrub to a new location of the video, unmutes the audio. Added Callback function to addTrack() and change() methods Reworked sound functions Reworked shortcuts Functions Fixed minor bugs Code update

    Source code(tar.gz)
    Source code(zip)
  • 1.0.7(Mar 26, 2021)

    Release v1.0.7

    New Shortcuts Icons path can now be changed Added new css custom properties Reworked functions Fixed minor bugs Code update

    Source code(tar.gz)
    Source code(zip)
  • 1.0.6(Mar 23, 2021)

    Release v1.0.6

    Added new methods Added manual of how to integrate WebTorrent with moovie Hidden Fullscreen and volume icons on iOs Changed loading screen Added CSS custom properties Overall sound management improvements Volume level is now stored when muted/unmuted and restored to last position. Reworked functions Fixed minor bugs Code update

    Source code(tar.gz)
    Source code(zip)
  • 1.0.5(Mar 19, 2021)

    Release v1.0.5

    UX Improvements for iOs (There is still a lot of work to do) Added buffer progress bar Changed captions's size shortcuts Removed caption's positioning shortcuts Now captions are always visible when controls show up Reworked Functions Fixed Minor Bugs Code Update

    Source code(tar.gz)
    Source code(zip)
  • 1.0.4(Mar 16, 2021)

    Release v1.0.4

    Added "change" method, video's and poster's source can now be changed Added LocalStorage to store user's input to the player Caption's font size and positioning can now be changed on the fly Reworked Functions Fixed Minor Bugs Code Update

    Source code(tar.gz)
    Source code(zip)
  • 1.0.3(Mar 14, 2021)

    Release v1.0.3

    Major improvements in mobile UX Added loading screen while media is still loading Added new API Gets/Sets Reworked Functions Fixed Minor Bugs Code Update

    Source code(tar.gz)
    Source code(zip)
  • 1.0.2(Mar 13, 2021)

  • 1.0.1(Mar 12, 2021)

  • 1.0.0(Mar 12, 2021)

    First Release v1.0.0

    Built-in Caption Offset Adjust on the fly Built-in support for .vtt and .srt caption files Add Tracks/Captions dynamically Improved Responsive Behavior Standardized Shortcuts Standardized Events

    Known Bugs:

    Progress bar and backward & forward doesn't work well on touch devices due to mouse related eventListeners

    Source code(tar.gz)
    Source code(zip)
Owner
Bruno Vieira
“Make it work, make it right, make it fast.” – Kent Beck
Bruno Vieira
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 Dec 27, 2022
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
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
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
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
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
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
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
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
Accessible HTML5 Video Player

Accessible HTML5 Video Player What is it? A lightweight HTML5 video player which includes support for captions and screen reader accessibility. For de

PayPal 2.4k Jan 5, 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
An app to read a movie file, and indicate which scenes are NSFW.

The NSFW Movie Parser An app to read a movie file, and indicate which scenes are NSFW. You can download the installer for the Windows 10 version here.

dynamite-ready 70 Oct 9, 2022
Rule YouTube, Soundcloud and Vimeo player with one API

Polyplayer Polyplayer allows you to rule YouTube's, Soundcloud's and Vimeo's player using one API. Features Playing, pausing, stopping Seek to absolut

Marius 41 Sep 24, 2022
:clapper: An extensible media player for the web.

Huge changes in the latest version. See 0.4.0 version changelog for more information Clappr is an extensible media player for the web. Your architectu

Clappr 6.1k Jan 7, 2023
Radio player for audio tracks in a tezos wallet.

Hicathon 2021 | WG7 7.2 - Galleries and collections Minimal galleries for exhibitions The Team: Name Role Discord Username Twitter Username Wallet Tea

Sean Cooper 23 Jul 11, 2022
The #1 cross-platform open source music player

Rhyme The #1 Open-Source Music Player Discord: Matrix: A beautiful looking music player which supports Local music files Create custom playlists view

Rhyme Music Player 51 Apr 13, 2022
Music bot that uses Lavalink for its audio player

Msv Music ?? A Advanced Discord Music Bot Made With Lavalink And Have Many Premium Features with filters and more willl be add soon About Msv Music ??

M s v 36 Jan 4, 2022