From fedb94dd70903ba5b653bd7fc76800ddb1f2bc4d Mon Sep 17 00:00:00 2001 From: Hailey <153161762+haileyok@users.noreply.github.com> Date: Thu, 21 Dec 2023 14:33:46 -0800 Subject: 3rd party embed player (#2217) * Implement embed player for YT, spotify, and twitch * fix: handle blur event * fix: use video dimensions for twitch * fix: remove hack (?) * fix: remove origin whitelist (?) * fix: prevent ads from opening in browser * fix: handle embeds that don't have a thumb * feat: handle dark/light mode * fix: ts warning * fix: adjust height of no-thumb label * fix: adjust height of no-thumb label * fix: remove debug log, set collapsable to false for player view * fix: fix dimensions "flash" * chore: remove old youtube link test * tests: add tests * fix: thumbless embed position when loading * fix: remove background from webview * cleanup embeds (almost) * more refactoring - Use separate layers for player and overlay to prevent weird sizing issues - Be sure the image is not visible under the player - Clean up some * cleanup styles * parse youtube shorts urls * remove debug * add soundcloud tracks and sets (playlists) * move logic into `ExternalLinkEmbed` * border radius for yt player on native * fix styling on web * allow scrolling in webview on android * remove unnecessary check * autoplay yt on web * fix tests after adding autoplay * move `useNavigation` to top of component --------- Co-authored-by: Paul Frazee --- src/lib/strings/url-helpers.ts | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'src/lib/strings/url-helpers.ts') diff --git a/src/lib/strings/url-helpers.ts b/src/lib/strings/url-helpers.ts index e9bf4111d..8a71718c8 100644 --- a/src/lib/strings/url-helpers.ts +++ b/src/lib/strings/url-helpers.ts @@ -139,35 +139,6 @@ export function feedUriToHref(url: string): string { } } -export function getYoutubeVideoId(link: string): string | undefined { - let url - try { - url = new URL(link) - } catch (e) { - return undefined - } - - if ( - url.hostname !== 'www.youtube.com' && - url.hostname !== 'youtube.com' && - url.hostname !== 'youtu.be' - ) { - return undefined - } - if (url.hostname === 'youtu.be') { - const videoId = url.pathname.split('/')[1] - if (!videoId) { - return undefined - } - return videoId - } - const videoId = url.searchParams.get('v') as string - if (!videoId) { - return undefined - } - return videoId -} - /** * Checks if the label in the post text matches the host of the link facet. * -- cgit 1.4.1