video.nvue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template name="dever-video">
  2. <view>
  3. <view class="player">
  4. <video
  5. :src="src"
  6. preload
  7. autoplay
  8. :muted="!play"
  9. :show-play-btn="true"
  10. :show-center-play-btn="false"
  11. :controls="false"
  12. :loop="true"
  13. :id="id()"
  14. objectFit="fill"
  15. :enable-progress-gesture="false"
  16. play-btn-position="center"
  17. class="video"
  18. :playsinline="true"
  19. :webkit-playsinline="true"
  20. x-webkit-airplay="allow"
  21. x5-video-player-type="h5-page"
  22. >
  23. </video>
  24. </view>
  25. <view class="control" @click="open">
  26. <cover-image v-if="poster" class="poster" :src="pic">
  27. </cover-image>
  28. <cover-image
  29. class="ico-video-play" v-if="!play"></cover-image>
  30. <pos :item="item" :down="src" v-if="item"></pos>
  31. <cover-view class="cover-view-right" v-if="showInfo">
  32. <cover-image :src="item[0].pic"
  33. class="avater img"
  34. @click.stop="tapAvater"></cover-image>
  35. <text class="right-follow">+</text>
  36. <cover-image
  37. style="position:relative;top:-20upx;"
  38. :src="up ? '../../static/video/axc.png' : '../../static/video/bed.png'"
  39. class="img-left" @click.stop="tapLove"></cover-image>
  40. <text class="right-text">1</text>
  41. <cover-image src="@/static/video/ay2.png"
  42. style="height: 80upx;" class="img-left" @click.stop="tapMsg"></cover-image>
  43. <text class="right-text">10</text>
  44. <cover-image src="@/static/video/b6p.png"
  45. style="height: 76upx;" class="img-left" @click.stop="tapShare"></cover-image>
  46. <text class="right-text">10</text>
  47. <cover-image src="@/static/video/changpian.png" class="musicIcon img">
  48. </cover-image>
  49. </cover-view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import pos from "@/pages/dream/view/pos.vue";
  55. export default {
  56. name: "dever-video",
  57. props: {
  58. item : {
  59. type : Object,
  60. value : null
  61. },
  62. src : {
  63. type : String,
  64. value : null
  65. },
  66. index : {
  67. type : Number,
  68. value : null
  69. },
  70. vid : {
  71. type : String,
  72. value : null
  73. },
  74. pic : {
  75. type : String,
  76. value : null
  77. },
  78. },
  79. data() {
  80. return {
  81. play : false,
  82. poster : true,
  83. video : false,
  84. showInfo : false,
  85. };
  86. },
  87. mounted() {
  88. this.video = uni.createVideoContext(this.id(), this);
  89. },
  90. methods:{
  91. //获取video_id
  92. id : function() {
  93. return 'video_' + this.vid + '_' + this.index;
  94. },
  95. start : function() {
  96. this.poster = false;
  97. this.video.play();
  98. this.play = true;
  99. },
  100. stop : function() {
  101. this.video.pause();
  102. this.play = false;
  103. },
  104. open : function() {
  105. if (!this.play) {
  106. this.start();
  107. } else {
  108. this.stop();
  109. }
  110. },
  111. },
  112. components:{
  113. pos
  114. }
  115. }
  116. </script>
  117. <style scoped>
  118. .control {
  119. width: 100%;
  120. height: 100%;
  121. z-index: 2;
  122. background: transparent;
  123. position: absolute;
  124. left: 0;
  125. top: 0;
  126. overflow: hidden;
  127. }
  128. .player {
  129. width: 100%;
  130. height: 100%;
  131. overflow: hidden;
  132. z-index: 1;
  133. background: transparent;
  134. position: absolute;
  135. left: 0;
  136. top: 0;
  137. overflow: hidden;
  138. }
  139. .video {
  140. width: 101%;
  141. height: 101%;
  142. margin-left: -5rpx;
  143. margin-top: -5rpx;
  144. position: relative;
  145. background-color: transparent;
  146. z-index: 1;
  147. }
  148. .poster{
  149. background-size: cover;
  150. position: absolute;
  151. left: 0;
  152. top: 0;
  153. width: 100%;
  154. height: 100%;
  155. }
  156. .ico-video-play{
  157. background: url(@/static/icon/ico-video-play.png) no-repeat;
  158. background-size: cover;
  159. width: 100rpx;
  160. height: 100rpx;
  161. position: absolute;
  162. left: 50%;
  163. top: 50%;
  164. transform: translate3d(-50%,-50%,0);
  165. }
  166. .cover-view-left {
  167. position: absolute;
  168. margin-left: 20upx;
  169. width: 580upx;
  170. bottom: 110upx;
  171. z-index: 9999;
  172. font-size: 14px;
  173. color: #ffffff;
  174. }
  175. .left-text {
  176. font-size: 14px;
  177. color: #ffffff;
  178. }
  179. .cover-view-right {
  180. position: absolute;
  181. bottom: 40px;
  182. right: 30upx;
  183. z-index: 9999;
  184. text-align: center;
  185. }
  186. .avater {
  187. border-radius: 50%;
  188. border-width: 2px;
  189. border-style: solid;
  190. border-color: #ffffff;
  191. }
  192. .img {
  193. height: 90upx;
  194. width: 90upx;
  195. margin-bottom: 110upx;
  196. }
  197. .img-left {
  198. width: 80upx;
  199. height: 66upx;
  200. padding-left: 4px;
  201. }
  202. .right-follow {
  203. position: absolute;
  204. z-index: 100;
  205. top: 75upx;
  206. left: 28upx;
  207. color: #ffffff;
  208. font-size: 16px;
  209. width: 34upx;
  210. height: 34upx;
  211. background-color: #f12f5b;
  212. text-align: center;
  213. line-height: 34upx;
  214. border-radius: 17upx;
  215. }
  216. .right-text {
  217. color: #ffffff;
  218. font-size: 11px;
  219. text-align: center;
  220. margin-bottom: 40upx;
  221. }
  222. .musicIcon {
  223. margin-top: 40upx;
  224. }
  225. @keyframes rotating {
  226. from {
  227. transform: rotate(0);
  228. }
  229. to {
  230. transform: rotate(360deg);
  231. }
  232. }
  233. .view-left-text-content {
  234. flex: 1;
  235. }
  236. .view-left-text {
  237. color: #ffffff;
  238. font-size: 18px;
  239. margin-bottom: 10upx;
  240. font-weight: bold;
  241. }
  242. .text-content-text {
  243. color: #ffffff;
  244. font-size: 16px;
  245. line-height: 50upx;
  246. height: 100upx;
  247. overflow: hidden;
  248. }
  249. </style>