Is there any way by which i could play the audio of sound.
Currently am playing the video with the sound muted and unmuting it when the user interacts with the document/ Canvas.
Can’t i achieve to play the video along with sound without interaction ?
I got your point, Just need to know one thing, if user interaction is required with the document.
How is this video is played with sound? without interaction with the webpage on autoplay.
The link you provided is playing the sound because the media file is embedded in a media player. The audio runs when the user hits the play button or if you make a timeout function to make the play button play automatically. This way you can make the isPlaying variables value to be true and trigger the audio to play when the variable is true. I tried to make a similar thing but I made an event listener to play the audio when the page loads I make a fake click on the screen that way the audio played seemlesly.
So does that mean, if we also embed the video inside a media player and run it over the browser, it will run on opening without the user interaction ? Is it possible by this way ?
Also how was youtube able to achieve this thing where we directly open the webpage by a URL and it autoplays the video ?
Consider Youtube and other video sharing platforms each of them doesnt play the video in the HTML directly instead the video is being embedded into a VideoPlayer which is making the audio play.
In your case you are making the HTML to play the audio, let me find the code for running the audio I have it somewhere on my machine
But this will only work when we play it in media Player right? I don’t want to give user to control the media player functionality of play/pause volume etc. But want that to control on my code side. Will this be possible ?
Nah if you totally want to make the audio run without user interaction then you have to make it run using a fake click, I wouldn’t prefer that but manthrax is right!
Why do you want to do this? Forcing users to play audio that they can only turn off by turning off their computer’s audio is a terrible idea.
If audio is necessary for whatever you’re coding (eg a game or audio visual experience), inform the user and let them control when it starts playing with a start button.
If it isn’t necessary but you think it’s cool, like background music for a portfolio website, again the user should choose it they want the audio to play or not.
Got it. You Got a Point, and i’ve done the changes by showing a popup in starting asking for audio permissions by understanding the POV from a user who will be accessing it .