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

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