Gathering detailed insights and metrics for shaka-player-react
Gathering detailed insights and metrics for shaka-player-react
Gathering detailed insights and metrics for shaka-player-react
Gathering detailed insights and metrics for shaka-player-react
npm install shaka-player-react
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
112 Stars
51 Commits
34 Forks
5 Watching
4 Branches
2 Contributors
Updated on 12 Oct 2024
Minified
Minified + Gzipped
JavaScript (96.01%)
HTML (3.99%)
Cumulative downloads
Total Downloads
Last day
15%
369
Compared to previous day
Last week
27.5%
2,764
Compared to previous week
Last month
42.5%
10,070
Compared to previous month
Last year
-18.8%
78,582
Compared to previous year
11
A React component for Shaka Player, an open-source JavaScript library for adaptive media. It is highly recommended to check the official shaka documentation first.
npm install shaka-player-react --save
yarn add shaka-player-react
As seen in the example below, the CSS bundled with shaka-player
has been imported separately. This is because shaka-player-react
does not require any CSS internally, which keeps you in full control of the styling as if you were not using this React wrapper.
1import React from 'react'; 2import ShakaPlayer from 'shaka-player-react'; 3import 'shaka-player-react/dist/controls.css'; 4 5function App() { 6 return <ShakaPlayer autoPlay src="https://streams.com/example.mpd" />; 7}
The following ShakaPlayer
properties are supported:
Property | Description | Type |
---|---|---|
src | The MPEG-DASH, or HLS media asset. Is provided to shaka.Player.load on mount or change. | String |
autoPlay | Whether the asset should autoplay or not, directly bound to the HTMLVideoElement element. | Boolean |
width | Width of the player. | Number |
height | Height of the player. | Number |
playbackRate | Sets the speed of the audio/video playback. | Number |
muted | Sets whether the video is muted or not | Boolean |
loop | Sets whether teh audio/video should start over again when finished | Boolean |
volume | Sets the volume of the audio/video | Number |
className | Adds a class to the root element, which is a div. | String |
The following is a more advanced setup to illustrate how you can integrate shaka's features in React.
1import React, { useRef, useEffect } from 'react'; 2import ShakaPlayer from 'shaka-player-react'; 3 4function App() { 5 const controllerRef = useRef(null); 6 7 useEffect(() => { 8 const { 9 /** @type {shaka.Player} */ player, 10 /** @type {shaka.ui.Overlay} */ ui, 11 /** @type {HTMLVideoElement} */ videoElement 12 } = controllerRef.current; 13 14 async function loadAsset() { 15 // Load an asset. 16 await player.load('https://streams.com/example.mpd'); 17 18 // Trigger play. 19 videoElement.play(); 20 } 21 22 loadAsset(); 23 }, []); 24 25 return <ShakaPlayer ref={controllerRef} />; 26}
Or check the example in this repository.
1import React from 'react'; 2import dynamic from 'next/dynamic'; 3 4const ShakaPlayer = dynamic(() => import('shaka-player-react'), { ssr: false }); 5 6export default function Index() { 7 return ( 8 <div> 9 <ShakaPlayer autoPlay src="https://streams.com/example.mpd" /> 10 </div> 11 ); 12}
When using next/dynamic
with { ssr: false }
, we'll make sure the component is not interpreted by Next.js SSR. As of today, pre-rendering shaka-player's UI is technically not possible due to the fact that it is not written in React (but in plain Javascript). Although, shaka-player heavily relies on browser API's and serves no real purpose on a backend anyways.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/20 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
12 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More