New course! Every coder should learn Generative AI!
Try a free lesson+ 20
'autoplay' attribute is not working. Same problem is with audio too. It requires some gestures for running audio or video.
Follow the steps below for running audio or video automatically may not be automatically but this can do your work.
1. Add a 'sweet alert' at the beginning of you web page. For removing the alert user has to click on 'Ok' button. And so we will get a gesture of click.
2. Write the following code in js.
//We have to add a function because code will not execute without it in SL
window.onload =()=>{
var clip = document.getElementById("id of video element");
//In above line you can use any id
document.addEventListener("click", ()=>{
clip.play();
}
);
Done.
This will help you as user will feel that sweet alert is designing and you will get a gesture for playing a video also.
+ 13
https://www.sololearn.com/discuss/2330298/?ref=app
Refer to this sis...
+ 11
Somya 🎸 Sorry,i not looked your question properly 😶 you are talking about video element....
look at this code😶
https://code.sololearn.com/WxHHnlzkmCkX/?ref=app
https://code.sololearn.com/Who05vq9W28Y/?ref=app
+ 9
Hope these may help you..
Autoplay not support in some browsers.. Some browsers not allow..
https://www.sololearn.com/Discuss/2187081/?ref=app
https://www.sololearn.com/discuss/1921932/?ref=app
https://www.sololearn.com/discuss/2059721/?ref=app
https://www.sololearn.com/discuss/998457/?ref=app
https://www.sololearn.com/discuss/995368/?ref=app
Edit :
@Somya 🎸
You mean need about video? You can find from the links above about that also... It's almost same. But some will not support autoplay attribute. You can use bind() or play() in js.. alternatively..
See this for clear info..
https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
hope it helps...
+ 8
Vilgax Hello, you forgot to add⬇️
Video.volume = 1 😶
Btw,nice code but why -2 down-- 🤔
+ 8
Vilgax but can't hear Audio on 0 & if set 1 then able to hear audio....
+ 6
Sis You can try to make a preloader and with that click function u can autoplay the video with no loading time
I assume you are asking for project
If you asking for only autoplay purpose then sorry for my irrelevant answer I tried video.js if u wait for loading text disappear the video will play automatically but but with audio it fails...
https://code.sololearn.com/WkEKE2ww6CD2/?ref=app
+ 5
Since some browsers don't allow autoplay
I am giving you the code link where you need to tap the screen and the song will play automatically
I hope this answer satisfies you
If not then tell me
I will search and study for you to give the best answer
https://code.sololearn.com/WMxyBMYNu2XR/?ref=app
Happy coding🥺
+ 4
ᕙ(@°▽°@)ᕗ {inactive} u must have used play button wait for the while the till the loading text automatically disappears you can see video automatically playing but if u set volume to 1 when the loading text get disappear u will get the error :)
+ 3
ᕙ(@°▽°@)ᕗ {inactive} i didn't forget to make 1
if u make it 1 u will notAllowederror in mobile using android because google only allow play() with DOM elements
So its not possible to autoplay
And about -2 maybe because that's irrelevant i guess so u may assume as spam :)
+ 2
Somya 🎸
You mean need about video? You can find from the links above about that also... It's almost same. But some will not support autoplay attribute. You can use bind(), play() in js to work without any gesture.. alternatively..
See this for clear info.. Hope it helps...
https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
+ 1
Remove the"controls"
<video autoplay>
<source >
</video>
+ 1
There is not solution to this, some browsers don't allow autoplay due to invasive publicity and various pop ups that you may encounter while browsing web. Once said so, there are still some tricks to do that but it's kinda against browser policy so if you want the answer I think this is the wrong place to ask. Also if you find a trick for one browser for others it might not work so... I don't think it's worth the effort.
0
You can use loop is infinity your video
0
I learnt from the answers
- 1
مرحبا
- 1
شو هذا التطبيق
- 1
Try to take a look with this
look at this code😶
https://code.sololearn.com/WxHHnlzkmCkX/?ref=app