videoplay6.vue 988 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <div style="position:relative;">
  3. <video id="video-webrtc6" controls autoplay style="width:100%"></video>
  4. </div>
  5. </template>
  6. <script setup>
  7. import { ref,toRef,watch,defineProps } from 'vue'
  8. const props = defineProps({
  9. url: String
  10. });
  11. const refToWatch = toRef(props,'url')
  12. watch(refToWatch,(newVal,oldValue)=>{
  13. if (newVal !== oldValue && newVal !== ""){
  14. getScript()
  15. }
  16. })
  17. var player = ''
  18. const getScript = ()=>{
  19. var video = '';
  20. video = document.getElementById('video-webrtc6');
  21. player = new JSWebrtc.Player(props.url, { video: video, autoplay: true, onPlay: (obj) => { } });
  22. }
  23. const endde =()=>{
  24. player.destroy()
  25. }
  26. defineExpose({
  27. endde
  28. })
  29. </script>
  30. <style scoped>
  31. .video-js .vjs-progress-control.vjs-control {
  32. display: none;
  33. }
  34. .btn-zhuapai{
  35. position:absolute;
  36. top:15px;
  37. right:10px;
  38. background: rgba(255,255,255,0.5);
  39. width:44px;
  40. height:27px;
  41. text-align:center;
  42. line-height: 27px;
  43. font-size:14px;
  44. cursor:pointer;
  45. }
  46. </style>