I really want to do that, i tryed lots of things but none work
Are you embedding a YouTube video or a manually uploaded one? I don’t see a video file in your code.
manually, i removed it, now that i notice, ive been 2 hours on this and i still coulnt do it…
@CoderElijah just added it back!
it is inside the games/cool-game folder
Adding this to
<video width="320" height="240" controls autoplay muted>
<source src="rickroll.mp4" type="video/mp4">
Your browser does not support the video tag.
S4IL is a dev! (my fork with a working Rick Roll, note that I may delete the Repl some day so when this post is two months old, the link may be a 404)
So, in order to autoplay on some browsers, it must be muted. You can take
autoplay muted out, and then it will not autoplay, but when played there will be sound. Or you could put
muted, and it may not autoplay on every browser, but it might on some. Regardless, that embeds your video. See this article for more information on video embedding.
so, it cannot autoplay and not be muted?
In some browsers, it cannot autoplay with sound. I’m using Firefox and it did not autoplay until I added
ohhhh, so that was the problem… is there a way to remove the pause controls?
and if you make an mp3 file sound then would it sound?
You can remove the controls by taking
controls out of the
According to w3schools, an audio file will have the same issue where many browsers will block autoplay unless it’s muted (and who wants a muted audio file?).
ohhh, thanks a LOT!!!
how can i add the mp3 file (even if it doesnt autoplay)
This should play audio if the browser will let you. As with
video, you should be able to take out the
<audio controls autoplay>
<source src="rickroll.mp3" type="audio/mpeg">
Your browser does not support the audio element.
thank you A LOT! You helped me a lot, i love to program but i’m not really pro at the moment, but thanks a lot
You’re welcome! I’m glad I could help.
@CoderElijah wait! also, is there a way to make that if the browser allows, the video autoplays with audio, but if not, then muted?
I’m not sure. You could autoplay an MP3 with audio and the video without audio and that would work, but I’m not sure about the video by itself doing that. Note if you use MP3 and MP4, make sure the audio lines up with the video (I’d recommend converting your MP4 to MP3 to ensure this).
ok, thanks! but idk how to make detect if the browser allows or not…
how could i do that?
oh… so you are gone…