react-player
react-player copied to clipboard
Display Advertisement (Ads)
Hi, how can you configure the player to show the standard advertising that plays for the videos? I'm trying to build a player with custom controls and would like the ads to play as usual.
I've tried using config values like this:
config: {
youtube: {
playerVars: {
iv_load_policy: 3, // hide annotations
disablekb: 1, // disable keyboard controls
playsinline: 1, // play inline on mobile devices
enablejsapi: 1 // allow player to interact with JS code
}
}
}
But nothing seems to work, the ads are always blocked. I've turned off all ad blocking extensions in the browser too. Any suggestions or hints would be greatly appreciated!
Can you provide a specific example (example code or a codepen) and the browser you are using?
Used it on Chrome Version 111.0.5563.64 (Official Build) (x86_64), along with Safari, and Brave.
Yes, here is the codepen: https://codesandbox.io/s/jolly-mestorf-n3o4nu?file=/src/App.js:528-542
I've also tried adding the "enablejsapi=1" as a query param, but no effect. Basically, I can't get the interrupting pre-roll or inbetween kind of ads to show, where the viewer can hit the "skip" button on the lower right.
I also noticed the same behavior on your online demo ( https://cookpete.com/react-player/ ), but wasn't sure if it was due to how recent it was.
I’ve looked more at this and I cannot figure it out. My initial thought was that the creator of the video has turned off ads for embedded videos, but this doesn’t look possible:
If you don't want to show ads on your embedded videos, there's no way to turn off ads directly on embedded videos only. You may turn off embedding altogether.
https://support.google.com/youtube/answer/132596?hl=en-GB
I also thought it might be related to rel being set to 0 but setting to 1 makes no difference.