智慧画屏客户端
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.

481 lines
13 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
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
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
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
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
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
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
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="show-content" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd">
  4. <view v-for="(item, index) in show_materials" :key="index" :class="['show-item', item.material_type == 1 && itemIndex == index ? 'show-video' : '']">
  5. <image
  6. :class="['show-img', 'animate__animated', item.material_type == 0 ? item.effect : '']"
  7. v-show="item.material_type == 0 && itemIndex == index"
  8. :src="linkUrl"
  9. mode="aspectFill"
  10. ></image>
  11. <video
  12. :id="'video' + index"
  13. v-if="item.material_type == 1 && itemIndex == index"
  14. :src="linkUrl"
  15. :controls="false"
  16. :autoplay="autoplay"
  17. :enable-progress-gesture="false"
  18. :enable-play-gesture="false"
  19. object-fit="contain"
  20. show-center-play-btn="false"
  21. @play="playEvent"
  22. @ended="videoPlayEnd"
  23. @waiting="waitingVideo"
  24. @loadeddata="loading"
  25. @timeupdate="timeUpdate"
  26. initial-time="initial_time"
  27. >
  28. <!-- <cover-view
  29. style="z-index:99;position: fixed;width:100%;height:100%;top:0;left:0;display:flex; justify-content:center; align-items:center;">
  30. <image style="width: 40px;height: 40px;"></image>
  31. </cover-view> -->
  32. </video>
  33. </view>
  34. </view>
  35. <!-- <swiper @change="changeMaterial()" style="height: 100%;">
  36. <swiper-item v-for="(item, index) in show_materials" :key="index" :class="['show-item', item.material_type == 1 && itemIndex == index ? 'show-video' : '']">
  37. <view class="item" v-if="item.material_type == 1 && itemIndex == index">
  38. <video id="myVideo" ref="myVideo"
  39. :src="linkUrl" :autoplay="autoplay" :controls="false" :enable-progress-gesture="false" object-fit="contain" @ended="videoPlayEnd"></video>
  40. <cover-view
  41. style="z-index:99;position: fixed;width:100%;height:100%;top:0;left:0;display:flex; justify-content:center; align-items:center;">
  42. <image style="width: 40px;height: 40px;"></image>
  43. </cover-view>
  44. </view>
  45. <view class="item" v-if="item.material_type == 0 && itemIndex == index">
  46. <image :src="linkUrl" :class="['show-img', 'animate__animated', item.material_type == 0 ? item.effect:'']"></image>
  47. </view>
  48. </swiper-item>
  49. </swiper> -->
  50. <view class="show-audio"></view>
  51. <view style="position:absolute; bottom:55.55rpx; left: 69.44rpx; color: #fff; z-index: 99999;">{{ infoTxt }}--{{ audioName }}</view>
  52. <!-- <view v-if="!deviceInfoShow" class="local-data">
  53. <text class="title">欢迎使用数字新视窗</text>
  54. <view class="data-info">设备ID : 123456789</view>
  55. <view class="data-info">设备账号 : 123456789</view>
  56. <view class="data-info">设备名称 : CVBBN2</view>
  57. <view class="count-down" @click="deviceInfoShow=true">{{ count }}</view>
  58. </view> -->
  59. </view>
  60. </template>
  61. <script>
  62. import one from './show2.js';
  63. let innerAudioContext = uni.createInnerAudioContext();
  64. export default {
  65. components: {},
  66. data() {
  67. return {
  68. // 已登录情况显示6S得设备信息
  69. count: 6,
  70. deviceInfoShow: false,
  71. autoplay: false,
  72. // 素材
  73. materialsCont: [],
  74. show_materials: [],
  75. contentIndex: 0,
  76. itemIndex: 0,
  77. linkUrl: '',
  78. timer: null,
  79. duration: null,
  80. audioSrc: null,
  81. audioName: null,
  82. itemLength: [],
  83. flagIndex: 0,
  84. infoTxt: '',
  85. video_real_time: 0,
  86. nitial_time: '',
  87. startY: 0,
  88. startX: 0,
  89. isAutoSwitch: true,
  90. moveX: 0, //滑动的x轴距离
  91. moveY: 0, //滑动的y轴距离
  92. like_state: 0 //-1:左滑,0:没滑动,1:右滑
  93. };
  94. },
  95. onLoad() {
  96. const _this = this;
  97. let result = one.data.data;
  98. this.materialsCont = result;
  99. this.materialsCont.map(item => {
  100. this.itemLength = this.itemLength.concat(item.show_materials.length);
  101. this.show_materials = this.show_materials.concat(item.show_materials);
  102. });
  103. // 初始化
  104. this.changIndex();
  105. },
  106. onReady: function(res) {
  107. const videoId = 'video'+this.itemIndex
  108. this.videoCtx = uni.createVideoContext(videoId)
  109. },
  110. created() {
  111. this.auto();
  112. },
  113. mounted() {
  114. // this.countdown();
  115. this.changeMaterial();
  116. },
  117. methods: {
  118. // 素材切换
  119. touchStart(event) {
  120. this.startX = event.touches[0].pageX;
  121. this.startY = event.touches[0].pageY;
  122. // console.log('开始触摸:', this.startX, this.startY);
  123. },
  124. touchMove(event) {
  125. let currentX = event.touches[0].pageX;
  126. let currentY = event.touches[0].pageY;
  127. let moveX = currentX - this.startX;
  128. let moveY = currentY - this.startY;
  129. let text = '';
  130. let state = 0; //-1:左滑,0:没滑动,1:右滑
  131. // //左右方向滑动
  132. if (Math.abs(moveX) > Math.abs(moveY)) {
  133. if (moveX < -10) {
  134. text = '左滑';
  135. state = 1;
  136. } else if (moveX > 10) {
  137. text = '右滑';
  138. state = -1;
  139. }
  140. } else {
  141. //上下方向滑动
  142. if (moveY < 0) {
  143. text = '上滑';
  144. state = -2;
  145. } else if (moveY > 0) {
  146. text = '下滑';
  147. state = 2;
  148. }
  149. }
  150. this.like_state = state;
  151. this.moveX = moveX;
  152. this.moveY = moveY;
  153. // console.log('开始滑动:', this.moveX, this.moveY, this.like_state);
  154. },
  155. touchEnd(event) {
  156. // console.log(`移动距离:${Math.abs(this.moveX)}`);
  157. // if (Math.abs(this.moveX) > 60 ) {
  158. // if (this.like_state == 1) {
  159. // this.itemIndex++;
  160. // this.flagIndex++;
  161. // this.isAutoSwitch = true;
  162. // } else if (this.like_state == -1) {
  163. // this.itemIndex--;
  164. // this.flagIndex--;
  165. // this.isAutoSwitch = false;
  166. // }
  167. // this.changIndex();
  168. // }
  169. if (Math.abs(this.moveY) > 60) {
  170. if (this.like_state == -2) {
  171. this.itemIndex++;
  172. this.flagIndex++;
  173. this.isAutoSwitch = true;
  174. } else if (this.like_state == 2) {
  175. this.itemIndex--;
  176. this.flagIndex--;
  177. this.isAutoSwitch = false;
  178. }
  179. this.changIndex();
  180. }
  181. },
  182. // 自动切换
  183. changeMaterial() {
  184. const _this = this;
  185. clearInterval(_this.timer);
  186. _this.timer = setInterval(() => {
  187. _this.duration -= 1;
  188. if (_this.duration == 0) {
  189. _this.itemIndex++;
  190. _this.flagIndex++;
  191. this.isAutoSwitch = true;
  192. this.changIndex();
  193. }
  194. }, 1000);
  195. },
  196. changIndex() {
  197. const _this = this;
  198. innerAudioContext.destroy();
  199. _this.linkUrl = '';
  200. console.log(this.itemLength)
  201. // 资源素材加载到最后一张时 - 下一页
  202. if (_this.itemIndex == this.show_materials.length) {
  203. // clearInterval(_this.timer);
  204. console.log('最后一页啦')
  205. this.itemIndex = 0;
  206. this.flagIndex = 0;
  207. this.contentIndex = 0;
  208. }
  209. // 资源加载到第一张时 - 上一页
  210. if (this.itemIndex == -1) {
  211. this.itemIndex = this.show_materials.length - 1;
  212. this.contentIndex = this.itemLength.length - 1;
  213. this.flagIndex = this.itemLength[this.contentIndex];
  214. }
  215. if (this.flagIndex == -1) {
  216. // if(this.contentIndex == -1){
  217. // this.contentIndex = this.itemLength.length - 1;
  218. // }
  219. // console.log('itemIndex',this.itemIndex)
  220. // console.log('flagIndex',this.flagIndex)
  221. // console.log('contentIndex',this.contentIndex)
  222. // console.log(this.materialsCont[this.contentIndex])
  223. this.contentIndex--;
  224. this.flagIndex = this.itemLength[this.contentIndex];
  225. }
  226. // 图片播放时间
  227. _this.duration = this.show_materials[this.itemIndex].duration;
  228. // 资源地址-图片/视频
  229. _this.linkUrl = this.show_materials[this.itemIndex].deposit_url;
  230. // 优先判断图片自带音频
  231. if (this.show_materials[this.itemIndex].bgm_url) {
  232. _this.audioSrc = this.show_materials[this.itemIndex].bgm_url;
  233. _this.audioName = this.show_materials[this.itemIndex].bgm_name;
  234. } else {
  235. // 不同发布节点
  236. if (this.contentIndex == this.itemLength.length) {
  237. this.flagIndex = 0;
  238. this.contentIndex = 0;
  239. } else {
  240. if (this.isAutoSwitch) {
  241. if (this.flagIndex == this.itemLength[this.contentIndex]) {
  242. this.flagIndex = 0;
  243. this.contentIndex++;
  244. if (this.contentIndex == this.itemLength.length || _this.itemIndex == this.show_materials.length) {
  245. this.contentIndex = this.itemLength.length-1;
  246. this.flagIndex = this.itemLength[this.contentIndex];
  247. }
  248. }
  249. }
  250. }
  251. // 图片无自带 - 再判断是否有BGM - main
  252. if (this.materialsCont[this.contentIndex].bgm_main) {
  253. this.audioSrc = this.materialsCont[this.contentIndex].bgm_main;
  254. this.audioName = this.materialsCont[this.contentIndex].bgm_name;
  255. }
  256. }
  257. // 当前资源是 - 视频 - 时,即销毁音频(防止干扰)
  258. if (this.show_materials[this.itemIndex].material_type == 1) {
  259. innerAudioContext.destroy()
  260. innerAudioContext.src = ''
  261. }
  262. // 销毁-创建音频-播放音频
  263. innerAudioContext = uni.createInnerAudioContext();
  264. this.playVoice(this.audioSrc);
  265. },
  266. // 视频
  267. videoPlayEnd() {
  268. console.log('end-video')
  269. this.itemIndex++;
  270. this.flagIndex++;
  271. this.changIndex();
  272. },
  273. auto() {
  274. setTimeout(()=>{
  275. this.autoplay = true;
  276. },500)
  277. },
  278. playEvent(e) {
  279. console.log("play_video")
  280. let currentId = e.target.id; // 获取当前视频id
  281. this.videoCtx = uni.createVideoContext(currentId);
  282. innerAudioContext.destroy()
  283. },
  284. loading(){
  285. console.log('play_loading')
  286. },
  287. waitingVideo(){
  288. console.log('waiting-video')
  289. this.videoCtx.pause()
  290. },
  291. timeupdateEvent(event) {
  292. console.log('timeupdateEvent')
  293. },
  294. // 禁止拖动进度条快进
  295. timeUpdate(e) {
  296. var isReady = 1; // 是否开启可以视频快进 1 禁止开启
  297. //跳转到指定播放位置 initial-time 时间为秒
  298. let that = this;
  299. //播放的总时长
  300. var duration = e.detail.duration;
  301. //实时播放进度 秒数
  302. var currentTime = parseInt(e.detail.currentTime);
  303. //当前视频进度
  304. // console.log("视频播放到第" + currentTime + "秒")//查看正在播放时间,以秒为单位
  305. if (that.video_real_time == 0) {
  306. var jump_time = parseInt(that.initial_time) + parseInt(that.video_real_time);
  307. } else {
  308. var jump_time = parseInt(that.video_real_time);
  309. }
  310. if (isReady == 1) {
  311. if (currentTime > jump_time && currentTime - jump_time > 3) {
  312. let videoContext = uni.createVideoContext(e.target.id);
  313. uni.showToast({
  314. title: '未完整看完该视频,不能快进',
  315. icon: 'none',
  316. duration: 2000
  317. });
  318. videoContext.stop()
  319. videoContext.seek(0);
  320. }
  321. }
  322. that.video_real_time = currentTime; //实时播放进度
  323. },
  324. // 音频
  325. playVoice(src) {
  326. if (innerAudioContext != undefined) {
  327. innerAudioContext.stop();
  328. }
  329. innerAudioContext = uni.createInnerAudioContext();
  330. innerAudioContext.stop();
  331. innerAudioContext.src = src;
  332. innerAudioContext.autoplay = true;
  333. innerAudioContext.loop = true;
  334. innerAudioContext.onPlay(() => {
  335. this.infoTxt = '音频开始播放';
  336. // console.log('开始播放');
  337. });
  338. innerAudioContext.onError(res => {
  339. if(this.show_materials[this.itemIndex].material_type != 1){
  340. console.log(res.errMsg);
  341. console.log(res.errCode);
  342. innerAudioContext.destroy();
  343. }
  344. // innerAudioContext.stop();
  345. });
  346. innerAudioContext.onPause(function() {
  347. console.log('onPause');
  348. });
  349. innerAudioContext.onStop(() => {
  350. this.infoTxt = '音频停止';
  351. // console.log('停止');
  352. });
  353. innerAudioContext.onEnded(() => {
  354. this.infoTxt = '音频自然播放结束事件';
  355. // console.log('音频自然播放结束事件');
  356. });
  357. },
  358. countdown() {
  359. this.count = 6;
  360. const timer = setInterval(() => {
  361. this.count -= 1;
  362. if (this.count < 1) {
  363. clearInterval(timer);
  364. this.deviceInfoShow = true;
  365. console.log('倒计时结束');
  366. }
  367. }, 1000);
  368. }
  369. }
  370. };
  371. </script>
  372. <style scoped>
  373. .main_container {
  374. position: relative;
  375. overflow: hidden;
  376. background: #000;
  377. }
  378. .show-item {
  379. display: flex;
  380. flex-direction: column;
  381. align-items: center;
  382. justify-content: center;
  383. }
  384. .show-item .show-img {
  385. width: 100%;
  386. height: 100vh;
  387. object-fit: cover;
  388. }
  389. .show-item uni-video {
  390. width: 100%;
  391. height: 100%;
  392. }
  393. .show-video {
  394. width: 100%;
  395. height: 100vh;
  396. }
  397. .show-audio {
  398. position: fixed;
  399. bottom: 79.16rpx;
  400. right: 46.52rpx;
  401. width: 159.72rpx;
  402. height: 152.08rpx;
  403. background: url(~@/static/images/an-yy.png) no-repeat;
  404. background-size: cover;
  405. }
  406. .show-audio uni-image {
  407. width: 159.72rpx;
  408. height: 152.08rpx;
  409. }
  410. .local-data {
  411. position: absolute;
  412. left: 50%;
  413. top: 50%;
  414. display: flex;
  415. flex-direction: column;
  416. justify-content: center;
  417. width: 625rpx;
  418. height: 555.55rpx;
  419. transform: translate(-50%, -50%);
  420. font-size: 27.77rpx;
  421. color: #333;
  422. border-radius: 27.77rpx;
  423. background: rgba(255, 255, 255, 0.85);
  424. }
  425. .title {
  426. margin-bottom: 32.63rpx;
  427. font-size: 56.94rpx;
  428. text-align: center;
  429. }
  430. .data-info {
  431. padding: 0 83.33rpx;
  432. margin-bottom: 32.63rpx;
  433. }
  434. .count-down {
  435. position: absolute;
  436. right: 34.72rpx;
  437. top: 27.77rpx;
  438. width: 48.61rpx;
  439. height: 48.61rpx;
  440. font-size: 30.55rpx;
  441. text-align: center;
  442. line-height: 48.61rpx;
  443. border: 1px solid #333;
  444. border-radius: 50%;
  445. }
  446. .swiper {
  447. height: 100vh;
  448. }
  449. .item {
  450. width: 100%;
  451. height: 100%;
  452. }
  453. .mask {
  454. position: absolute;
  455. top: 0;
  456. left: 0;
  457. bottom: 0;
  458. right: 0;
  459. width: 100%;
  460. height: 100%;
  461. background: rgba(0, 0, 0, 0.3);
  462. z-index: 999;
  463. }
  464. .controls-title {
  465. position: absolute;
  466. top: 0;
  467. left: 0;
  468. bottom: 0;
  469. right: 0;
  470. width: 100%;
  471. height: 100%;
  472. background: rgba(0, 0, 0, 0.3);
  473. text-align: center;
  474. color: #ffffff;
  475. border: 10px solid #fff;
  476. z-index: 9999;
  477. }
  478. </style>