Git Product home page Git Product logo

mse-player's Introduction

flussonic-mse-player

flussonic-mse-player is a JavaScript library for playing video relies on flussonic backend, HTML5 video and MediaSource Extensions

Installation

npm install --save @flussonic/flussonic-mse-player

Usage

Webpack:

import FlussonicMsePlayer from '@flussonic/flussonic-mse-player'
...
const player = new FlussonicMsePlayer(element, url, opts)

example

Script tag:

Since the library include via script tag it is accesible at window.FlussonicMsePlayer

<script type="text/javascript" src="../../dist/FlussonicMsePlayer.js"></script>
var FlussonicMsePlayer = window.FlussonicMsePlayer
var player = new FlussonicMsePlayer(element, url, opts)

example

Static Methods:

  • isSupported() - return true if browser is supported Media Source Extension

  • replaceHttpByWS(url: string) - return new url where replaced http(s):// by ws(s)://

Construction:

const player = new FlussonicMsePlayer(element, url, opts)

element -

url - url of a stream

opts is plain object it can include methods:

  • debug?: boolean - if true then enable logs in browser console. And export methods humanTime, humanDate to window.

  • progressUpdateTime?: number - time period for invoking onProgress.

  • onProgress(utc: number) - triggered every 100ms(progressUpdateTime) while a stream is playing and gives current playback time

  • onMediaInfo(info: MediaInfo) - triggered when metadata of the stream is available. metadata include a common information of the stream such as width, height, information about mbr streams and so on. After this callback triggered you can use getVideoTracks()/getAudioTracks() methods.

  • onSeeked() - triggered when process of seeking is finished

  • onStartStalling() - triggered when playing is stalled

  • onEndStalling() - triggered when the video tag is progressed(start playing). onStartStalling()/onEndStalling() useful callback for implementation loading-spinner.

  • •••DEPRECATED••• bufferMode: 'segments'|'sequence' - SourceBuffer Object Append Mode. Default value is 'sequence'.

  • errorsBeforeStop: number - Amount of errors will be happened before invoke the stop() method.

Methods:

  • play(from?: UtcOrLive, videoTrack?: Track, audioTrack?: Track) => Promise - start playing.

    Return a Promise. Resolved if HTMLMediaElement.play() resolved(HTMLMediaElement.play() Returns a Promise). Overwise rejected with error message.

    if you do autoplay="true" muted="false" video. The play will be rejected(Autoplay Policy Changes)

    For resolve this behaviour you can mute the video before playing. Or you can process play's rejection and show play button.

  • pause() - send pause command by websocket

  • stop() - close websocket connection; detach mediaSource from given HTMLMediaElement; invoke the HTMLMediaElement stop method

  • seek(utc: number) - send seek command by websocket

  • setTracks(tracks: Array) -

Types:

type MediaInfo = {
  height: number,
  width: number,
  streams: Array<StreamInfo>,
  activeStreams: ActiveStreams,
}

type StreamInfo = {
  bitrate: number,
  codec: string,
  content: string,
  fps: number,
  height: number,
  length_size: number,
  level: string,
  pixel_height: number,
  pixel_width: number,
  profile: "Baseline",
  sar_height: number,
  sar_width: number,
  size: string,
  track_id: TrackId,
  width: number
}

type ActiveStreams = {
  video: TrackId,
  audio: TrackId,
}

type TrackId = 'a1'|'a2'|'a3'| ... 'aN'|'v1'|'v2'|'v3'| ... 'vN'

type UtcOrLive = number | 'live'

TODO

CHANGELOG

mse-player's People

Contributors

otmjka avatar atak3n avatar zamarawka avatar maxlapshin avatar boushley avatar keylase avatar katjadev avatar thecotne 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.