mrfoolish
V2EX  ›  HTML

[求助]使用 html5 的 audio 标签在手机浏览器网页上无法自动加载/播放音乐,求解决方案?

  •  
  •   mrfoolish · Dec 2, 2015 · 5071 views
    This topic created in 3842 days ago, the information mentioned may be changed or developed.

    设置 autoplay="autoplay",测试 QQ 浏览器, Chrome 浏览器,手机都无法自动播放音频

    5 replies    2015-12-02 17:37:22 +08:00
    skywatcher
        1
    skywatcher  
       Dec 2, 2015
    有些浏览器不支持的,看官方文档是否支持 autoplay ,或者自己检测 http://mrcoles.com/detecting-html5-audio-autoplay/
    TakanashiAzusa
        2
    TakanashiAzusa  
       Dec 2, 2015
    en ,有的浏览器屏蔽掉了。不过我有个有 hack 方法。模拟点击事件啥的。。具体没研究
    MiGong
        3
    MiGong  
       Dec 2, 2015
    需要使用 JS .play()
    54sword
        4
    54sword  
       Dec 2, 2015
    手机浏览器默认都需要有交互才能播放 audio.
    swirling
        5
    swirling  
       Dec 2, 2015
    $(document.body).one("touchstart",function(){
    // play it!
    });
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3413 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 11:41 · PVG 19:41 · LAX 04:41 · JFK 07:41
    ♥ Do have faith in what you're doing.