Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #29 from stroeer/patch-always-use-hls.js
Browse files Browse the repository at this point in the history
Patch the UI to always use hls.js in seek preview
  • Loading branch information
gorillamoe authored Dec 13, 2022
2 parents db61f6b + fda0b85 commit dc05a8d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.1.2",
"version": "4.0.0",
"name": "@stroeer/stroeer-videoplayer-default-ui",
"description": "Ströer Videoplayer Default UI",
"main": "dist/StroeerVideoplayer-default-ui.cjs.js",
Expand Down
14 changes: 11 additions & 3 deletions src/UI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,18 @@ class UI {
const HlsJs = StroeerVideoplayer.getHlsJs()
const canPlayNativeHls = videoEl.canPlayType('application/vnd.apple.mpegurl') === 'probably' || videoEl.canPlayType('application/vnd.apple.mpegurl') === 'maybe'

if (!canPlayNativeHls && HlsJs.isSupported() === true) {
if (HlsJs.isSupported() === true) {
if (this.hls === null || (this.hls !== null && this.hls.url !== videoSource.src)) {
if (this.hls !== null) {
this.hls.destroy()
this.hls = null
}
this.hls = new HlsJs()
this.hls = new HlsJs({
maxBufferSize: 0,
maxBufferLength: 10,
capLevelToPlayerSize: true,
autoStartLoad: true
})
this.hls.loadSource(videoSource.src)
this.hls.attachMedia(seekPreviewVideo)

Expand All @@ -536,10 +541,13 @@ class UI {
this.hls = null
})
}
} else {
} else if (canPlayNativeHls) {
if (seekPreviewVideo.src !== videoSource.src) {
seekPreviewVideo.src = videoSource.src
}
} else {
console.error('Error trying to create seek preview: No HLS Support found')
return
}

const calculatedMaxRight = timelineContainer.offsetWidth - seekPreviewContainer.offsetWidth
Expand Down

0 comments on commit dc05a8d

Please sign in to comment.