博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
基于jQuery的视频和音频播放器jPlayer
阅读量:6957 次
发布时间:2019-06-27

本文共 4974 字,大约阅读时间需要 16 分钟。

hot3.png

jPlayer简介:

想在网页上播放背景音乐,不想用html标签的方式,因为那样只有音乐全部下载完以后才能播放,还容易出现跨浏览器兼容性的问题,于是选了一款基于jQuery的播放器jPlayer来做。

jPlayer实现:

先引入

HTML

    
设备通道
视频画面
play
 
 
play
stop
mute
max volume
repeat
full screen
搜索录像
  • 设备名称:
    监控通道:
  • 开始日期:
    结束日期:
  • 查找录像
录像文件
序号 视频名称
操作
    

js

        var f = 0;	$(function() {		$("#jquery_jplayer_1").jPlayer({			ready: function () {				$(this).jPlayer("setMedia", {					m4v: "",				});			},			pause: function (event){				$("#"+playfile+"tr").attr("ondblclick","keepplay(this)");				$("#"+playfile+"td").attr('src','../../../imgs/1097510.png'); 				$("#"+playfile+"td").removeAttr('onclick');				$("#"+playfile+"td").attr("onclick","keepplay(this)");			},			play: function (event){				$("#"+playfile+"tr").attr("ondblclick","StopPlayback(this)");				$("#"+playfile+"td").attr('src','../../../imgs/1097509.png'); 				$("#"+playfile+"td").removeAttr('onclick');				$("#"+playfile+"td").attr("onclick","StopPlayback(this)");			},			ended: function (event){				$("#"+playfile+"tr").attr("ondblclick","viewplay(this)");				$("#"+playfile+"td").attr('src','../../../imgs/1097510.png'); 				$("#"+playfile+"td").removeAttr('onclick');				$("#"+playfile+"td").attr("onclick","viewplay(this)");			},			resize: function (event){				if(f % 2 != 0){					$("#jp_container_1").css({ 	 					'width' : ($("#con2").width()), 	 					'height' : ($("#con2").height()) 	 				}); 	 				$(".jp-type-single").css({ 	 					'width' : ($("#jp_container_1").width()), 	 					'height' : ($("#jp_container_1").height()) 	 				}); 	 				$("#jquery_jplayer_1").css({ 	 					'width' : ($("#con2").width()), 	 					'height' : ($("#con2").height()-71) 	 				}); 	 				$("#jp_video_0").css({ 	 					'width' : ($("#jquery_jplayer_1").width()), 	 					'height' : ($("#jquery_jplayer_1").height()) 	 				});				}				f += 1;				flag = "true";			},			swfPath: "${ctx}/js/jPlayer-2.9.1/jquery.jplayer.swf", 			supplied: "mp4, webmv, ogv, m4v",			useStateClassSkin: true,			autoBlur: false,			smoothPlayBar: true,			keyEnabled: true,			remainingDuration: false,			toggleDuration: true		});		$("#jp_container_1").css({				'width' : ($("#con2").width()),				'height' : ($("#con2").height())			});		$(".jp-type-single").css({			'width' : ($("#jp_container_1").width()),			'height' : ($("#jp_container_1").height())		});		$("#jquery_jplayer_1").css({			'width' : ($("#con2").width()),			'height' : ($("#con2").height()-71)		});		$("#jp_video_0").css({			'width' : ($("#jquery_jplayer_1").width()),			'height' : ($("#jquery_jplayer_1").height())		});	});});........................function skip(obj){	pg = obj.getAttribute("name");	view_table(json,pagenum);	if(playfile != ""){		$("#"+playfile).attr('src','../../../imgs/1097509.png');		$("#"+playfile).removeAttr('onclick');		$("#"+playfile).attr("onclick","StopPlayback(this)");	}}function viewplay(obj){	if(playfile != ""){		$("#"+playfile).attr('src','../../../imgs/1097510.png');		$("#"+playfile).removeAttr('onclick');		$("#"+playfile).attr("onclick","viewplay(this)");	}	playfile = obj.getAttribute("file");	var filename = obj.getAttribute("name");	var file = $(obj).attr('file');	$("#"+file+"tr").attr("ondblclick","StopPlayback(this)");	$("#"+file+"td").attr('src','../../../imgs/1097509.png');	$("#"+file+"td").removeAttr('onclick');	$("#"+file+"td").attr("onclick","StopPlayback(this)");	var mp4path = "../../../files/"+filename;	$("#jquery_jplayer_1").jPlayer("setMedia", {  		m4v: mp4path,    });	$("#jp_video_0").css({		'width' : ($("#jquery_jplayer_1").width()),		'height' : ($("#jquery_jplayer_1").height())	});	$("#jquery_jplayer_1").jPlayer("play");}function StopPlayback(obj) {	if($(obj).attr('vc') == "tr"){		var file = $(obj).attr('file');		$("#"+file+"tr").attr("ondblclick","keepplay(this)");		$("#"+file+"td").attr('src','../../../imgs/1097510.png');		$("#"+file+"td").removeAttr('onclick');		$("#"+file+"td").attr("onclick","keepplay(this)");	}else if($(obj).attr('vc') == "td"){		var file = $(obj).attr('file');		$("#"+file+"tr").attr("ondblclick","keepplay(this)");		$("#"+file+"td").attr('src','../../../imgs/1097510.png');		$("#"+file+"td").removeAttr('onclick');		$("#"+file+"td").attr("onclick","keepplay(this)");	}	$("#jquery_jplayer_1").jPlayer("pause");}function keepplay(obj){	if($(obj).attr('vc') == "tr"){		var file = $(obj).attr('file');		$("#"+file+"tr").attr("ondblclick","StopPlayback(this)");		$("#"+file+"td").attr('src','../../../imgs/1097509.png');		$("#"+file+"td").removeAttr('onclick');		$("#"+file+"td").attr("onclick","StopPlayback(this)");	}else if($(obj).attr('vc') == "td"){		var file = $(obj).attr('file');		$("#"+file+"tr").attr("ondblclick","StopPlayback(this)");		$("#"+file+"td").attr('src','../../../imgs/1097509.png');		$("#"+file+"td").removeAttr('onclick');		$("#"+file+"td").attr("onclick","StopPlayback(this)");	}	$("#jquery_jplayer_1").jPlayer("play");}

转载于:https://my.oschina.net/yongqingfan/blog/540510

你可能感兴趣的文章
js实现继承的几种方式
查看>>
[LintCode/LeetCode] Two Strings are Anagrams/Valid Anagram
查看>>
Consul入门03 - 注册服务
查看>>
[Centos]necessary tools for newbie
查看>>
前端临床手札——单元测试
查看>>
Java IO : File
查看>>
MySQL Replication
查看>>
JavaScript数组去重总结
查看>>
MVVM_Android-CleanArchitecture
查看>>
iOS开发-协议Protocol&代理delegate
查看>>
【系统架构师修炼之道】(4):绪论——Zachman 框架
查看>>
Foxify v0.10.7 发布,基于 TypeScript 的 Node 框架
查看>>
Python数据结构——双端队列
查看>>
GitHub 项目推荐:用深度学习让你的照片变得美丽 ...
查看>>
另类文件加密 图片当密码给文本加密
查看>>
MySQL数据库如何解决大数据量存储问题
查看>>
CENTOS6.5 yum配置
查看>>
《自顶向下网络设计(第3版)》——1.6 复习题
查看>>
【转】微信小程序给程序员带来的可能是一个赚钱的机遇
查看>>
《Programming Ruby中文版:第2版》终于正式出版了
查看>>