media.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. var media_count = 0;
  2. function img_play(src) {
  3. var height = 404;
  4. var width = 640;
  5. layer.open({
  6. area: [width + "px", height + "px"],
  7. type: 1,
  8. title: '图片预览',
  9. maxmin: true,
  10. closeBtn: 1,
  11. shadeClose: true,
  12. skin: 'layui-layer-nobg', //没有背景色
  13. shadeClose: true,
  14. resize: true,
  15. content: "<div style='height: 100%;width:100%;background:#000;text-align: center; '> <img src='" + src + "' style='height: 100%; '/></div>"
  16. });
  17. }
  18. function video_paly(src) {
  19. var height = 364;
  20. var width = 640;
  21. var css = "<style lang='css/text'>" + __inline('/node_modules/video.js/dist/video-js.min.css') + " .video-js .vjs-fullscreen-control { display: none;} </style>";
  22. var list = src.split(".");
  23. var videotype = list[list.length - 1]
  24. var html = css + '<video' +
  25. ' id="my-player' + (++media_count) + '"' +
  26. ' class="video-js"' +
  27. ' controls' +
  28. ' preload="auto"' +
  29. ' width="' + width + '" height="' + (height - 42) + '"' +
  30. ' data-setup=\'{}\'>' +
  31. ' <source src=\'' + src + '\' type="video/' + videotype + '"></source>' +
  32. ' <p class="vjs-no-js">' +
  33. ' To view this video please enable JavaScript, and consider upgrading to a' +
  34. ' web browser that' +
  35. ' <a href="http://videojs.com/html5-video-support/" target="_blank">' +
  36. ' supports HTML5 video' +
  37. ' </a>' +
  38. ' </p>' +
  39. '</video>';
  40. var lpayer = null;
  41. layer.open({
  42. area: [width + "px", height + "px"],
  43. type: 1,
  44. title: '视频播放',
  45. maxmin: true,
  46. closeBtn: 1,
  47. shadeClose: true,
  48. content: "<div id='video_content_div'>" + html + "</div>",
  49. success: function() {
  50. var options = {
  51. };
  52. lpayer = videojs('my-player' + media_count, options, function onPlayerReady() {
  53. videojs.log('Your player is ready!');
  54. // In this context, `this` is the player that was created by Video.js.
  55. this.play();
  56. // How about an event listener?
  57. this.on('ended', function() {
  58. videojs.log('Awww...over so soon?!');
  59. });
  60. });
  61. },
  62. full: function() {
  63. lpayer.width(window.innerWidth - 20);
  64. lpayer.height(window.innerHeight - 40 - 10);
  65. },
  66. restore: function() {
  67. lpayer.width(width);
  68. lpayer.height(height - 40);
  69. }
  70. });
  71. }