Html5弹幕视频播放器插件Danmmu Player动态连接到数据库示例
2017-07-12 23:09
633 查看
插件描述:Danmmu Player是一个具备弹幕功能的Html5视频播放器。 具备弹幕视频播放,接受用户发送彩色弹幕,实时调解弹幕显示效果等功能。 Danmmu Player意在使开发者能便捷的在网站中实现弹幕视频播放。
Danmmu Player动态连接到数据库示例:
插入该插的css、js文件。
配置参数:
js中数据库参数处理部分:
query.php文件:
stone.php文件:
数据库2shou结构:
完整代码见https://download.csdn.net/download/cc1314_/10209859
Danmmu Player动态连接到数据库示例:
插入该插的css、js文件。
<div id="danmup"></div>
配置参数:
<script> $("#danmup").DanmuPlayer({ islogin:<?PHP echo($islogin); ?>,//自建属性 poster:"<?PHP if($obj->ImageURL==""){?>images/noImg.jpg<?PHP }else{?>user/images/<?PHP echo($obj->ImageURL); ?><?PHP } ?>",//自建属性 src:"user/video/abc.mp4",//视频源 height: "480px", //区域的高度 width: "100%" ,//区域的宽度 urlToGetDanmu:"query.php",//从后端获取弹幕数据 urlToPostDanmu:"stone.php",//发送弹幕数据给后端保存入库 gd:<?PHP echo($gid); ?>,//自建属性 ud:"<?PHP echo($UserName); ?>",//自建属性 ndmid:ndmid,//自建属性 }); </script>
js中数据库参数处理部分:
//从后端获取弹幕 this.getDanmu = function () { $.get(that.options.urlToGetDanmu, { GoodsId: that.options.gd, ndmid:that.options.ndmid, }, function (data, status) { danmuFromSql = eval(data); for (var i = 0; i < danmuFromSql.length; i++) { try { var danmuLs = eval('(' + danmuFromSql[i] + ')'); } catch (e) { continue; } $(that.id + ' .danmu-div').danmu("addDanmu", danmuLs); } }); }; if (options.urlToGetDanmu) this.getDanmu(); //发送弹幕 this.sendDanmu = function (e) { var text = $(e.data.that.id + " .danmu-input").get(0).value; if (text.length == 0) { return; } if (text.length > 100){ alert("弹幕过长!"); return; } text = text.replace(/&/g, ">").replace(/</g, "<").replace(/>/g, ">").replace(/\"/g, """).replace(/\n/g, "<br>"); var color = e.data.that.danmuColor; var position = $(e.data.that.id + " input[name=danmu_position]:checked").val(); var size = $(e.data.that.id + " input[name=danmu_size]:checked").val(); var time = $(e.data.that.id + " .danmu-div").data("nowTime") + 3; var textObj = '{ "text":"'+e.data.that.options.ud+':' + text + '","color":"' + color + '","size":"' + size + '","position":"' + position + '","time":' + time + '}'; if(e.data.that.options.islogin==0){ $("#tishi").show(); }else{ if (e.data.that.options.urlToPostDanmu) $.post(e.data.that.options.urlToPostDanmu, { danmu: textObj, GoodsId: e.data.that.options.gd, UserId:e.data.that.options.ud, }, function(data){} ); textObj = '{ "text":"'+e.data.that.options.ud+':' + text + '","color":"' + color + '","size":"' + size + '","position":"' + position + '","time":' + time + ',"isnew":""}'; var newObj = eval('(' + textObj + ')'); $(e.data.that.id + " .danmu-div").danmu("addDanmu", newObj); $(e.data.that.id + " .danmu-input").get(0).value = ''; $(e.data.that).trigger("senddanmu"); } };
query.php文件:
<?php header('Content-type:text/html;charset=utf8'); $conn = @ mysql_connect("localhost", "你的mysql用户名", "你的密码") or die("datebase can't been connected"); mysql_select_db("2shou", $conn);//数据库2shou mysql_query("set names 'utf8'"); // $gd=$_GET['GoodsId'];//从js获取数据 $ndmid=$_GET['ndmid'];//从js获取数据 $ndmidc=explode(',',$ndmid); $sql="SELECT danmu FROM danmu where GoodsId = '" . $gd . "' and dmid not in('".$ndmidc[0]."','".$ndmidc[1]."','".$ndmidc[2]."','".$ndmidc[3]."','".$ndmidc[4]."','".$ndmidc[5]."','".$ndmidc[6]."','".$ndmidc[7]."','".$ndmidc[8]."','".$ndmidc[9]."')"; $query=mysql_query($sql); //echo $danmu; echo "["; $first=0; while($row=mysql_fetch_array($query)){ if ($first) { echo ","; } $first=1; echo "'".$row['danmu']."'"; } echo "]"; ?>
stone.php文件:
<?php header('Content-type:text/html;charset=utf8'); date_default_timezone_set('Asia/Chongqing'); //系统时间差8小时问题 $conn = @ mysql_connect("localhost", "。。。", "。。。") or die("datebase can't been connected"); mysql_select_db("2shou", $conn); mysql_query("set names 'utf8'"); $danmu=$_POST['danmu'];//从js获取数据 $gd=$_POST['GoodsId'];//从js获取数据 $ud=$_POST['UserId'];//从js获取数据 $sendtime=strftime("%Y-%m-%d %H:%M:%S"); $sql="INSERT INTO Danmu (GoodsId, UserId, danmu, SendTime) VALUES ('" . $gd . "','" . $ud . "','" . $danmu . "','" . $sendtime ."')"; $query=mysql_query($sql); ?>
数据库2shou结构:
完整代码见https://download.csdn.net/download/cc1314_/10209859
相关文章推荐
- Html5弹幕视频播放器插件Danmu介绍
- Html5弹幕视频播放器插件
- jQuery Danmmu Player 弹幕视频
- WordPress插件 Fox Video Player 独家HTML5广告视频播放器插件[更新至v3.0.1]
- 使用danmuplayer.js插件实现Java web网站视频发弹幕
- jqm视频播放器,html5视频播放器,html5音乐播放器,html5媒体播放器,video开展demo,html5视频播放演示示例,html5移动视频播放器
- jqm视频播放器,html5视频播放器,html5音乐播放器,html5播放器,video开发demo,html5视频播放示例,html5手机视频播放器
- 动态切换数据库连接配置简单示例
- 【html5多媒体】自定义播放器(弹幕,水印,甚至在视频开头添加封面)
- jqm视频播放器,html5视频播放器,html5音乐播放器,html5播放器,video开发demo,html5视频播放示例,html5手机视频播放器
- 用 JavaScript 写服务器端连接数据库的代码示例
- 使用Using System.Data.OleDb; 连接数据库,又一种动态绑定GridView显示数据。
- 各种数据库的JDBC连接示例
- 网页中添加播放器播放视频文件与网页增加背景音乐示例【深海原创】
- 利用JTDS连接数据库并操作示例
- 动态加载数据库连接和操作类
- 动态的连接到数据库的方法
- 动态附加数据库文件, 连接报错:此版本的 SQL Server 不支持用户实例登录标志
- db2监视表空间使用情况、中断数据库连接进程的脚本示例
- asp.net的数据库连接数据示例