GitPedia

Media stream player js

Video player built around Media Stream Library JS

From AxisCommunications·Updated April 7, 2026·View on GitHub·
·Archived

**media stream player js** is a Video player built around Media Stream Library JS The project is written primarily in TypeScript, distributed under the MIT License license, first published in 2020. Key topics include: axis, camera, ip-camera, rtp, rtp-player.

Latest release: v8.1.2Release v8.1.2
August 24, 2022View Changelog →

This project has moved to become part of media-stream-library-js

Media Stream Player JS

CI
NPM

Media Stream Player is a video player for Axis cameras based on React. The main
idea is to define the video state entirely within specialized React components
for each of the different supported formats (currently MP4 over HTTP, RTP over
WebSocket, and still images). The main video player will only handle the
intended video state (attached to handlers) and format. The player is built on
top of the
Media Stream Library
which provides basic playing functionality for the different formats.

You can either import the Player or BasicPlayer and use them directly (see
the example applications). If you want to build your own customized player, you
can look at the latter component and build your own player, using the
Container, Layer, and PlaybackArea components.

Basic requirements

This library specifically targets AXIS IP cameras because
we make underlying API-calls to AXIS specfic APIs to get the video streams.

Firmware requirements

  • For H.264 to work you need at least firmware 6.50 (LTS)
  • For MP4 to work you need at least firmware 9.80 (LTS)

Structure

Installation

As a stand-alone element

If you don't use the player as part of you React app, the easiest way to use it
is to download the media-stream-player.min.js file from the
releases
page and include it in your html file as a script:

html
<script src="media-stream-player.min.js"></script>

The bundle is built to support the browserslist "latest 2 versions, not dead",
which should work on most modern browsers. If you need support for older browsers, you can use
the (larger) legacy bundle media-stream-player.legacy.min.js instead, but note
that this isn't tested, so you might run into some issues.

Then, you can use the <media-stream-player/> tag, similar to how you would use
<video/> to include a video element, and provide the camera IP as hostname:

html
<media-stream-player hostname="192.168.0.90" />

You can find an example of this under examples/web-component.

Supported properties right now are:

PropertyComment
variantSupported choices are basic or advanced. Refers to BasicPlayer and Player.
hostnameThe ip address to your device
autoplayIf the property exists, we try and autoplay your video
autoretryIf the property exists, we try to auto retry your video on errors and if ended
secureIf the property exists, we will connect with https instead of http
formatAccepted values are JPEG, RTP_JPEG, RTP_H264, or MP4_H264
compressionAccepted values are 0..100, with 10 between each step
resolutionWritten as WidthXHeight, eg 1920x1080
rotationAccepted values are 0, 90, 180 and 270
cameraAccepted values are 0...n or quad depending on your device
RTP_H264 / RTP_JPEG / MP4_H264 specific properties
fpsAccepted values are 0...n
audioAccepted values are 0 (off) and 1 (on)
clockAccepted values are 0 (hide) and 1 (show)
dateAccepted values are 0 (hide) and 1 (show)
textAccepted values are 0 (hide text overlay) and 1 (show text overlay)
textstringA percent-encoded string for the text overlay
textcolorAccepted values are black and white
textbackgroundcolorAccepted values are black, white, transparent and semitransparent
textposAccepted values are 0 (top) and 1 (bottom)

Example:

html
<media-stream-player hostname="192.168.0.90" format="RTP_H264" autoplay />

You may need to start a localhost server to get H.264 or Motion JPEG video to
run properly. It doesn't work with the file:/// protocol. The easiest way to
do that is Pythons simpleHttpServer.

First run

bash
yarn build

to get a local copy of the minified file. Then go to the web-component example
folder and type the following in you terminal:

bash
python -m SimpleHTTPServer 8080

Then you can open up http://localhost:8080 to see the result.

Note that using anything other than the actual hostname you're hosting from
will result in CORS errors for some video formats. You'll need to proxy the
camera or load a page from the camera (in which case you can set
window.location.host as the hostname).

As part of your React application

If you want to import the player as a React component into your own code, or use
parts of the player, you'll need to install the package as a dependency. Make
sure you have Node installed on your machine.

Then, to install the package:

shell
npm install media-stream-player

or if you are using yarn:

shell
yarn add media-stream-player

You will also need to install a number of peer dependencies
such as luxon, which we use for date and time purposes,
react/react-dom, styled-components, and media-stream-library.
You can find an example of this under examples/react-app.

To run our example react app, you can start a vite dev server with:

shell
MSP_CAMERA=<YOUR_CAMERA_HOST> yarn dev

for example

shell
MSP_CAMERA=http://192.168.0.90 yarn dev

where you specify the IP of the camera you want to proxy as the MSP_CAMERA
environment variable (default is 192.168.0.90). The vite dev server will
proxy requests to the camera, so that you'll have no CORS issues for any format.

FAQ

Does this library support audio?
Yes, yes it does. With a few caveats though.

  • Make sure your AXIS camera actually supports audio
  • Make sure the audio is enabled on the camera.
  • It only works with H.264 and only after user interaction with the volume slider

Icons

The icons used are from https://github.com/google/material-design-icons/, which
are available under the Apache 2.0 license, more information can be found on:
http://google.github.io/material-design-icons

The spinner is from https://github.com/SamHerbert/SVG-Loaders, available under
the MIT license.

Contributors

Showing top 9 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from AxisCommunications/media-stream-player-js via the GitHub API.Last fetched: 6/17/2026