GithubHelp home page GithubHelp logo

elm-video's Introduction

Example Elm Video Player

I wanted to figure out how a video player in Elm would work, so I made one.

There were two primary challenges: sending commands to the video player (such as play and pause) and reading the state of the video player (such as current position). The first problem was solved through a port: JavaScript listens for messages and acts accordingly upon the video object. The second was solved through custom event handlers. Since each video event has a reference to the media player object, the event target can be decoded to provide the necessary information.

The assets and HTML template were taken from the 2013 article https://www.creativebloq.com/html5/build-custom-html5-video-player-9134473, which was a decent primer on how to make a custom video player. However, noting its age, there may be better ways to do parts of this at the time of writing that I am as yet unaware of.

The elm can be compiled using the following elm-make command:

elm-make src/media-player.elm --output elm.js

You can then open media-player.html in your favorite web browser and see the results. Note that the --debug flag can be added to add a debug box at the bottom which tracks internal Elm messages.

elm-video's People

Contributors

a-teammate avatar geppettodivacin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.