You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
URL's that don't match anything in canPlay will result in react-player never finding a player, if a 'react-player/file' import is used.
Example url: https://api.test.com/DbHjaY7aZ4H8A121
This one does not match in the canPlay function for files, because it doesn't have an extension. That's fine when using the normal 'react-player' import, because it will automatically fallback to the FilePlayer, even if a url does not match.
constgenerateSinglePlayers=async()=>{for(const{ key, name }ofplayers){constfile=` var createReactPlayer = require('./lib/ReactPlayer').createReactPlayer var Player = require('./lib/players/${name}').default module.exports = createReactPlayer([{ key: '${key}', canPlay: Player.canPlay, lazyPlayer: Player }]) `awaitwriteFile(join('.',`${key}.js`),file)}}
this would fix it, because the fallback is provided, so when canPlay returns false, we will still get the file player fallback. It seems a bit redundant tho
always using the file player as a fallback no matter if the 'fallback' parameter is provided
URL's that don't match anything in
canPlay
will result in react-player never finding a player, if a 'react-player/file' import is used.Example url:
https://api.test.com/DbHjaY7aZ4H8A121
This one does not match in the
canPlay
function for files, because it doesn't have an extension. That's fine when using the normal 'react-player' import, because it will automatically fallback to the FilePlayer, even if a url does not match.When using 'react-player/file' the fallback will not be provided to ReactPlayer, so then the
canPlay
function will again return false, but we will never get a player, because we don't provide a fallback here to thecreateReactPlayer
function: https://github.com/cookpete/react-player/blob/v2.16.0/scripts/pre-publish.js#L10-L14And specifically this if fallback check here will not be 'truthy' when using the file import:
There are two solutions here that would fix this:
this would fix it, because the fallback is provided, so when
canPlay
returns false, we will still get the file player fallback. It seems a bit redundant thoreturn null
here and always return the file player:Let me know if something is unclear, or I can help with fixing this 🙂
The text was updated successfully, but these errors were encountered: