<!--语音导航 start-->
<div style="border:0px solid red;width:100%;height:72px;position:relative;overflow-y: hidden;">
<img src="/static/front/images/voice_play.png" style="width: 72px;float:left;height: 72px;margin-top:10px;" id="play"/>
<!--audio start-->
<audio id="audio" src=${(sightSpotVo.voice)!}></audio>
<!--audio end-->
<div style="border:0px solid red;width:50%;height: 56px;float:left;margin-top: 16px;">
<div style="height:10px;float:right;font-size: 12px;margin-top: 8px;color:#8E8E8E;"><span id="time">00:00</span>/<span id="sumTime">00:00</span></div>
<div style="width:100%;margin-top: 25px;height:6px;background:#B7B6B6;position: relative;" id="progress_bar">
<div style="margin:0;padding:0;background:#3099F3;height:6px;width:0%" id="pastime"></div>
</div>
</div>
<a class="goHere" href="/wap/map.htm?type=${(userParam.type)!}&id=${(userParam.id)!}&singspotId=${(sightSpotVo.id)!}&isIt='flase'">
<b class="routeIco"></b>
<p>去这里</p>
</a>
</div>
<!--语音导航 end-->

//语音播放
var initAudio=function (){
var audio=document.getElementById("audio");
//播放按钮
var play=document.getElementById("play");
audio.load(); //音频加载
audio.addEventListener("canplaythrough", function() {
$("#sumTime").text(format(audio.duration));
});
audio.addEventListener('timeupdate',function(){
if (!isNaN(audio.duration)) {
var pastime = document.getElementById("pastime");
var widthline = Math.round(audio.currentTime)/Math.round(audio.duration) * 100;
pastime.style.width = widthline + "%";
$("#time").text(format(audio.currentTime));
};
},false);
play.onclick=function () {
if(audio.paused){
play.src="/static/front/images/voice_pause.png";
audio.play();
playCount++;//播放次数+1
}else{
play.src="/static/front/images/voice_play.png";
audio.pause();
}
}
//注册触摸滑动事件
$('#progress_bar').get(0).addEventListener('touchstart', touchMoveFunc, false);
$('#progress_bar').get(0).addEventListener('touchmove', touchMoveFunc, false);
$('#progress_bar').get(0).addEventListener('touchend', touchMoveFunc, false);
}
//触摸滑动
var touchMoveFunc=function(ev){
audioPorgress(ev);
}
//时间格式化
function format(value) {
var theTime = parseInt(value);// 秒
var theTime1 = 0;// 分
var theTime2 = 0;// 小时
if(theTime > 60) {
theTime1 = parseInt(theTime/60);
theTime = parseInt(theTime%60);
}
var result =(parseInt(theTime1)<10?"0"+parseInt(theTime1):parseInt(theTime1))+":"+(parseInt(theTime)<10?"0"+parseInt(theTime):parseInt(theTime));
if(theTime1 > 0) {
result =(parseInt(theTime1)<10?"0"+parseInt(theTime1):parseInt(theTime1))+":"+(parseInt(theTime)<10?"0"+parseInt(theTime):parseInt(theTime));
}
return result;
}
//调整播放进度条
function audioPorgress(event){
var dom=$('#progress_bar').get(0);
//var event = window.event || ev;
var touch = event.targetTouches[0];
var progressX = touch.pageX - dom.getBoundingClientRect().left;
audio.currentTime = parseInt(progressX/324*audio.duration);
}

h5语音播放(移动端)的更多相关文章

  1. 腾讯云H5语音通信QoE优化

    本文首发在云+社区,未经许可,不得转载. 云+导语:4月21日,腾讯云+社区在京举办"'音'你而来,'视'而可见--音视频技术开发实战沙龙",腾讯音视频实验室高级工程师张轲围绕网络 ...

  2. 纯css3配合vue实现微信语音播放效果

    前言 每次写点东西都扯两句-0-,这几天一半精力放在移动端,一半维护之前的项目.书也少看了,不过还好依旧保持一颗学习的心.对于css3我是之前有专门整理过的,因此对于原理之前也算了解.今天是项目中遇到 ...

  3. js仿微信语音播放

    html结构如下: <div class="app-voice-you" voiceSrc="xx.mp3"> <img class=&quo ...

  4. jQuery语音播放插件

    自己做jQuery插件:将audio5js封装成jQuery语音播放插件   日前的一个项目需要用到语音播放功能.发现Audio5js符合需求且使用简单,又鉴于jQuery控件便于开发操作,于是有了以 ...

  5. h5、jq 移动端评论点攒功能

    h5.jq 移动端评论点攒功能 平时做的项目中大部分都会涉及到评论的功能,之前用angular写的项目,功能写起来很方便,但是对于一个单页来说,angular有点大材小用了,所有今天分享一个关于jq制 ...

  6. 视频播放—— H5同层播放器接入规范

    H5同层播放器接入规范 x5-video-player-type 启用H5同层播放器 通过video属性“x5-video-player-type”声明启用同层H5播放器 x5-video-playe ...

  7. 【H5 音乐播放实例】第一节 音乐详情页制作(1)

    本教程是一个H5音乐播放的详情页制作,实现了H5音乐播放,音轨的跳动,已经较为酷炫的UI界面. 通过本教程,您会学到: 1.H5音乐播放 (带音轨) 2.iconfont字体图标库 3.div+css ...

  8. html5的audio实现高仿微信语音播放效果

    效果图 前台大体呈现效果图如下: 点击就可以播放mp3格式的录音.点击另外一个录音,当前录音停止! 思路 关于播放动画,这个很简单,我们可以用css3的逐帧动画来实现.关于逐帧动画,我之前的文章也写过 ...

  9. C# 文本转语音,在语音播放过程中停止语音

    1,运用SpVoice播放语音 在VS2013创建Windows窗体应用程序项目,添加引用COM组件Microsoft Speech Object Library: using SpeechLib; ...

随机推荐

  1. linux在线添加硬盘、扫盘

    1:查看scsi 硬盘设备[root@web02 ~]# ls /sys/class/scsi_host host0 host1 host2 2:检查本机现有硬盘 [root@web02 ~]# fd ...

  2. Python排序 插入排序

    插入排序从前往后遍历数组的每一个元素,对每一位元素都将其插入到已经有序的部分数组中,所以插入排序的要点就是找出要插入元素在已经有序的部分中的位置,同时,由于插入排序采用原地排序(in-place)算法 ...

  3. Opencv 三对角线矩阵(Tridiagonal Matrix)解法之(Thomas Algorithm)

    1. 简介 三对角线矩阵(Tridiagonal Matrix),结构如公式(1)所示: aixi−1+bixi+cixx+1=di(1) 其中a1=0,cn=0.写成矩阵形式如(2): ⎡⎣⎢⎢⎢⎢ ...

  4. 基于json数据格式实现的简单数据库——jsonDB

    已在github上建立项目:https://github.com/ThinkerCodeChina/jsonDB /** +-------------------------------------- ...

  5. how to deal with &quot;no such file error or diretory&quot; error for a new programmer in QT creator

    when i try to develop a hello demo in QT creator with the code following : #include<QApplication& ...

  6. form表单系列中文件上传及预览

    文件上传及预览 Form提交 Ajax 上传文件 时机: 如果发送的[文件]:->iframe, jQurey(),伪Ajax 预览 import os img_path = os.path.j ...

  7. BZOJ 3110 线段树套线段树

    思路: 外围一个权值线段树 里面是个区间线段树 搞一个标记永久化 //By SiriusRen #include <cstdio> #include <cstring> #in ...

  8. OpenGL编程逐步深入(七)旋转变换

    准备知识 这一节我们来看一下旋转变换.旋转变换指的是给我们一个指点的点和角度,我们需要绕着过该点的轴线將对象旋转对应的角度.这里我们只改变X/Y/Z中的两个分量,第三个分量保持不变.这意味着我们的图形 ...

  9. array.fliter无法正确过滤出我想要的数组

    var checked_list = state.files.filter(function(item, id){ // console.log('click the ' + item.id); re ...

  10. 200 from memory cache / from disk cache / 304 Not Modified 区别

    三者情况有什么区别和联系,什么情况下会发生200 from memory cache 或 200 from disk cache 或 304 Not Modified? 200 from memory ...