H5微信场景应用 audio模块
css
.bgAudio{width:27px;height:27px;position:fixed;right:10px;top:10px;z-index:999;-webkit-tap-highlight-color:rgba(0,0,0,0);outline:none;-webkit-transition:all 1s linear;transition:all 1s linear;-webkit-transform:translateZ(0);transform:translateZ(0);display:none}
.bgAudio i{width:27px;height:27px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADYAAAA2CAYAAACMRWrdAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKTWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVN3WJP3Fj7f92UPVkLY8LGXbIEAIiOsCMgQWaIQkgBhhBASQMWFiApWFBURnEhVxILVCkidiOKgKLhnQYqIWotVXDjuH9yntX167+3t+9f7vOec5/zOec8PgBESJpHmomoAOVKFPDrYH49PSMTJvYACFUjgBCAQ5svCZwXFAADwA3l4fnSwP/wBr28AAgBw1S4kEsfh/4O6UCZXACCRAOAiEucLAZBSAMguVMgUAMgYALBTs2QKAJQAAGx5fEIiAKoNAOz0ST4FANipk9wXANiiHKkIAI0BAJkoRyQCQLsAYFWBUiwCwMIAoKxAIi4EwK4BgFm2MkcCgL0FAHaOWJAPQGAAgJlCLMwAIDgCAEMeE80DIEwDoDDSv+CpX3CFuEgBAMDLlc2XS9IzFLiV0Bp38vDg4iHiwmyxQmEXKRBmCeQinJebIxNI5wNMzgwAABr50cH+OD+Q5+bk4eZm52zv9MWi/mvwbyI+IfHf/ryMAgQAEE7P79pf5eXWA3DHAbB1v2upWwDaVgBo3/ldM9sJoFoK0Hr5i3k4/EAenqFQyDwdHAoLC+0lYqG9MOOLPv8z4W/gi372/EAe/tt68ABxmkCZrcCjg/1xYW52rlKO58sEQjFu9+cj/seFf/2OKdHiNLFcLBWK8ViJuFAiTcd5uVKRRCHJleIS6X8y8R+W/QmTdw0ArIZPwE62B7XLbMB+7gECiw5Y0nYAQH7zLYwaC5EAEGc0Mnn3AACTv/mPQCsBAM2XpOMAALzoGFyolBdMxggAAESggSqwQQc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XfOEISMa8ENpRJxPxF1ksyEXNc7eUSMe9NOEpPAK8C28xsolmps5Fsxa0ZpM5uFVbwnTC1xqo4ZJYAt8nzNVM7WwfwpzT3u4zXo8APcuB8n2Wy898DAGS5KfDJ47MqAAAAAElFTkSuQmCC) no-repeat; background-size:27px 27px;display:block; position:relative; z-index:2}
.bgAudio .icon_music{}
@-webkit-keyframes audio-animation{
from{-webkit-transform:rotate(0);}
to{-webkit-transform:rotate(-360deg)}
}
.audioPlay i{-webkit-animation:audio-animation 1.2s linear infinite;animation:audio-animation 1.2s linear infinite;}
html
<a href="javascript:;" class="bgAudio" id="audio_ct">
<i class="icon_music"></i>
<em></em>
</a>
js
/* Audio类 momo 2015-01-30 */
var mmAudio=function(aurl){
if(!aurl){return;}
var audio_ct=document.getElementById('audio_ct');
this.audio=document.getElementById('audio');
if(!this.audio){return;}
this.audioCt=audio_ct||null;
this.aurl=aurl;
this.loadMusic();
};
//装载音频
mmAudio.prototype.loadMusic=function(){
var _this=this;
_this.audio.src=this.aurl;
_this.audio.volume=0.5;
if(!_this.audioCt){return;}
_this.audioCt.style.display='block';
_this.audioCt.className='bgAudio audioPlay';
/*ios默认暂停*/
_this.isIphone(); //绑定音频控制
_this.audioCt.addEventListener('click',function(){
this.className=='bgAudio'?_this.playMusic():_this.pauseMusic();
},false);
}; //播放音频
mmAudio.prototype.playMusic=function(){
this.audio.play();
this.audioCt.className='bgAudio audioPlay';
}; //暂停音频
mmAudio.prototype.pauseMusic=function(){
this.audio.pause();
this.audioCt.className='bgAudio';
}; /*判断系统
ios自动暂停
ios 4隐藏
*/
mmAudio.prototype.isIphone = function(){
var sys = navigator.userAgent;
if(sys.indexOf('iPhone')>-1){
this.pauseMusic();
if(window.screen.height<=480){this.audioCt.style.display='none';}
}
}
调用方法
var music = new mmAudio('http://icon.xgo-img.com.cn/topic/music.mp3');
H5微信场景应用 audio模块的更多相关文章
- 解决H5微信浏览器中audio兼容-- 背景音乐无法自动播放
我们知道,ios 在safari浏览器中,audio标签不能在没有用户交互的情况下自动播放或有js直接控制播放,这是系统限制的一些原因. 但是背景音乐在微信浏览器可以设置自动播放,config配置一下 ...
- 【干货】微信场景之H5页面制作免费工具大集合
营销代有手段出,各领风骚数百天.要说现在哪些营销方式最能传播,屡屡刷爆朋友圈的H5页面肯定就是首当其冲的,提到H5页面,就立马想到"围住神经猫",上线微信朋友圈3天的时间便创造了用 ...
- H5微信授权登录
这里介绍H5微信授权登录,采用了微信公众号授权原理,是oauth2的登录授权方式,简单的来讲,就是用户通过手机微信确认登录之后,微信方会返回一个授权码code给回第三方(接入方),这个授权码code一 ...
- 移动端H5微信分享
移动端H5微信分享功能,可以使项目更好地传播. 微信官方教程文档: 微信JS-SDK说明文档 步骤一:绑定域名 先登录微信公众平台进入"公众号设置"的"功能设置&quo ...
- [小程序开发] 微信小程序audio音频播放组件+api_wx.createAudioContext
引言: audio是微信小程序中的音频组件,可以轻松实现小程序中播放/停止音频等自定义动作. 附上微信小程序audio组件的相关属性说明:https://mp.weixin.qq.com/debug/ ...
- Odoo 开源微信小程序商城模块
详见:http://oejia.net/blog/2018/09/13/oejia_weshop_about.html oejia_weshop Odoo 微信小程序商城模块 oejia_weshop ...
- h5微信页面在手机微信端和微信web开发者工具中都能正常显示,但是在pc端微信浏览器上打不开(显示空白)
h5微信页面在手机微信和微信开发者工具中都能正常显示,但是在pc端微信浏览器上打不开或者数据加载不出来. 原因:pc端微信浏览器不支持ES6语法,我的代码中使用了一些ES6的特性 解决:将ES6转换为 ...
- 微信h5支付“网站域名ICP备案主体与商户号主体不一致”的解决方法,H5微信支付 授权函下载
如下图所示: 微信h5支付“网站域名ICP备案主体与商户号主体不一致”: 需提交H5微信支付 授权函 下载地址:https://download.csdn.net/download/a72400815 ...
- H5微信页面开发 IOS系统 input输入框失去焦点,软键盘关闭后,被撑起的页面无法回退到原来正常的位置,导致弹框里的按钮响应区域错位
H5微信页面开发,软键盘弹起后,若原输入框被遮挡,页面整体将会上移,然而当输入框失焦,软键盘收起后,页面未恢复,导致弹框里的按钮响应区域错位. 解决方案:给输入框(或select选择框)添加失去焦点的 ...
随机推荐
- TPC-H 下载参考
CSDN免费下载地址 tpc-h-v2.17.3.zip tools https://download.csdn.net/download/zes2014/10558251
- 洛谷 P1083 借教室 题解
P1083 借教室 题目描述 在大学期间,经常需要租借教室.大到院系举办活动,小到学习小组自习讨论,都需要向学校申请借教室.教室的大小功能不同,借教室人的身份不同,借教室的手续也不一样. 面对海量租借 ...
- 洛谷P2312解方程题解
题目 暴力能得\(30\),正解需要其他的算法操作,算法操作就是用秦九韶算法来优化. 秦九韶算法就是求多项式的值时,首先计算最内层括号内一次多项式的值,然后由内向外逐层计算一次多项式的值,然后就将求\ ...
- X-NUCA-ezphp记录
鸽了很久,还是记录一下 比赛的时候搞了很长时间,终于和mlt师傅搞出来了,竟然只有我们一队是预期解== <?php $files = scandir('./'); foreach($files ...
- 【转载】sudoers改坏后无法使用sudo的解决办法
练习安装odoo的时候,创建了一个odoo用户,想把它赋予sudo权限,然而,编辑的时候不留意,改坏了,导致sudo无法使用,无法编辑sudoers文件修改回来. 提示如下信息: >>&g ...
- csapp网络编程初学笔记
csapp网络编程初学笔记 客户端-服务器编程模型 每个网络应用都是基于客户端-服务器模型,服务器管理某种资源,并且通过操作来为它的客户提供某种服务 客户端-服务器模型中的基本操作是transacti ...
- Java HashSet介绍
HashSet底层使用HashMap实现.当使用add方法将对象添加到Set当中时,实际上是将该对象作为底层所维护的Map对象的key,而value则都是同一个Object对象(该对象我们用不上). ...
- 微信小程序左滑删除未操作有复位效果
1.wxml <!--pages/test/test.wxml--> <view class="page"> <movable-area class= ...
- Flink 之 Data Source
Data Sources 是什么呢?就字面意思其实就可以知道:数据来源. Flink 做为一款流式计算框架,它可用来做批处理,即处理静态的数据集.历史的数据集: 也可以用来做流处理,即实时的处理些实时 ...
- 人脸替换(FaceSwap)的一些思考
本文链接:https://blog.csdn.net/cy1070779077/article/details/85224347人脸替换(FaceSwap)的一些思考 最一开始,我使用了openCV( ...