-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(plugin-interactive-video): replace SelectVideoMode with vide…
…o plugin ui, add focus hack
- Loading branch information
Showing
12 changed files
with
79 additions
and
119 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
apps/web/src/serlo-editor-integration/serlo-plugin-wrappers/video-serlo-static-renderer.tsx
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
59 changes: 0 additions & 59 deletions
59
packages/editor/src/plugins/interactive-video/editor/select-video-mode.tsx
This file was deleted.
Oops, something went wrong.
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
6 changes: 6 additions & 0 deletions
6
packages/editor/src/plugins/video/utils/is-valid-video-url.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { parseVideoUrl } from './parse-video-url' | ||
|
||
export function isValidVideoUrl(inputSrc: string) { | ||
const [, type] = parseVideoUrl(inputSrc) | ||
return type !== undefined | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/editor/src/plugins/video/utils/parse-video-url.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { VideoType } from '../renderer' | ||
|
||
export function parseVideoUrl( | ||
inputSrc: string, | ||
lang?: string | ||
): [string, VideoType | undefined] { | ||
const videoRegex = /^(https?:\/\/)?(.*?vimeo\.com\/)(.+)/ | ||
const vimeo = videoRegex.exec(inputSrc) | ||
if (vimeo) | ||
return [ | ||
`https://player.vimeo.com/video/${vimeo[3]}?autoplay=1`, | ||
VideoType.Vimeo, | ||
] | ||
const serloAssetRegex = | ||
/^(https:\/\/assets\.serlo\.org\/wikimedia\/)(.+)(webm)$/ | ||
const serloAsset = serloAssetRegex.exec(inputSrc) | ||
if (serloAsset) return [inputSrc, VideoType.SerloAsset] | ||
|
||
// TODO: update when new asset management is live | ||
if ( | ||
inputSrc.startsWith('https://editor.serlo.dev/media/') && | ||
inputSrc.endsWith('video.webm') | ||
) { | ||
return [inputSrc, VideoType.SerloAsset] | ||
} | ||
|
||
const youtubeRegex = | ||
/^(https?:\/\/)?(.*?youtube\.com\/watch\?(.*&)?v=|.*?youtu\.be\/)([a-zA-Z0-9_-]{11})/ | ||
const youtube = youtubeRegex.exec(inputSrc) | ||
if (youtube) { | ||
const videoId = encodeURIComponent(youtube[4]) | ||
const url = new URL(inputSrc) | ||
const timestamp = parseInt(url.searchParams.get('t') ?? '') | ||
const useSubtitles = url.search.includes('cc_load_policy=1') | ||
const iframeSrc = `https://www.youtube-nocookie.com/embed/${videoId}?autoplay=1&html5=1${ | ||
useSubtitles ? `&cc_lang_pref=${lang ?? 'de'}&cc_load_policy=1` : '' | ||
}${isNaN(timestamp) ? '' : `&start=${timestamp}`}` | ||
return [iframeSrc, VideoType.YouTube] | ||
} | ||
return [inputSrc, undefined] | ||
} |