Feature request: lazy players
See original GitHub issueMotivation: On my page I don’t know what player will be used in each particular case and many of the players will never be used, so I would like to lazily load only one player in each particular case.
Something like this:
import React, { Suspense, lazy } from 'react'
import { whichPlayerCanPlay } from 'react-player'
const players = {
youtube: () => import('react-player/lib/players/YouTube'),
vimeo: () => import('react-player/lib/players/Vimeo'),
file: () => import('react-player/lib/players/FilePlayer')
}
const MyPlayer = (props) => {
const { url } = props
const playerName = whichPlayerCanPlay(url, { players: ['youtube', 'vimeo', 'file'] })
if (!playerName) {
return null
}
const LazyPlayer = lazy(players[playerName]);
return (
<Suspense fallback={<div>Loading...</div>}>
<LazyPlayer {...props} />
</Suspense>
)
}
The problem here is that the canPlay
logic is inside of each individual player file and to know whether a player is capable of playing the url I need to download it. Could the canPlay
logic be extracted from each individual player to a separate file?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:18 (8 by maintainers)
Top Results From Across the Web
Feature request: lazy players · Issue #738 · cookpete/react ...
The problem here is that the canPlay logic is inside of each individual player file and to know whether a player is capable...
Read more >Feature Requests - WP Fusion
Feature Requests Got an idea for a new feature or integration? We'd love to hear it! You can find our roadmap here.
Read more >Why Your Product Team Isn't Working on Your Feature Request
There is, usually, a feature request process — a process by which you ... Lazy requests will bias the Product team against your...
Read more >We Created A Feature Request Board for World of Warcraft
This allows players a dedicated space to help collect and vote on feature requests for Retail and Classic versions of World of Warcraft, ......
Read more >Feature Request: Rebinding all keybinds, page 3 - GOG.com
Let's hope they didn't turn into Bethesda, waiting for their players to fix what they're too lazy or incompetent to do themselves.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should be fixed in
v2.0.1
Hey @trurl-master, yeah this has been on my radar for a long time. It would reduce the bundle size massively and essentially render the single player imports redundant. I can look at implementing this, but don’t have an exact timeline.