video.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view>
  3. <video v-if="url != ''" style="width: 100%; height: 100vh;" :src="url" autoplay codec="software" :play-strategy="1" :show-fullscreen-btn="true" @play="play" @pause="pause"></video>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. link:"",
  11. url: "",
  12. play_time_1: 0,
  13. play_time_2: 0
  14. };
  15. },
  16. onLoad() {
  17. // #ifndef APP-NVUE
  18. const eventChannel = this.getOpenerEventChannel();
  19. // #endif
  20. // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
  21. eventChannel.on('acceptDataFromOpenerPage', (data) => {
  22. console.log(data)
  23. uni.setNavigationBarTitle({
  24. title: data.title
  25. })
  26. this.link = data.url
  27. this.url = data.url
  28. })
  29. },
  30. methods: {
  31. play() {
  32. console.log('play:'+this.play_time_1,this.play_time_2)
  33. let time = this.play_time_1 - this.play_time_2
  34. setTimeout(() => {
  35. this.play_time_1 += 10
  36. console.log(this.play_time_1)
  37. }, 5000)
  38. if (time > 5) {
  39. this.url = ""
  40. this.play_time_2 = this.play_time_1
  41. setTimeout(()=>{
  42. this.url = this.link
  43. },10)
  44. return
  45. }
  46. },
  47. pause(){
  48. console.log('pause:暂停')
  49. }
  50. }
  51. }
  52. </script>
  53. <style lang="scss">
  54. </style>