Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hls-video-element

Package Overview
Dependencies
Maintainers
4
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hls-video-element - npm Package Compare versions

Comparing version 0.5.1 to 1.0.0

36

hls-video-element.js

@@ -123,3 +123,6 @@ import { CustomVideoElement } from 'custom-media-element';

this.audioTracks.addEventListener('change', () => {
this.api.audioTrack = [...this.audioTracks].find(t => t.enabled).id;
const audioTrackId = [...this.audioTracks].find(t => t.enabled)?.id;
if (audioTrackId != null && audioTrackId != this.api.audioTrack) {
this.api.audioTrack = +audioTrackId;
}
});

@@ -146,11 +149,34 @@

// and lock it to the first rendition that is enabled.
const switchRendition = ({ target: renditions }) => {
const level = renditions.selectedIndex;
const switchRendition = (event) => {
const level = event.target.selectedIndex;
if (level != this.api.nextLevel) {
this.api.nextLevel = level;
smoothSwitch(level);
}
};
this.videoRenditions.addEventListener('change', switchRendition);
// Workaround for issue changing renditions on an alternative audio track.
// https://github.com/video-dev/hls.js/issues/5749#issuecomment-1684629437
const smoothSwitch = (levelIndex) => {
const currentTime = this.currentTime;
let flushedFwdBuffer = false;
const callback = (event, data) => {
flushedFwdBuffer ||= !Number.isFinite(data.endOffset);
};
this.api.on(Hls.Events.BUFFER_FLUSHING, callback);
this.api.nextLevel = levelIndex;
this.api.off(Hls.Events.BUFFER_FLUSHING, callback);
if (!flushedFwdBuffer) {
this.api.trigger(Hls.Events.BUFFER_FLUSHING, {
startOffset: currentTime + 10,
endOffset: Infinity,
type: 'video',
});
}
};
this.videoRenditions?.addEventListener('change', switchRendition);
const removeAllMediaTracks = () => {

@@ -157,0 +183,0 @@ for (const videoTrack of this.videoTracks) {

4

package.json
{
"name": "hls-video-element",
"version": "0.5.1",
"version": "1.0.0",
"description": "Custom element (web component) for playing video using the HTTP Live Streaming (HLS) format. Uses HLS.js.",

@@ -24,3 +24,3 @@ "type": "module",

"dependencies": {
"custom-media-element": "^0.2.0",
"custom-media-element": "^1.0.0",
"hls.js": "^1.4.9",

@@ -27,0 +27,0 @@ "media-tracks": "^0.2.3"

@@ -17,3 +17,3 @@ # `<hls-video>`

```html
<script type="module" src="https://cdn.jsdelivr.net/npm/hls-video-element@0.4/+esm"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/hls-video-element@1.0/+esm"></script>
<hls-video controls src="https://stream.mux.com/r4rOE02cc95tbe3I00302nlrHfT023Q3IedFJW029w018KxZA.m3u8"></hls-video>

@@ -40,3 +40,3 @@ ```

```html
<script type="module" src="https://cdn.jsdelivr.net/npm/hls-video-element@0.4/+esm"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/hls-video-element@1.0/+esm"></script>
```

@@ -43,0 +43,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc