-
Notifications
You must be signed in to change notification settings - Fork 49
feat(core): add native hls error handling #1190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cac84fe
feat(core): add native hls error handling
luwes b90f230
fix(core): fix native hls error handling
luwes 1eac5f4
fix(core): fix event dispatching for media
luwes f3ead55
fix(core): fix event dispatching for media proxy
luwes 47fdd63
fix(core): fix type issues
luwes 27906c6
fix(core): fix duplicate error events
luwes bb37e45
fix(core): fix event dispatching for media delegate
luwes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,14 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Sandbox — HTML Video</title> | ||
| <link rel="preconnect" href="https://rsms.me/" /> | ||
| <link rel="stylesheet" href="https://rsms.me/inter/inter.css" /> | ||
| </head> | ||
| <body class="font-sans p-2"> | ||
| <div id="root" class="flex justify-center items-center min-h-screen"></div> | ||
| <script type="module" src="./main.ts"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or 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,44 @@ | ||
| import '@app/styles.css'; | ||
| import '@videojs/html/video/player'; | ||
| import '@videojs/html/media/native-hls-video'; | ||
| import { createHtmlSandboxState, createLatestLoader } from '@app/shared/html/sandbox-state'; | ||
| import { loadVideoSkinTag } from '@app/shared/html/skins'; | ||
| import { renderStoryboard } from '@app/shared/html/storyboard'; | ||
| import { onSkinChange, onSourceChange } from '@app/shared/sandbox-listener'; | ||
| import { getPosterSrc, getStoryboardSrc, SOURCES } from '@app/shared/sources'; | ||
|
|
||
| const html = String.raw; | ||
|
|
||
| const state = createHtmlSandboxState(); | ||
| const loadLatest = createLatestLoader(); | ||
|
|
||
| async function render() { | ||
| const tag = await loadLatest(() => loadVideoSkinTag(state.skin, state.styling)); | ||
| if (!tag) return; | ||
|
|
||
| const storyboard = getStoryboardSrc(state.source); | ||
| const poster = getPosterSrc(state.source); | ||
|
|
||
| document.getElementById('root')!.innerHTML = html` | ||
| <video-player> | ||
| <${tag} class="w-full aspect-video max-w-4xl mx-auto"> | ||
| <native-hls-video src="${SOURCES[state.source].url}" playsinline crossorigin="anonymous"> | ||
| ${renderStoryboard(storyboard)} | ||
| </native-hls-video> | ||
| ${poster ? html`<img slot="poster" src="${poster}" alt="Video poster" />` : ''} | ||
| </${tag}> | ||
| </video-player> | ||
| `; | ||
| } | ||
|
|
||
| render(); | ||
|
|
||
| onSkinChange((skin) => { | ||
| state.skin = skin; | ||
| render(); | ||
| }); | ||
|
|
||
| onSourceChange((source) => { | ||
| state.source = source; | ||
| render(); | ||
| }); |
This file contains hidden or 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,14 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Sandbox — React Video</title> | ||
| <link rel="preconnect" href="https://rsms.me/" /> | ||
| <link rel="stylesheet" href="https://rsms.me/inter/inter.css" /> | ||
| </head> | ||
| <body class="font-sans p-2"> | ||
| <div id="root" class="flex justify-center items-center min-h-screen"></div> | ||
| <script type="module" src="./main.tsx"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or 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,42 @@ | ||
| import '@app/styles.css'; | ||
| import { VideoProvider } from '@app/shared/react/providers'; | ||
| import { VideoSkinComponent } from '@app/shared/react/skins'; | ||
| import { Storyboard } from '@app/shared/react/storyboard'; | ||
| import { usePoster } from '@app/shared/react/use-poster'; | ||
| import { useSkin } from '@app/shared/react/use-skin'; | ||
| import { useSource } from '@app/shared/react/use-source'; | ||
| import { useStoryboard } from '@app/shared/react/use-storyboard'; | ||
| import { SOURCES } from '@app/shared/sources'; | ||
| import type { Styling } from '@app/types'; | ||
| import { NativeHlsVideo } from '@videojs/react/media/native-hls-video'; | ||
| import { useMemo } from 'react'; | ||
| import { createRoot } from 'react-dom/client'; | ||
|
|
||
| function readStyling(): Styling { | ||
| return new URLSearchParams(location.search).get('styling') === 'tailwind' ? 'tailwind' : 'css'; | ||
| } | ||
|
|
||
| function App() { | ||
| const skin = useSkin(); | ||
| const source = useSource(); | ||
| const styling = useMemo(readStyling, []); | ||
| const poster = usePoster(); | ||
| const storyboard = useStoryboard(); | ||
|
|
||
| return ( | ||
| <VideoProvider> | ||
| <VideoSkinComponent | ||
| poster={poster} | ||
| skin={skin} | ||
| styling={styling} | ||
| className="w-full aspect-video max-w-4xl mx-auto" | ||
| > | ||
| <NativeHlsVideo src={SOURCES[source].url} playsInline crossOrigin="anonymous"> | ||
| <Storyboard src={storyboard} /> | ||
| </NativeHlsVideo> | ||
| </VideoSkinComponent> | ||
| </VideoProvider> | ||
| ); | ||
| } | ||
|
|
||
| createRoot(document.getElementById('root')!).render(<App />); |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.