HTML5 Video Autoplay not working correctly

后端 未结 7 1150
鱼传尺愫
鱼传尺愫 2020-12-09 08:19

Im using this code:

相关标签:
7条回答
  • 2020-12-09 09:01

    Working solution October 2018, for videos including audio channel

     $(document).ready(function() {
         $('video').prop('muted',true).play()
     });
    

    Have a look at another of mine, more in-depth answer: https://stackoverflow.com/a/57723549/3049675

    0 讨论(0)
  • 2020-12-09 09:03

    Chrome does not allow autoplay if the video is not muted. Try using this:

    <video width="440px" loop="true" autoplay="autoplay" controls muted>
      <source src="http://www.tuscorlloyds.com/CorporateVideo.mp4" type="video/mp4" />
      <source src="http://www.tuscorlloyds.com/CorporateVideo.ogv" type="video/ogv" />
      <source src="http://www.tuscorlloyds.com/CorporateVideo.webm" type="video/webm" />
    </video>
    
    0 讨论(0)
  • 2020-12-09 09:04

    //You might want to add some scripts if your software doesn't support jQuery or giving any reference type error.

    //Use above scripts only if the software you are working on doesn't support jQuery.

    $(document).ready(function() { //Change the location of your mp3 or any music file. var source = "../Assets/music.mp3"; var audio = new Audio(); audio.src = source; audio.autoplay = true; });
    0 讨论(0)
  • 2020-12-09 09:20

    Try autoplay="autoplay" instead of the "true" value. That's the documented way to enable autoplay. That sounds weirdly redundant, I know.

    0 讨论(0)
  • <video width="1000px" loop="true" autoplay="autoplay" controls muted></video> worked for me

    0 讨论(0)
  • 2020-12-09 09:21

    Mobile browsers generally ignore this attribute to prevent consuming data until user explicitly starts the download.

    UPDATE: newer version of mobile browser on Android and iOS do support autoplay function. But it only works if the video is muted or has no audio channel:

    Some additional info: https://webkit.org/blog/6784/new-video-policies-for-ios/

    0 讨论(0)
提交回复
热议问题