cookpete / react-player

A React component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia and DailyMotion
https://cookpete.github.io/react-player
MIT License
9.44k stars 1.15k forks source link

Query Regarding the URLs passed #1328

Closed papuruth closed 7 months ago

papuruth commented 3 years ago

Current Behavior

When passing URL to the player for some provider it is accepting both links normal as well as an embedded link. But for provider like Wistia, DailyMotion, SoundsCloud, and MixCloud only normal URL works.

URLS Example

// testLinkA is a normal URL
// testLinkB is an embedded URL

const URLS = {
  wistia: {
    testLinkA: "https://simmirocks880.wistia.com/medias/x8ou8gjgoq",
    testLinkB:
      "https://simmirocks880.wistia.com/medias/x8ou8gjgoq?embedType=iframe&videoFoam=true&videoWidth=640"
  },
  mixCloud: {
    testLinkA:
      "https://www.mixcloud.com/TheBlessedMadonna/we-still-believe-episode-090-it-couldnt-happen-here/",
    testLinkB:
      "https://www.mixcloud.com/widget/iframe/?hide_cover=1&feed=%2FTheBlessedMadonna%2Fwe-still-believe-episode-090-it-couldnt-happen-here%2F"
  },
  dailyMotion: {
    testLinkA: "https://www.dailymotion.com/video/x392c7l",
    testLinkB: "https://www.dailymotion.com/embed/video/x392c7l?autoplay=1"
  },
  soundCloud: {
    testLinkA:
      "https://soundcloud.com/hahahahahahahahahaha09/churi-khan-bhaini",
    testLinkB:
      "https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/1131912316"
  }
};

Expected Behavior

I want that the player loads only the normal URLs or only the embedded URLs or if it could load both for all providers then that would be great. I don't know how to make this happen a direction towards help would be appreciated.

Steps to Reproduce

  1. Open the Sandbox link attached below
  2. Wait for the page to load
  3. Click on the button present on the UI to load the URLs into the player and observe the result
  4. All the URLs linked to Test Link A works fine but fails for Test Link B

Environment

Other Information

If I'm passing the embedded links directly to an Iframe element it works smoothly.

cookpete commented 3 years ago

The URL matching patterns have been put together over time mostly based on trial and error and PRs to correct them.

I will gladly look at a PR updating the patterns to support more variations, but note that some of them have a capture group used to extract the video ID from the URL.