Skip to content

Commit

Permalink
Merge pull request #52 from Uscreen-video/next
Browse files Browse the repository at this point in the history
fix(Timeline): hide timeline if duration is 0
  • Loading branch information
timaramazanov authored Jul 1, 2024
2 parents c0b0254 + 4bedbc8 commit afd4b8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 10 additions & 3 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 Expand Up @@ -344,7 +351,7 @@ export class VideoContainer extends LitElement {
case "loadeddata":
dispatch(this, Types.Action.updateDuration, {
initialized: true,
duration: getVideoDuration(video),
duration: getVideoDuration(video)
});
break;
case "ratechange":
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 || this.duration === Infinity) return nothing

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

0 comments on commit afd4b8f

Please sign in to comment.