CameraModal.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <uni-popup ref="cameraPopup" type="center">
  3. <view class="video-container">
  4. <view class="title">
  5. <uni-section type="line" :title="title">
  6. <template v-slot:right>
  7. <uni-icons type="closeempty" size="24" color="#999" @click="close"></uni-icons>
  8. </template>
  9. </uni-section>
  10. </view>
  11. <live-player
  12. :src="videoSrc"
  13. class="video"
  14. autoplay
  15. @statechange="statechange"
  16. @error="error"
  17. style="width: 100%; height: 225px;"
  18. />
  19. </view>
  20. </uni-popup>
  21. </template>
  22. <script>
  23. export default {
  24. name:"CameraModal",
  25. data() {
  26. return {
  27. title:"",
  28. videoSrc:""
  29. };
  30. },
  31. methods:{
  32. show({title,src}){
  33. this.videoSrc=src
  34. this.title=title;
  35. this.$refs.cameraPopup.open('center')
  36. },
  37. close(){
  38. this.videoSrc=""
  39. this.title="";
  40. this.$refs.cameraPopup.close()
  41. },
  42. statechange(e){
  43. console.log('live-player code:', e.detail.code)
  44. },
  45. error(e){
  46. console.error('live-player error:', e.detail.errMsg)
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. .video-container{
  53. width: 750rpx;
  54. height: 100vh;
  55. display: flex;
  56. // justify-content: center;
  57. align-items: center;
  58. flex-direction: column;
  59. background-color: #fff;
  60. .title{
  61. width: 100%;
  62. height: 10vh;
  63. }
  64. .video{
  65. display: block;
  66. width: 100%;
  67. }
  68. }
  69. </style>