zoukankan      html  css  js  c++  java
  • 项目中问题解决杂谈audio

    插件fullpage下html会被重新打包。audio播放不能。比较好的解决方案是在$.fn.fullpage({ 后加

    afterRender: function(){ 在这加入播放启动  },

    而或许你会遇到新的问题。IOS下audio不能默认播放。这就比较烦了。这个原本我以为ios默认浏览器的问题。然后我发现ios下微信也是一样的。

    我在微信下解决方案

    audioAutoPlay('bgMusic');
    function audioAutoPlay(id){
    var audio = document.getElementById(id);
    audio.play();
    document.addEventListener("WeixinJSBridgeReady", function () {
    audio.play();
    }, false);
    }

    function audionoPlay(id){
    var audio = document.getElementById(id);
    audio.pause();
    document.addEventListener("WeixinJSBridgeReady", function () {
    audio.pause();
    }, false);
    }

    最后需求可能更多的是能可开关的播放

    var off = true;

    afterRender: function(){
    $('.mscBtn').click(function(){
    off=!off;
    if(off){
    $("#audioBtn").removeClass("play");
    audionoPlay('bgMusic');
    }else{
    $("#audioBtn").addClass("play");
    audioAutoPlay('bgMusic');
    }
    })
    },

    播放按钮可以用c3做旋转效果 通过class名 play

    @-webkit-keyframes spin{
    0% {-webkit-transform: rotateZ(0deg);}
    100% { -webkit-transform: rotateZ(360deg);}}


    .play{-webkit-animation: 2.3s spin linear infinite;}

    当然audio的坑不止这些。我只是突然想到以前遇到的算是挺麻烦的问题。后期想到再补充吧

  • 相关阅读:
    手把手教你整Win10的Linux子系统(Ubuntu)
    Golang从入门到微服务
    GitHub总是打不开
    github无法push?看这篇文章就够了
    shell 操作mysql
    04 elasticsearch学习笔记-基本CRUD
    kibana-6.2.4-amd64的安装
    es 的reindex详解
    ruby 操作csv
    shell 去掉逗号_shell替换和去掉换行符
  • 原文地址:https://www.cnblogs.com/JQxu/p/8308516.html
Copyright © 2011-2022 走看看