insVideo.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <div class="videoBox">
  3. <vue-drag-resize
  4. :w="videoW"
  5. :h="videoH"
  6. :y="videoY"
  7. :x="videoX"
  8. :isActive="true"
  9. :parentH="docY"
  10. :preventActiveBehavior="true"
  11. :AspectRatio="true"
  12. @resizing="onResizingVideo"
  13. @dragging="onResizing"
  14. @resizestop="resizeVideostop"
  15. @dragstop="resizeVideostop"
  16. class="videoWrap"
  17. >
  18. <!-- -->
  19. <div class="videowall"></div>
  20. <div class="showBtnList">
  21. <i class="el-icon-close" @click="closeVideo"></i>
  22. </div>
  23. <video
  24. id="video"
  25. :src="src"
  26. :width="VideoWidth"
  27. :height="VideoHeight"
  28. controls
  29. loop
  30. ></video>
  31. </vue-drag-resize>
  32. </div>
  33. </template>
  34. <script>
  35. import VueDragResize from "vue-drag-resize";
  36. export default {
  37. components: {
  38. "vue-drag-resize": VueDragResize,
  39. },
  40. props: ["docY","videoSrc"],
  41. data() {
  42. return {
  43. videoX: 0,
  44. videoY:200,
  45. videoW: 640,
  46. videoH: 390,
  47. src: this.videoSrc,
  48. };
  49. },
  50. mounted() {
  51. let clientWidth =
  52. document.documentElement.clientWidth || document.body.clientWidth;
  53. this.videoX = (clientWidth - 640) / 2;
  54. this.videoY = (this.docY - 320) / 2;
  55. },
  56. methods: {
  57. onResizingVideo(e) {
  58. this.$emit('isResizing',true)
  59. // this.isResizing = true;
  60. this.videoH = Math.abs(e.height);
  61. this.videoW = Math.abs(e.width);
  62. },
  63. resizeVideostop(e) {
  64. this.videoH = Math.abs(e.height);
  65. this.videoW = Math.abs(e.width);
  66. setTimeout(() => {
  67. // this.isResizing = false;
  68. this.$emit('isResizing',false)
  69. }, 500);
  70. },
  71. onResizing(e) {
  72. // this.isResizing = true;
  73. this.$emit('isResizing',true)
  74. },
  75. closeVideo(){
  76. this.$emit('closeVideo')
  77. }
  78. },
  79. computed: {
  80. VideoWidth() {
  81. return this.videoW + "px";
  82. },
  83. VideoHeight() {
  84. return this.videoH - 30 + "px";
  85. },
  86. },
  87. };
  88. </script>
  89. <style lang="scss" scoped>
  90. .videowall {
  91. height: 30px;
  92. background-color: #ccc;
  93. }
  94. .content-container {
  95. // position: relative;
  96. // z-index: 2000;
  97. .showBtnList {
  98. display: flex;
  99. flex-direction: row;
  100. align-items: center;
  101. justify-content: space-around;
  102. font-size: 20px;
  103. position: absolute;
  104. right: 5px;
  105. top: 0;
  106. background-color: #ccc;
  107. height: 30px;
  108. // z-index: 2000;
  109. .icon {
  110. line-height: 30px;
  111. }
  112. }
  113. }
  114. .videoWrap {
  115. background-color: #fff;
  116. position: fixed;
  117. z-index: 20000;
  118. border: 1px solid #ccc;
  119. }
  120. </style>