Code Monkey home page Code Monkey logo

hlsprovider's Introduction

HLSProvider

An Open-source HLS Flash plugin that allows you to play HLS streams.

The plugin is compatible with the following players:

Features

  • VoD & Live playlists
    • Sliding window (aka DVR) support on Live playlists
  • Adaptive streaming
  • Configurable seeking method on VoD & Live
    • Accurate seeking to exact requested position
    • Key frame based seeking (nearest key frame)
    • Segment based seeking (beginning of segment)
  • AES-128 decryption
  • Buffer progress report
  • Error resilience
    • Retry mechanism on I/O errors
    • Recovery mechanism on badly segmented TS streams

Supported M3U8 tags

  • #EXTM3U
  • #EXTINF
  • #EXT-X-STREAM-INF (Multiple bitrate)
  • #EXT-X-ENDLIST (VoD / Live playlist)
  • #EXT-X-MEDIA-SEQUENCE
  • #EXT-X-TARGETDURATION
  • #EXT-X-DISCONTINUITY
  • #EXT-X-DISCONTINUITY-SEQUENCE
  • #EXT-X-PROGRAM-DATE-TIME (optional, used to synchronize time-stamps and sequence number when switching from one level to another)
  • #EXT-X-KEY (AES-128 method supported only)
  • #EXT-X-BYTERANGE

Configuration

The plugin accepts several optional configuration options, such as:

  • hls_debug (default false) - Toggle debug traces, outputted on JS console
  • hls_debug2 (default false) - Toggle verbose debug traces, outputted on JS console
  • hls_minbufferlength (default -1) - Minimum buffer length in seconds that needs to be reached before playback can start (after seeking) or restart (in case of empty buffer)
    • If set to -1 some heuristics based on past metrics are used to define an accurate value that should prevent buffer to stall
  • hls_lowbufferlength (default 3) - Low buffer threshold in seconds. When crossing down this threshold, HLS will switch to buffering state, usually the player will report this buffering state through a rotating icon. Playback will still continue.
  • hls_maxbufferlength (default 60) - Maximum buffer length in seconds (0 means infinite buffering)
  • hls_startfromlowestlevel (default false) - If set to true, playback will start from lowest non-audio level after manifest download. If set to false, playback will start from level matching download bandwidth
  • hls_seekfromlowestlevel (default false) - If set to true, playback will start from lowest non-audio level after any seek operation. If set to false, playback will start from level used before seeking
  • hls_live_flushurlcache (default false) - If set to true, Live playlist will be flushed from URL cache before reloading (this is to workaround some cache issues with some combination of Flash Player / IE version)
  • hls_seekmode
    • "ACCURATE" - Seek to exact position
    • "KEYFRAME" - Seek to last keyframe before requested position
    • "SEGMENT" - Seek to beginning of segment containing requested position
  • hls_manifestloadmaxretry (default -1): max number of Manifest load retries after I/O Error.
    • if any I/O error is met during initial Manifest load, it will not be reloaded. an HLSError will be triggered immediately.
    • After initial load, any I/O error will trigger retries every 1s,2s,4s,8s (exponential, capped to 64s). please note specific handling for these 2 values :
      • 0, means no retry, error message will be triggered automatically
      • -1 means infinite retry
  • hls_fragmentloadmaxretry (default -1): max number of Fragment load retries after I/O Error.
    • any I/O error will trigger retries every 1s,2s,4s,8s (exponential, capped to 64s). please note specific handling for these 2 values :
      • 0, means no retry, error message will be triggered automatically
      • -1 means infinite retry
  • hls_capleveltostage (default false) : cap levels usable in auto quality mode to the one with width smaller or equal to Stage Width.
    • true : playlist WIDTH attribute will be used and compared with Stage width. if playlist Width is greater than Stage width, this level will not be selected in auto quality mode. However it could still be manually selected.
    • false : don't cap levels, all could be used in auto-quality mode.

Examples :

Usage

  • Download HLSProvider from https://github.com/mangui/HLSprovider/releases
  • Unzip, extract and upload the appropiate version to your server
  • In the examples directory you will find examples for JW Player, Flowplayer, Strobe Media Playback (SMP) and GrindPlayer

Setup


JW Player 6

Please keep in mind that HLSprovider works only with the Free edition of JW Player 6

jwplayer("player").setup({
  // JW Player configuration options
  // ...
  playlist: [
    {
      file: 'http://mysite.com/stream.m3u8',
      provider: 'HLSProvider6.swf',
      type: 'hls'
    }
  ],
  // HLSProvider configuration options
  hls_debug: false,
  hls_debug2: false,
  hls_minbufferlength: -1,
  hls_lowbufferlength: 2,
  hls_maxbufferlength: 60,
  hls_startfromlowestlevel: false,
  hls_seekfromlowestlevel: false,
  hls_live_flushurlcache: false,
  hls_seekmode: 'ACCURATE'
});

JW Player 5

jwplayer("player").setup({
  // JW Player configuration options
  // ...
  modes: [
    {
      type: 'flash',
      src: 'player.swf',
      config: {
        provider: 'HLSProvider5.swf',
        file: 'http://example.com/stream.m3u8'
      }
    }, {
      type: 'html5',
      config: {
        file: 'http://example.com/stream.m3u8'
      }
    }
  ],
  // HLSProvider configuration options
  hls_debug: false,
  hls_debug2: false,
  hls_minbufferlength: -1,
  hls_lowbufferlength: 2,
  hls_maxbufferlength: 60,
  hls_startfromlowestlevel: false,
  hls_seekfromlowestlevel: false,
  hls_live_flushurlcache: false,
  hls_seekmode: 'ACCURATE'
});

Flowplayer

flowplayer("player", 'http://releases.flowplayer.org/swf/flowplayer-3.2.12.swf', {
  // Flowplayer configuration options
  // ...
  plugins: {
    httpstreaming: {
      // HLSProvider configuration options
      url: 'HLSProviderFlowPlayer.swf',
      hls_debug: false,
      hls_debug2: false,
      hls_lowbufferlength: 3,
      hls_minbufferlength: 8,
      hls_maxbufferlength: 60,
      hls_startfromlowestlevel: false,
      hls_seekfromlowestlevel: false,
      hls_live_flushurlcache: false,
      hls_seekmode: 'ACCURATE'
    }
  }
});

Strobe Media Playback (SMP) and other OSMF based players

var playerOptions = {
  // Strobe Media Playback configuration options
  // ...
  source: 'http://example.com/stream.m3u8',
  // HLSProvider configuration options
  plugin_hls: "HLSProvider.swf",
  hls_debug: false,
  hls_debug2: false,
  hls_minbufferlength: -1,
  hls_lowbufferlength: 2,
  hls_maxbufferlength: 60,
  hls_startfromlowestlevel: false,
  hls_seekfromlowestlevel: false,
  hls_live_flushurlcache: false,
  hls_seekmode: 'ACCURATE'
};

swfobject.embedSWF('StrobeMediaPlayback.swf', 'player', 640, 360, '10.2', null, playerOptions, {
  allowFullScreen: true,
  allowScriptAccess: 'always',
  bgColor: '#000000',
  wmode: 'opaque'
}, {
  name: 'player'
});

License

  • MPL 2.0
  • JW Player files are governed by a CC BY-NC-SA 3.0 license
  • as3crypto.swc is governed by a BSD license

Donation

If you'd like to support future development and new product features, please make a donation via PayPal. These donations are used to cover my ongoing expenses - web hosting, domain registrations, and software and hardware purchases.

Donate


Bitdeli Badge

hlsprovider's People

Contributors

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