How to make audio autoplay on chrome

后端 未结 17 1762
南旧
南旧 2020-11-22 08:42

audio autoplay working in Mozilla, Microsoft edge and old google chrome as well but not in new google chrome. they have blocked the autoplay. is there any way to make it au

17条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 09:07

    You may simply use (.autoplay = true;) as following (tested on Chrome Desktop):

    
    
    
    

    If you need to add stop/play buttons:

    
    
    
    
    
    
    

    If you want stop/play to be one single button:

    
    
    
    
    
    
    

    If you want to display stop/play on the same button:

    
    
    
    
    
    
    

    In some browsers audio may doesn't work correctly, so as a trick try adding iframe before your code:

    
    
    
    
    
    
    
    
    

提交回复
热议问题