Skip to content

feat!: detect players with Video.js resolveAdapterType - #2050

Merged
luwes merged 2 commits into
feat/videojs-v10-mediafrom
feat/resolve-adapter-type
Oct 2, 2026
Merged

luwes merged 2 commits into
feat/videojs-v10-mediafrom
feat/resolve-adapter-type

Conversation

@luwes

@luwes luwes commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Merged into #2049, which now ships these changes as part of one PR. Its description covers the breaking changes listed here.

Stacked on #2049.

Replaces the URL regexes in src/patterns.ts with resolveAdapterType / resolveMimeType from @videojs/react, so ReactPlayer recognizes the same sources as the Video.js v10 media components it renders.

  • Every built-in player key is a Video.js adapter type (plus html), so patterns.ts resolves a URL to its player key once and each player's canPlay is canPlay('<key>'), instead of a table of per-player predicates.
  • Mux stream URLs ending in .m3u8 still play with hls.js.
  • File playback keeps AUDIO_EXTENSIONS / VIDEO_EXTENSIONS as a fallback for extensions Video.js does not recognize (m4v, m4b, weba, oga, spx, ...).
  • Removed canPlayFile, which handled arrays of sources that src no longer accepts.

Release notes

Features

  • Player detection now uses resolveAdapterType from Video.js v10.
  • Newly recognized sources: localized Spotify URLs (open.spotify.com/intl-de/track/...), spotify: URIs, youtube/<id> and vimeo/<id> shorthands, and .flac files.

Breaking changes:

  • react-player/patterns no longer exports HLS_EXTENSIONS, DASH_EXTENSIONS, MATCH_URL_MUX, MATCH_URL_YOUTUBE, MATCH_URL_VIMEO, MATCH_URL_WISTIA, MATCH_URL_SPOTIFY, MATCH_URL_TWITCH or MATCH_URL_TIKTOK. Use resolveAdapterType from @videojs/react instead:

    import { resolveAdapterType } from '@videojs/react';
    
    resolveAdapterType('https://youtu.be/oUFJJNQGwhk'); // 'youtube'
  • canPlay in react-player/patterns is now a function of the player key: canPlay.youtube(url) becomes canPlay('youtube')(url).

  • These URLs are no longer matched to a service player and fall back to the HTML player:

    URL Before After
    youtube.com/user/..., music.youtube.com/watch?v=... YouTube HTML
    vimeo.com/channels/<channel>/<id>, vimeo.com/showcase/<id> Vimeo HTML
    player.twitch.tv/?video=<id> Twitch HTML

Testing

  • pnpm lint, pnpm typecheck, pnpm test, pnpm build and pnpm build:demo pass, on each commit.
  • Compared old and new detection across ~50 URLs; the table above lists every difference.
  • After the canPlay(key) refactor, re-ran the comparison against the previous commit: identical player selection for every URL.

luwes added 2 commits October 1, 2026 18:45
Replace the URL regexes in patterns.ts with resolveAdapterType and resolveMimeType from @videojs/react, so ReactPlayer recognizes the same sources as the Video.js v10 media components it renders.

- YouTube, Vimeo, Wistia, Mux, Spotify, Twitch, TikTok and DASH sources are matched by adapter type.
- Mux stream URLs ending in .m3u8 still play with hls.js.
- File playback keeps AUDIO_EXTENSIONS and VIDEO_EXTENSIONS as a fallback for extensions Video.js does not recognize (m4v, m4b, weba, oga, spx, ...).

Newly recognized sources:
- localized Spotify URLs (open.spotify.com/intl-de/track/...) and spotify: URIs
- youtube/<id> and vimeo/<id> shorthands
- .flac files

Breaking changes:
- react-player/patterns no longer exports HLS_EXTENSIONS, DASH_EXTENSIONS, MATCH_URL_MUX, MATCH_URL_YOUTUBE, MATCH_URL_VIMEO, MATCH_URL_WISTIA, MATCH_URL_SPOTIFY, MATCH_URL_TWITCH or MATCH_URL_TIKTOK. Use resolveAdapterType from @videojs/react instead.
- These URLs are no longer matched to a service player and fall back to the HTML player: youtube.com/user/..., music.youtube.com, vimeo.com/channels/..., vimeo.com/showcase/... and player.twitch.tv/?video=...

BREAKING CHANGE: URL pattern exports were removed from react-player/patterns in favor of resolveAdapterType from @videojs/react, and some URLs now resolve to a different player.
Every built-in player key is a Video.js adapter type (plus html), so patterns.ts resolves a URL to its player key once and canPlay(key) compares against it, instead of a table of per-player predicates. The Mux .m3u8 -> hls.js rule and the extension fallback for the HTML player are unchanged; player selection is identical for every URL compared. Also removes canPlayFile, which handled arrays of sources that src no longer accepts.

Breaking changes:
- react-player/patterns exports canPlay as a function of the player key: canPlay.youtube(url) becomes canPlay('youtube')(url).

BREAKING CHANGE: canPlay in react-player/patterns is now canPlay(key)(url) instead of canPlay[key](url).

This branch was successfully deployed

1 active deployment
github-preview — ef45ca49 Deployed Oct 2, 2026 by luwes via deploy-preview #273
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant