Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.72 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
  3. <head>
  4.     <title>Philips Initiator XML</title>
  5.     <meta charset="utf-8">
  6. </head>
  7. <body>
  8. <div id="debug"
  9.      style=" display: block; position: absolute; z-index: 9999; width: 1200px; height: 250px; background-color: #5cbb44; padding: 20px; font-size: 22px; color: white; opacity: 0.8"></div>
  10. <video id="videoid" height="720" width="1280" autoplay></video>
  11. <script>
  12.  
  13. var url = '';
  14. var video;
  15.  
  16. function initialize() {
  17.     addLog('Hi!');
  18.     video = document.getElementById('videoid');
  19.     video.addEventListener('error', onVideoError, true);
  20.  
  21.     video.addEventListener("loadstart", function() {
  22.         addLog('loadstart!');
  23.     }, true);
  24.     video.addEventListener("canplay", function() {
  25.         addLog('canplay!');
  26.     }, true);
  27.     video.addEventListener("pause", function() {
  28.         addLog('pause!');
  29.     }, true);
  30.     video.addEventListener("playing", function() {
  31.         addLog('playing!');
  32.     }, true);
  33.     video.addEventListener("seeked", function() {
  34.         addLog('seeked!');
  35.     }, true);
  36.     video.addEventListener("seeking", function() {
  37.         addLog('seeking!');
  38.     }, true);
  39.     video.addEventListener("volumechange", function() {
  40.         addLog('volumechange!');
  41.     }, true);
  42.     video.addEventListener("durationchange", function() {
  43.         addLog('durationchange!');
  44.     }, true);
  45.     video.addEventListener("ended", function() {
  46.         addLog('loadstart!');
  47.     }, true);
  48.     video.addEventListener("waiting",function() {
  49.         addLog('waiting!');
  50.     }, true);
  51.  
  52.     addVideoSourceAndPlay();
  53. }
  54.  
  55. function addVideoSourceAndPlay() {
  56.     addLog('create source with manifest');
  57.     addLog(url);
  58.     var source = document.createElement('source');
  59.     source.setAttribute('src', url);
  60.     source.setAttribute('type', 'application/vnd.ms-playready.initiator+xml');
  61.     video.appendChild(source);
  62.     addLog('try to play video');
  63.     video.play();
  64. }
  65.  
  66. function onVideoError(e) {
  67.     addLog('Error!');
  68.     addLog('network state: ' + video.networkState);
  69.     if (video.error) {
  70.         addLog('error code: ' + video.error.code);
  71.     }
  72. }
  73.  
  74. function addLog(message) {
  75.     var debug = document.getElementById("debug");
  76.     console.log(message);
  77.     debug.innerHTML += message + '</br>';
  78. }
  79.  
  80. function keyCodes(e) {
  81.     var currentPosition = video.currentTime;
  82.     if (e.keyCode == 49) {
  83.         window.location.reload();
  84.     } else if (e.keyCode == 415) {
  85.         video.play();
  86.     } else if (e.keyCode == 19) {
  87.         video.pause();
  88.     } else if (e.keyCode == 417) {
  89.         video.currentTime = currentPosition + 10;
  90.     } else if (e.keyCode == 412) {
  91.         video.currentTime = currentPosition - 10;
  92.     } else if (e.keyCode == 461) {
  93.         window.close();
  94.     }
  95. }
  96.  
  97. addEventListener('keydown', keyCodes);
  98. addEventListener('load', initialize);
  99.  
  100. </script>
  101. </body>
  102. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement