-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(player): rework layout loading in player class constructors
- Loading branch information
Showing
8 changed files
with
82 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { DefaultLayoutProps } from '../../components'; | ||
import type { VidstackPlayerLayoutLoader } from './loader'; | ||
|
||
export class VidstackPlayerLayout implements VidstackPlayerLayoutLoader { | ||
constructor(readonly props?: Partial<DefaultLayoutProps>) {} | ||
|
||
async load() { | ||
await import('../../elements/bundles/player-layouts/default'); | ||
await import('../../elements/bundles/player-ui'); | ||
} | ||
|
||
create() { | ||
const layouts = [ | ||
document.createElement('media-audio-layout'), | ||
document.createElement('media-video-layout'), | ||
]; | ||
|
||
if (this.props) { | ||
for (const [prop, value] of Object.entries(this.props)) { | ||
for (const el of layouts) el[prop] = value; | ||
} | ||
} | ||
|
||
return layouts; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface VidstackPlayerLayoutLoader { | ||
load(): void | Promise<void>; | ||
create(): HTMLElement[] | Promise<HTMLElement[]>; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { PlyrLayoutProps } from '../../components'; | ||
import type { VidstackPlayerLayoutLoader } from './loader'; | ||
|
||
export class PlyrLayout implements VidstackPlayerLayoutLoader { | ||
constructor(readonly props?: Partial<PlyrLayoutProps>) {} | ||
|
||
async load() { | ||
await import('../../elements/bundles/player-layouts/plyr'); | ||
} | ||
|
||
create() { | ||
const layout = document.createElement('media-plyr-layout'); | ||
|
||
if (this.props) { | ||
for (const [prop, value] of Object.entries(this.props)) { | ||
layout[prop] = value; | ||
} | ||
} | ||
|
||
return [layout]; | ||
} | ||
} |
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