videoPlay.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="body">
  3. <view class="top_bg">
  4. <topBox></topBox>
  5. <view @click="backBtn" class="back" tabindex="0">返回上一级</view>
  6. </view>
  7. <view class="vdo_box" tabindex="0">
  8. <video style="width: 80%; height: 70%" id="myVideo" :src="list.video" autoplay loop="true" controls @keydown="handleVideoKey" ref="tvVideo"></video>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. let that;
  14. export default {
  15. data() {
  16. return { list: [] };
  17. },
  18. onLoad(o) {
  19. console.log(o.id, '是朋友');
  20. that = this;
  21. this.getContentDetails(o);
  22. },
  23. methods: {
  24. // 详情
  25. getContentDetails(o) {
  26. this.$api.getContentDetails(
  27. {
  28. main_body_id: 1,
  29. id: o.id
  30. },
  31. function (res) {
  32. that.list = res.data;
  33. console.log(that.list, 'list');
  34. }
  35. );
  36. },
  37. handleVideoKey(e) {
  38. const video = this.$refs.tvVideo;
  39. switch (e.keyCode) {
  40. case 13: // OK键
  41. if (video.paused) {
  42. video.play();
  43. } else {
  44. video.pause();
  45. }
  46. break;
  47. case 37: // 左键 - 快退
  48. video.currentTime = Math.max(0, video.currentTime - 10);
  49. break;
  50. case 39: // 右键 - 快进
  51. video.currentTime = Math.min(video.duration, video.currentTime + 10);
  52. break;
  53. }
  54. },
  55. backBtn() {
  56. uni.navigateBack({
  57. delta: 1
  58. });
  59. }
  60. }
  61. };
  62. </script>
  63. <style>
  64. .body {
  65. width: 100%;
  66. height: 100vh;
  67. background: url('../../../static/img/image5.png') no-repeat center;
  68. background-size: 100% 100%;
  69. background-attachment: fixed;
  70. position: fixed;
  71. }
  72. /deep/.uni-video-container {
  73. background-color: transparent !important;
  74. }
  75. /deep/.uni-video-cover {
  76. background-color: transparent !important;
  77. }
  78. .vdo_box {
  79. width: 100%;
  80. height: 100%;
  81. margin-top: 12%;
  82. margin-left: 10%;
  83. }
  84. .top_bg {
  85. width: 100%;
  86. /* height: 300rpx; */
  87. position: absolute;
  88. /* font-size: 48rpx; */
  89. color: #ffffff;
  90. /* letter-spacing: 0.1em; */
  91. background: linear-gradient(10deg, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2) 100%);
  92. }
  93. .back {
  94. width: 15%;
  95. height: 5%;
  96. margin-left: 5%;
  97. margin-top: -2%;
  98. cursor: pointer;
  99. font-size: 12px;
  100. color: #ffffff;
  101. letter-spacing: 0.3em;
  102. }
  103. </style>