npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cycjimmy/jsmpeg-player

v6.1.2

Published

MPEG1 Video Player Based On JSMpeg

Downloads

13,227

Readme

JSMpeg Player(TS Player)

libraries dependency status libraries sourcerank Release date rollup semantic-release npm license

  • jsmpeg-player has been renamed to @cycjimmy/jsmpeg-player for scoped NPM package.
  • JSMpeg player is based on jsmpeg.
  • The video must be compressed into the TS format of MPEG1 / MP2.
  • Apple device automatically plays without sound, you need to guide the user to click on the video in the lower right corner of the video icon to unlock the sound. (no similar problem in non-autoplay mode)
  • Demo

How to use

Install

NPM version NPM bundle size npm download

$ npm install @cycjimmy/jsmpeg-player --save
# or
$ yarn add @cycjimmy/jsmpeg-player

Usage

import JSMpeg from '@cycjimmy/jsmpeg-player';
# OR
const JSMpeg = require('@cycjimmy/jsmpeg-player');
new JSMpeg.VideoElement(videoWrapper, videoUrl [, options] [, overlayOptions])
  • JSMpeg.VideoElement config:

    • videoWrapper: [String | Element] The wrapper of the video. The height and width of the wrapper are recommended to be initialized.
    • videoUrl: [String] A URL to an MPEG .ts file
    • options: [Object] support:
      • canvas: [String | Element] The HTML canvas element to use for video rendering. If none is given, the renderer will create its own canvas element. Default ''.
      • poster: [String] URL to an image to use as the poster to show before the video plays. (Recommended to set it manually)
      • autoplay: [Boolean] Whether to start playing immediately. Default false.
      • autoSetWrapperSize: [Boolean] Whether to set the wrapper element size automatically when the video loaded. Default false.
      • loop: [Boolean] Whether to loop the video (static files only). Default false.[overwrite]
      • control: [Boolean] Whether the user can control. Default true.
      • decodeFirstFrame: [Boolean] Whether to decode and display the first frame of the video. Default true.
      • picMode: [Boolean] Picture mode (no playButton). Default false.
      • progressive: [Boolean] whether to load data in chunks (static files only). Default true.
      • chunkSize [Number] The chunk size in bytes to load at a time. Default 1024*1024 (1mb).
      • hooks: [Object] The hook function
        • play: [Function] The hook function when the video play.
        • pause: [Function] The hook function when the video pause.
        • stop: [Function] The hook function when the video stop.
        • load: [Function] The hook function when the video established.
    • overlayOptions: [Object] More options can view the jsmpeg options
  • JSMpeg.VideoElement instance supports the following methods:

    • play(): Start playback
    • pause(): Pause playback
    • stop(): Stop playback and seek to the beginning
    • destroy(): Stop playback and empty video wrapper
  • JSMpeg.VideoElement.player instance API can view the JSMpeg.Player API

Use in browser

jsdelivr

<div id="videoWrapper"></div>
<script src="jsmpeg-player.umd.min.js"></script>
<script>
  var videoUrl = '../static/media/test_video.ts';
  new JSMpeg.VideoElement('#videoWrapper', videoUrl);
</script>

CDN

To use via a CDN include this in your HTML:

<script src="https://cdn.jsdelivr.net/npm/@cycjimmy/jsmpeg-player@6/dist/jsmpeg-player.umd.min.js"></script>

Encoding Video/Audio for jsmpeg by ffmpeg. E.g:

$ ffmpeg -i input.mp4 -f mpegts \
         -codec:v mpeg1video -s 640x360 -b:v 700k -r 25 -bf 0 \
         -codec:a mp2 -ar 44100 -ac 1 -b:a 64k \
         output.ts
  • options
    • -s: video size
    • -b:v: video bit rate
    • -r: frame rate
    • -ar: sampling rate
    • -ac: number of audio channels
    • -b:a: audio bit rate