Autoplay not working

Discussion in 'HTML and CSS' started by D.127.0.0.1.C, Jul 9, 2018.

  1. D.127.0.0.1.C

    D.127.0.0.1.C

    Joined:
    Jul 9, 2018
    Messages:
    2
    Likes Received:
    1
    I've been working on a pet project of a website with background music, no control bar, and autoplay loop. A while ago my code worked fine but now it doesn't seem to work?

    <audio class="audio" controls="false" autoplay>
    <source src="That Seagull Has Nothing On Me.ogg" type="audio/ogg">
    <source src="That Seagull Has Nothing On Me.mp3" type="audio/mpeg">
    </audio>

    AND

    <audio autoplay loop >
    <source src="INSERT MP3 FILE NAME.ogg"
    type="audio/ogg">
    <source src="<INSERT MP3 FILE NAME.mp3"
    type="audio/mpeg">
    </audio>

    Here are both codes I've used in the past. Now neither work. No autoplay, no loop and I have to have the control bar. Any ideas as to why ?
     
    D.127.0.0.1.C, Jul 9, 2018
    #1
    AdrianG001 likes this.
    1. Advertisements

  2. D.127.0.0.1.C

    John Joe

    Joined:
    Apr 25, 2017
    Messages:
    97
    Likes Received:
    14
    Location:
    Malaysia
    Try this code instead

    Code (Text):
    <video controls autoplay>
      <source src="movie.mp4" type="video/mp4">
      <source src="movie.ogg" type="video/ogg">
      Your browser does not support the video tag.
    </video>
    Get from : https://www.w3schools.com/tags/att_video_autoplay.asp
     
    John Joe, Jul 10, 2018
    #2
    1. Advertisements

  3. D.127.0.0.1.C

    D.127.0.0.1.C

    Joined:
    Jul 9, 2018
    Messages:
    2
    Likes Received:
    1

    Unfortunately this didn't work either
     
    D.127.0.0.1.C, Jul 11, 2018
    #3
  4. D.127.0.0.1.C

    JasKinasis

    Joined:
    Jun 27, 2018
    Messages:
    11
    Likes Received:
    4
    Location:
    /dev/null
    @D.127.0.0.1.C :
    It's been quite a while since I did any thing web-based, but assuming you're using HTML5 - then the second snippet of code you posted (using html5 audio tags) should work.

    Are you experiencing this problem when developing on your local machine?
    Or does this problem only occur when the site is uploaded to your server and you are viewing it remotely?
    Or both?

    Also, which browser are you developing/testing on? And which OS?

    You said that it works when you use controls in the audio tags, so the paths to the files must be OK. But it doesn't work when you use autoplay without the controls - so I'm thinking that perhaps auto-play has been disabled in your browser - that would be the first thing I'd check!

    Some browsers have an option to disable autoplay for embedded audio/video in pages.
    For example:
    In Firefox's about:config tab - there is an option called "media.autoplay.enabled".
    By default, this option is normally set to true - so autoplay will work when pages are loaded.
    But if it is set to false, autoplay will not work. So any time a page is loaded and an audio or video control tries to autoplay something, the browser will simply ignore it.

    So I'd recommend checking the configuration options in your browser to make sure that you haven't somehow disabled autoplay in your browser. Perhaps you have installed an add-on or a plug-in for your browser which has disabled autoplay. If this is the case, it means that your website is NOT broken, it just means that your browser is mis-configured. Therefore, re-enabling your browsers autoplay option should fix things for you.

    If it isn't your browser's configuration preventing auto-play from working, then I don't know offhand.
     
    JasKinasis, Jul 13, 2018
    #4
    JohnyMay likes this.
  5. D.127.0.0.1.C

    AdrianG001

    Joined:
    Aug 6, 2018
    Messages:
    1
    Likes Received:
    0
    Hey,

    Try the below code

    <audio controls autoplay>
    <source src="horse.ogg" type="audio/ogg">
    <source src="horse.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
    </audio>

    Regards,
    Adrian Gates
    Web Developer
     
    AdrianG001, Aug 6, 2018
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.