Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. <html lang="en">
  2. <head>
  3. <title>Video.js | HTML5 Video Player</title>
  4. <link href="http://vjs.zencdn.net/5.19/video-js.css" rel="stylesheet">
  5. <script src="http://vjs.zencdn.net/ie8/1.1/videojs-ie8.min.js"></script>
  6. <script src="http://vjs.zencdn.net/5.19/video.js"></script>
  7. <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
  8. integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g="
  9. crossorigin="anonymous"></script>
  10. </head>
  11. <body>
  12. <video id="example_video_1" class="video-js vjs-default-skin" controls
  13. preload="none" width="640" height="264"
  14. poster="http://vjs.zencdn.net/v/oceans.png" data-setup="{}">
  15. <source src="C:xampphtdocsAi_Edutech_trial_projectvideo jsvideo-js-
  16. 6.4.0examplessimple-embedHTML Tutorial for Beginners - 00 -
  17. Introduction
  18. to HTML.mp4" type="video/mp4">
  19. <track kind="captions" src="C:xampphtdocsAi_Edutech_trial_projectvideo
  20. jsvideo-js-6.4.0examplessimple-embedHTML Tutorial for Beginners - 00 -
  21. Introduction to HTML [English].vtt" srclang="en" label="English" default>
  22. <p class="vjs-no-js">To view this video please enable JavaScript, and
  23. consider upgrading to a web browser that <a
  24. href="http://videojs.com/html5-
  25. video-support/" target="_blank">supports HTML5 video</a></p>
  26. </video>
  27. <script type="text/javascript">
  28. function ajax_post_one(count,duration,tot_time,arr){
  29. // Create our XMLHttpRequest object
  30. var hr = new XMLHttpRequest();
  31. var url = "my_parse_file_one.php";
  32. alert(count);
  33. alert(tot_time);
  34. var num_pause = count;
  35. var tt = tot_time;
  36. var time_arr=arr;
  37. var dur = duration;
  38. var vars =
  39. "count="+num_pause+"&tot_time="+tt+"&arr="+time_arr+"&duration="+dur;
  40. hr.open("POST", url, true);
  41. hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  42. hr.onreadystatechange = function() {
  43. if(hr.readyState == 4 && hr.status == 200) {
  44. var return_data = hr.responseText;
  45. document.getElementById("status").innerHTML = return_data;
  46. }
  47. }
  48. hr.send(vars);
  49. document.getElementById("status").innerHTML = "processing...";
  50. }
  51. $(document).ready(function(){
  52. var player = videojs('example_video_1');
  53. var pause_t=0;
  54. var tot_time=0;
  55. var duration=0;
  56. var count=0;
  57. var arr = new Array();
  58. player.ready(function() {
  59. //alert("Working");
  60. });
  61. player.on("pause",function(){
  62. pause_t = player.currentTime();
  63. tot_time=tot_time + pause_t;
  64. arr= arr +pause_t;
  65. });
  66. player.on("play",function(){
  67. });
  68. player.on("play",function(){
  69. count=count+1;
  70. });
  71. //This tells the total duration of the video...
  72. player.one('loadedmetadata', function() {
  73. duration = player.duration();
  74. });
  75. var video = videojs('example_video_1').ready(function(){
  76. var player = this;
  77. player.on('ended', function() {
  78. alert(tot_time);
  79. alert(arr);
  80. ajax_post_one(count,duration,tot_time,arr);
  81. });
  82. });
  83. });
  84. </script>
  85. <p> Status down here</p>
  86. <div id="status"></div>
  87. </body>
  88. </html>
  89.  
  90. <?php
  91. $servername = "localhost";
  92. $username = "root";
  93. $password = "";
  94. // Create connection
  95. $conn = new mysqli($servername, $username, $password);
  96. // Check connection
  97. if ($conn->connect_error) {
  98. die("Connection failed: " . $conn->connect_error);
  99. }
  100. echo "Connected successfully";
  101. //$db = mysqli_select_db("ajax", $conn); // Selecting Database
  102. mysqli_select_db($conn,"videojs");
  103. //MySQL Query to read datao
  104. $num_pause =($_POST['count']);
  105. $tot_time =($_POST['tot_time']);
  106. $time_arr =($_POST['arr']);
  107. $duration =($_POST['duration']);
  108. echo "$num_pause";
  109. echo "$tot_time";
  110. $sql = "INSERT INTO info (num_pause, duration, tot_time, time_arr)
  111. VALUES ('$num_pause', '$tot_time','$duration','$time_arr')";
  112. if ($conn->query($sql) === TRUE) {
  113. echo "New record created successfully";
  114. } else {
  115. echo "Error: " . $sql . "<br>" . $conn->error;
  116. }
  117. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement