智慧画屏客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

347 lines
8.3 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <view class="main_container">
  3. <view class="screen-swiper-box">
  4. <swiper :hidden="autoplay" class="screen-swiper" indicator-dots="true" circular="true" :autoplay="!autoplay"
  5. indicator-active-color="#71C1F6" indicator-color="#ffffff" interval="3000" duration="500">
  6. <swiper-item>
  7. <image class="swiperImage" :src="pictureUrl" mode="scaleToFill"></image>
  8. </swiper-item>
  9. <swiper-item>
  10. <image class="swiperImage" :src="videoPicture" @click="showVideo" mode="scaleToFill"></image>
  11. </swiper-item>
  12. </swiper>
  13. <view :hidden="!autoplay" class="video">
  14. <video class="MyVideo" id="myVideo" :src="videoUrl" objectFit="cover" @play="BoFang()" @pause="ZanTing()"
  15. controls="true">
  16. <cover-image class="videoClose" @click="colseVideo()"
  17. src="https://i-1-lanrentuku.qqxzb-img.com/2020/11/20/7ab68fc9-e126-47da-bcf2-7dd7a3b9f540.jpg?imageView2/2/w/1024/">
  18. </cover-image>
  19. <!-- 添加一个覆盖在视频上的关闭按钮cover-image -->
  20. </video>
  21. </view>
  22. </view>
  23. <view class="show-audio"></view>
  24. <view style="position:absolute; bottom:55.55rpx; left: 69.44rpx; color: #fff; z-index: 99999;">{{infoTxt}}--{{linkUrl}}--{{ audioName }}</view>
  25. <!-- <view v-if="!deviceInfoShow" class="local-data">
  26. <text class="title">欢迎使用数字新视窗</text>
  27. <view class="data-info">设备ID : 123456789</view>
  28. <view class="data-info">设备账号 : 123456789</view>
  29. <view class="data-info">设备名称 : CVBBN2</view>
  30. <view class="count-down" @click="deviceInfoShow=true">{{ count }}</view>
  31. </view> -->
  32. </view>
  33. </template>
  34. <script>
  35. import one from './show2.js';
  36. let innerAudioContext = uni.createInnerAudioContext();
  37. export default {
  38. components: {},
  39. data() {
  40. return {
  41. // 已登录情况显示6S得设备信息
  42. count: 6,
  43. deviceInfoShow: false,
  44. autoplay: false,
  45. // 素材
  46. materialsCont: [],
  47. show_materials: [],
  48. contentIndex: 0,
  49. itemIndex: 0,
  50. linkUrl: '',
  51. timer: null,
  52. duration: null,
  53. audioSrc: null,
  54. audioName: null,
  55. itemLength: [],
  56. flagIndex: 0,
  57. infoTxt:'',
  58. voicePlayer: null,
  59. videoPicture: 'https://desk-fd.zol-img.com.cn/t_s720x360c5/g6/M00/0B/06/ChMkKmFBixKIYQSCAAJVqqciWmYAATuTwFJgJkAAlXC803.jpg',
  60. pictureUrl: 'https://img-baofun.zhhainiao.com/market/133/2366564fa6b83158208eb3181752a8d6_preview.jpg',
  61. videoUrl: 'https://stream7.iqilu.com/10339/upload_transcode/202002/18/20200218114723HDu3hhxqIT.mp4',
  62. };
  63. },
  64. onReady: function(res) {
  65. // #ifndef MP-ALIPAY
  66. this.videoContext = uni.createVideoContext('myVideo')
  67. // #endif
  68. },
  69. onLoad() {
  70. const _this = this;
  71. let result = one.data.data;
  72. this.materialsCont = result;
  73. this.materialsCont.map(item => {
  74. this.itemLength = this.itemLength.concat(item.show_materials.length);
  75. this.show_materials = this.show_materials.concat(item.show_materials);
  76. });
  77. // 初始化
  78. this.changIndex();
  79. },
  80. created() {
  81. this.atuo();
  82. },
  83. mounted() {
  84. // this.countdown();
  85. this.changeMaterial();
  86. this.voicePlayer.play();
  87. },
  88. methods: {
  89. // 轮播图事件
  90. showVideo() {
  91. this.autoplay = true;
  92. this.videoContext.play();
  93. },
  94. colseVideo() {
  95. this.videoContext.pause();
  96. this.autoplay = false;
  97. },
  98. BoFang() {
  99. this.videoContext.play();
  100. },
  101. ZanTing() {
  102. this.videoContext.pause();
  103. },
  104. swiperChange(current, source){
  105. // 切换如果不是视频位置 暂停视频
  106. console.log(current.target.current)
  107. if(current.target.current == 0){
  108. //this.player.seek(0)
  109. this.player.play()
  110. //this.showFullVideo=true;
  111. }else{
  112. this.player.pause()
  113. //this.player.stop()
  114. //this.showFullVideo=false;
  115. }
  116. },
  117. changeMaterial() {
  118. const _this = this;
  119. clearInterval(_this.timer);
  120. _this.timer = setInterval(() => {
  121. _this.duration -= 1;
  122. if (_this.duration == 0) {
  123. _this.itemIndex++;
  124. _this.flagIndex++;
  125. this.changIndex();
  126. }
  127. }, 1000);
  128. },
  129. changIndex() {
  130. const _this = this;
  131. if (_this.itemIndex == this.show_materials.length) {
  132. // clearInterval(_this.timer);
  133. this.itemIndex = 0;
  134. this.flagIndex = 0;
  135. this.contentIndex = 0;
  136. innerAudioContext.stop();
  137. }
  138. _this.duration = this.show_materials[this.itemIndex].duration;
  139. _this.linkUrl = this.show_materials[this.itemIndex].deposit_url;
  140. if (this.show_materials[this.itemIndex].bgm_url) {
  141. _this.audioSrc = '../../static/source/' + this.show_materials[this.itemIndex].bgm_url;
  142. _this.audioName = this.show_materials[this.itemIndex].bgm_name;
  143. } else {
  144. if (this.contentIndex == this.itemLength.length) {
  145. this.flagIndex = 0;
  146. this.contentIndex = 0;
  147. }else{
  148. if (this.flagIndex == this.itemLength[this.contentIndex]) {
  149. this.flagIndex = 0;
  150. this.contentIndex++;
  151. }
  152. }
  153. if (this.materialsCont[this.contentIndex].bgm_main) {
  154. this.audioSrc = '../../static/source/' + this.materialsCont[this.contentIndex].bgm_main;
  155. this.audioName = this.materialsCont[this.contentIndex].bgm_name;
  156. }
  157. }
  158. // this.playVoice(this.audioSrc);
  159. if (this.show_materials[this.itemIndex].material_type == 1) {
  160. innerAudioContext.stop();
  161. }
  162. },
  163. videoPlayEnd() {
  164. this.itemIndex++;
  165. this.flagIndex++;
  166. this.changIndex();
  167. },
  168. playVoice(src) {
  169. if (innerAudioContext != undefined) {
  170. innerAudioContext.stop();
  171. }
  172. innerAudioContext = uni.createInnerAudioContext();
  173. innerAudioContext.stop();
  174. innerAudioContext.src = src;
  175. innerAudioContext.autoplay = true;
  176. innerAudioContext.onPlay(() => {
  177. this.infoTxt = ''
  178. this.infoTxt = '开始播放'
  179. console.log('开始播放');
  180. });
  181. innerAudioContext.onError(res => {
  182. console.log(res.errMsg);
  183. console.log(res.errCode);
  184. innerAudioContext.stop();
  185. });
  186. innerAudioContext.onPause(() => {
  187. //暂停监听
  188. this.infoTxt = '暂停'
  189. console.log('暂停');
  190. // innerAudioContext.stop();
  191. });
  192. innerAudioContext.onEnded(() => {
  193. // 自然播放结束监听也需要更改isPause 开关状态
  194. this.infoTxt = '音频自然播放结束事件'
  195. console.log('音频自然播放结束事件');
  196. innerAudioContext.stop();
  197. });
  198. },
  199. atuo() {
  200. this.autoplay = true;
  201. },
  202. countdown() {
  203. this.count = 6;
  204. const timer = setInterval(() => {
  205. this.count -= 1;
  206. if (this.count < 1) {
  207. clearInterval(timer);
  208. this.deviceInfoShow = true;
  209. console.log('倒计时结束');
  210. }
  211. }, 1000);
  212. }
  213. }
  214. };
  215. </script>
  216. <!--
  217. <style scoped>
  218. .main_container {
  219. position: relative;
  220. overflow: hidden;
  221. background: #000;
  222. }
  223. .show-item {
  224. /* width: 100%;
  225. height: 100vh; */
  226. display: flex;
  227. flex-direction: column;
  228. align-items: center;
  229. justify-content: center;
  230. }
  231. .show-item .show-img {
  232. width: 100%;
  233. height: 100vh;
  234. object-fit: cover;
  235. }
  236. .show-item uni-video {
  237. width: 100%;
  238. }
  239. .show-video {
  240. width: 100%;
  241. height: 100vh;
  242. }
  243. .show-audio {
  244. position: fixed;
  245. bottom: 79.16rpx;
  246. right: 46.52rpx;
  247. width: 159.72rpx;
  248. height: 152.08rpx;
  249. background: url(~@/static/images/an-yy.png) no-repeat;
  250. background-size: cover;
  251. }
  252. .show-audio uni-image {
  253. width: 159.72rpx;
  254. height: 152.08rpx;
  255. }
  256. .local-data {
  257. position: absolute;
  258. left: 50%;
  259. top: 50%;
  260. display: flex;
  261. flex-direction: column;
  262. justify-content: center;
  263. width: 625rpx;
  264. height: 555.55rpx;
  265. transform: translate(-50%, -50%);
  266. font-size: 27.77rpx;
  267. color: #333;
  268. border-radius: 27.77rpx;
  269. background: rgba(255, 255, 255, 0.85);
  270. }
  271. .title {
  272. margin-bottom: 32.63rpx;
  273. font-size: 56.94rpx;
  274. text-align: center;
  275. }
  276. .data-info {
  277. padding: 0 83.33rpx;
  278. margin-bottom: 32.63rpx;
  279. }
  280. .count-down {
  281. position: absolute;
  282. right: 34.72rpx;
  283. top: 27.77rpx;
  284. width: 48.61rpx;
  285. height: 48.61rpx;
  286. font-size: 30.55rpx;
  287. text-align: center;
  288. line-height: 48.61rpx;
  289. border: 1px solid #333;
  290. border-radius: 50%;
  291. }
  292. </style> -->
  293. <style lang="scss" scoped>
  294. .screen-swiper-box {
  295. position: absolute;
  296. width: 100%;
  297. height: 350rpx;
  298. .video {
  299. height: 100%;
  300. width: 100%;
  301. position: absolute;
  302. .MyVideo {
  303. width: 100%;
  304. position: absolute;
  305. height: 100%;
  306. .videoClose {
  307. height: 40rpx;
  308. width: 40rpx;
  309. position: absolute;
  310. right: -1rpx;
  311. z-index: 99999;
  312. background-repeat: no-repeat;
  313. background-size: 100% 100%;
  314. }
  315. }
  316. }
  317. .screen-swiper {
  318. width: 100%;
  319. position: absolute;
  320. height: 100%;
  321. .swiperImage {
  322. width: 100%;
  323. position: absolute;
  324. height: 100%;
  325. }
  326. }
  327. }
  328. </style>