Skip to content

Commit

Permalink
fix(Timeline): hide timeline if duration is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
timaramazanov committed Jul 1, 2024
1 parent c0b0254 commit 8727af3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/components/video-container/Video-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ import { sourcesController, SourcesController } from "./sources";
const INIT_NATIVE_HLS_RE = /^((?!chrome|android).)*safari/i;

// In Safari on live streams video.duration = Infinity
const getVideoDuration = (video: HTMLVideoElement) =>
video.duration === Infinity ? video.seekable.end(0) : video.duration;
const getVideoDuration = (video: HTMLVideoElement) => {
if (video.duration && video.duration !== Infinity) {
return video.duration
}
if (video.seekable.length > 0) {
return video.seekable.end(0)
}
return 0
}

/**
* @slot - Video-container main content
Expand Down
5 changes: 4 additions & 1 deletion src/components/video-timeline/Video-timeline.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { unsafeCSS, LitElement, html } from "lit";
import { unsafeCSS, LitElement, html, nothing } from "lit";
import { customElement, property, query, state } from "lit/decorators.js";
import styles from "./Video-timeline.styles.css?inline";
import { connect, createCommand } from "../../state";
Expand Down Expand Up @@ -129,6 +129,9 @@ export class VideoTimeline extends DependentPropsMixin(LitElement) {

render() {
const disabled = this.disabled || !this.canPlay;

if (!this.duration) return nothing

return html`
<video-slider
with-tooltip
Expand Down

0 comments on commit 8727af3

Please sign in to comment.