Audio auto play? | Sololearn: Learn to code for FREE!

+2

Audio auto play?

How to add Audio with auto play mood ? Please send me with a code .

8/13/2022 11:33:18 AM

✧ Coo ★

21 Answers

New Answer

+5

Here is quick summary of this thread: - autoplay attribute doesn't work anymore - to play media element from javascript, user gesture (mouse, keyboard, touch event) is required - AudioContext API allows playing audio without user gesture but in several browsers it is in suspended state by default which won't allow played audio to start (you need to resume the instance which requires user gesture)

+9

https://code.sololearn.com/WMQM5h49whmO/?ref=app

+8

You can go through this code https://code.sololearn.com/W41UlnPCFNIS/?ref=app

+5

autoplay is deprecated in modern browsers. It need a gesture or event to autoplay so you need a javascript support.. try to see these possibilities works or not: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide Hope it helps.. edit: try these : <audio loop autoplay controls> <source src="https://dl.dropbox.com/s/nbt7tqcacl3nob8/IPL%20theme%20RMX?dl=0"> </audio> <iframe src="https://dl.dropbox.com/s/nbt7tqcacl3nob8/IPL%20theme%20RMX?dl=0" type="audio/mp3" allow="autoplay"> Audio element not supported by your browser. </iframe> edit: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play#Usage_notes

+5

Let me be straightforward. You cannot AUTOPLAY audio, video or any media playable without initialising user event hence it's no more an "AUTOPLAY". Well that's how it is now... All these methods won't work

+4

ρү૨œdԌ૨ × Table is never deprecated unless you mean the type from the furnitures. I will also like to clarify the difference between element/attribute deprecation. Attributes like [AUTOPLAY, disabled] etc are always immediate after deprecation [Marquee] is a deprecated element, they are to be translated directly by the browser, they always give some time so older programs using them can switch to the alternative

+2

Only with html

+2

ρү૨œdԌ૨ × I've tested the example you provided. It does not work in this code playground. I also tested it in chrome it does not work. However there is a media autoplay in Chrome and If I set that to allow. It will work with out user interaction. With further testing I have found that it does work in some other code playgrounds. I suspect that those do not follow chromes Browser Policies. And that leads us to the problem with things that are depreciated. Sometimes it works sometimes it don't. https://code.sololearn.com/WmUMGC0InPuD/?ref=app

+2

Chi Zu your quote is right 2-3yrs back but AUTOPLAY doesn't work anymore. Just me being straightforward here so you won't be going around the internet trying to add buggy codes to your program. iOS has even add more restrictions, you can't preload or play more than a single media file simultaneously. That's just how it is

+2

ρү૨œdԌ૨ × as already told by others, it won't work here.. That's just a example, but not a working example as per OP expectations.. (On reply only with html), I also given possibilities, which are all ways to do previously, so can go on to check now, if those are working or not in their using browers.. But surely it won't work modern browsers. Details about why, @Mirielle explained in detailed... @Chris provided test example.tqs

+1

https://www.sololearn.com/discuss/2576523/?ref=app https://www.sololearn.com/discuss/1921932/?ref=app https://www.sololearn.com/discuss/2059721/?ref=app https://www.sololearn.com/discuss/2330298/?ref=app edit https://www.sololearn.com/Discuss/2853634/?ref=app

+1

👍Am also mean the the same pointing.. May be indirect.. 🙂

0

<audio src="" autoplay> https://www.w3schools.com/tags/tag_audio.asp

0

@ρү૨œdԌ૨ × So why don't you add an example how to write that, working example of autoplaying pls?

0

Correct me if I'm wrong, but... Use `autoplay` on a `<video>` or `<audio>` tag for it to autoplay as soon as it's seen on the screen.

0

<!-- Credit - https://dribbble.com/shots/14605167/attachments/6297430?mode=media --> <!-- <a href="https://www.freepik.com/vectors/creative-illustration">Creative illustration vector created by pikisuperstar - www.freepik.com</a> <a href="https://www.flaticon.com/free-icons/google" title="google icons">Google icons created by Freepik - Flaticon</a> <a href="https://www.flaticon.com/free-icons/facebook" title="facebook icons">Facebook icons created by Freepik - Flaticon</a> --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Awesome Login Screen</title> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Raleway:[email protected];400;500;600;700;800&display=swap" rel="stylesheet"> <script

0

By using audio starting tag use: <audio autoplay> </audio>

0

-1

Not true. Quit peddling jabbascript. Deprecated or not it still works.

-1

Jayakrishna🇮🇳 I already gave an example. Unless they deprecated the function in the last 2 years it works. There's also other deprecated things in HTML like <table> that still work.