前端html多音频自动连续播放

本文介绍了如何在前端实现多音频文件的自动连续播放功能。用户通过勾选多选框选择要播放的音频,点击播放后,系统会跳转到播放界面,并依次循环播放所选的音频文件,同时高亮显示当前播放的音频。
摘要由CSDN通过智能技术生成

多音频自动连续播放,且标识正在播放的文件
一、前端界面显示多选框和播放按钮
在这里插入图片描述
勾选多选框选择播放的音频文件,点击播放,跳转到播放界面

function PlayAll(){
	var hdIdValue = $("#hdIdValue").val();
	if(hdIdValue=="")
		alert("请选择数据!");
	else{
		$.ajax({
	 		type : "POST",
	 		url : "recordsCopy.do?recordpath="+window.encodeURI(hdIdValue),
	 		success : function() {
	 			layer.open({
	 		        type: 2,
	 		        title: '语音播放',
	 		        move: false,
	 		        area: ['750px', '500px'],
	 		        content: "recordsplay?hdIdValue="+hdIdValue,
	 		        end: function () {
	 		            location.reload();}
	 		        }) 
        	},
       		 error: function(XMLHttpRequest, textStatus, errorThrown) {
       			 alert(textStatus);
      			 }	
		});
		 
	}
}

二、recordsCopy.do复制音频文件到服务器指定位置,以便播放

public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
   
		req.setCharacterEncoding("UTF-8");
		String recordpathss=req.getParameter("recordpath");
		String[] recordpaths=recordpathss.split(",");
		String realPath = req.getSession().getServletContext().getRealPath("/");
		doFolder(realPath+"temprecord");
		for(int i=0;i<recordpaths.length;i++) {
   
			String recordpath=recordpaths[i];
			if(recordpath != null) {
   
				String filename = recordpaths[i].split("/")[recordpaths[i].split("/").length-1];
				File source = new File(recordpath);
				File dest = new File(realPath+"temprecord/"+filename);
				
				// copy file using FileStreamslong start = System.nanoTime();
				copyFileUsingFileStreams(source, dest);
			}
		}
	}
	
	
		private static void copyFileUsingFileStreams(File source, File dest)
				throws IOException {
   
			InputStream input = null;
			OutputStream output = null
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值