Reputation: 733
I have an iframe video with a play button (not youtube!). There is no autoplay functionality. So, I want onLoad imitate click this button. How can I achieve this? I know the class of the button, I want to use it.
Upvotes: 0
Views: 1311
Reputation: 1120
There is a way, example: declare a boolean state and append autoplay=1
to the url on click. Only works for web browsers.
const [play, setPlay] = useState(false);
const url = play ? "urEmbededUrl?autoplay=1" : urEmbededUrl
<iframe
src={url}
title={""}
height="100%"
width="100%"
allow="autoplay;"
/>
<button onClick={() => setPlay(true)}>play</button>
Note that allow="autoplay;"
is required.
Upvotes: 1
Reputation: 733
Unfortunately, there is no way to access the elements inside the iframe being loaded from a third-party resource.
Upvotes: 0