video.nvue 4.7 KB

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