Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. type TWebmComponent = React.FC<{ videoUrl: string; fallbackUrl: string; description: string; onClick?: (e) =>void }>
  2.  
  3. const WebmComponent: TWebmComponent = ({ videoUrl, fallbackUrl, description, onClick = () => null }) => {
  4. const supportsWebm = !!document.createElement('video').canPlayType
  5.  
  6. return (
  7. <>
  8. <figure className="figure">
  9. <a
  10. href={supportsWebm ? videoUrl : fallbackUrl}
  11. target="_blank"
  12. rel="noopener noreferrer"
  13. onClick={onClick}
  14. >
  15. <video
  16. preload="auto"
  17. loop={true}
  18. poster={fallbackUrl}
  19. autoPlay={true}
  20. className="figure-img img-fluid rounded img-thumbnail"
  21. >
  22. <source src={videoUrl} type="video/webm"></source>
  23. <source src={videoUrl} type="video/mp4"></source>
  24. </video>
  25. </a>
  26. <figcaption className="figure-caption text-center">{description}</figcaption>
  27. </figure>
  28. </>
  29. )
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement