-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(player): show title in default layout
- Loading branch information
Showing
7 changed files
with
61 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 17 additions & 5 deletions
22
packages/vidstack/src/elements/define/layouts/default/ui/title.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import { html } from 'lit-html'; | ||
import { signal } from 'maverick.js'; | ||
|
||
import { useMediaContext, useMediaState } from '../../../../../core/api/media-context'; | ||
import type { TextTrack } from '../../../../../core/tracks/text/text-track'; | ||
import { watchActiveTextTrack } from '../../../../../core/tracks/text/utils'; | ||
import { $signal } from '../../../../lit/directives/signal'; | ||
|
||
export function DefaultTitle() { | ||
return html`<media-title class="vds-title"></media-title>`; | ||
return $signal(() => { | ||
const { textTracks } = useMediaContext(), | ||
{ title, started } = useMediaState(), | ||
$hasChapters = signal<TextTrack | null>(null); | ||
|
||
watchActiveTextTrack(textTracks, 'chapters', $hasChapters.set); | ||
|
||
return $hasChapters() && (started() || !title()) | ||
? DefaultChapterTitle() | ||
: html`<media-title class="vds-chapter-title"></media-title>`; | ||
}); | ||
} | ||
|
||
export function DefaultChapterTitle() { | ||
return html`<media-chapter-title class="vds-chapter-title"></media-chapter-title>`; | ||
} | ||
|
||
export function DefaultTitleGroup() { | ||
return html`<div class="vds-title-group">${DefaultTitle()}${DefaultChapterTitle()}</div>`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters