media.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. function video_paly(src) {
  2. var height = 264;
  3. var width = 640;
  4. __inline('/node_modules/video.js/dist/video.min.js');
  5. var css = "<style lang='css/text'>" + __inline('/node_modules/video.js/dist/video-js.min.css') + " .video-js .vjs-fullscreen-control { display: none;} </style>";
  6. var list = src.split(".");
  7. var videotype = list[list.length-1]
  8. var html = css + '<video' +
  9. ' id="my-player"' +
  10. ' class="video-js"' +
  11. ' controls' +
  12. ' preload="auto"' +
  13. ' width="' + width + '" height="' + height + '"' +
  14. ' data-setup=\'{}\'>' +
  15. ' <source src=\'' + src + '\' type="video/'+videotype+'"></source>' +
  16. ' <p class="vjs-no-js">' +
  17. ' To view this video please enable JavaScript, and consider upgrading to a' +
  18. ' web browser that' +
  19. ' <a href="http://videojs.com/html5-video-support/" target="_blank">' +
  20. ' supports HTML5 video' +
  21. ' </a>' +
  22. ' </p>' +
  23. '</video>';
  24. layer.open({
  25. area: [width + "px", height + "px"],
  26. type: 1,
  27. title: false,
  28. closeBtn: 0,
  29. shadeClose: true,
  30. content: html
  31. });
  32. var player = videojs('my-player');
  33. var options = {
  34. };
  35. var player = videojs('my-player', options, function onPlayerReady() {
  36. videojs.log('Your player is ready!');
  37. // In this context, `this` is the player that was created by Video.js.
  38. this.play();
  39. // How about an event listener?
  40. this.on('ended', function() {
  41. videojs.log('Awww...over so soon?!');
  42. });
  43. });
  44. }