{"version":3,"file":"previewResource.a5d47997.mjs","sources":["../../../../components/previewResource.vue"],"sourcesContent":["<template>\n  <el-dialog :model-value=\"modelValue\" custom-class=\"preview_dialog\" title=\"\" :before-close=\"handleClose\" :width=\"900\" :append-to-body=\"true\" :close-on-click-modal=\"false\">\n    <div class=\"video_body_content\" v-loading=\"ctrl.loading\">\n      <div id=\"resource_player\" ref=\"videoBox\" class=\"video_win\" />\n    </div>\n  </el-dialog>\n</template>\n\n<script>\nimport { reactive, ref, toRefs} from 'vue';\nimport {materialPreView} from '@/api/paper.js';\nexport default defineComponent({\n  name: 'Preview',\n  props: {\n    modelValue: {\n      type: Boolean,\n      default: false\n    },\n    id: {\n      type: String,\n      default: ''\n    }\n  },\n  setup(props, {emit}) {\n    const {id, modelValue} = toRefs(props)\n    const videoBox = ref(null)\n    const opts = reactive({\n      imageList: []\n    })\n    const map = reactive({\n      resource_player: null,\n      vodPlatform: 2,\n      userInfo: {}\n    })\n    const ctrl = reactive({\n      loading: false\n    })\n    const handleClose = () => {\n      if(map.resource_player)\n      if (map.vodPlatform === 2) {\n        map.resource_player.destroy()\n        map.resource_player = null\n      } else if (map.vodPlatform === 3) {\n        map.resource_player.destroy()\n        map.resource_player = null\n      }\n      emit('close')\n    }\n    const getView = () => {\n      ctrl.loading = true\n      materialPreView({id: id.value}).then(res => {\n        map.vodPlatform = res.vodPlatform\n        if (res.vodPlatform === 2) {\n          play(res)\n        } else if (res.vodPlatform === 3) {\n          baiJiaYunPlay(res)\n        }\n        ctrl.loading = false\n      })\n    }\n    const baiJiaYunPlay = (data) => {\n      const _that = map\n      const box = videoBox.value\n      document.querySelector('#resource_player').innerHTML = '';\n      _that.resource_player = new BPlayer({\n        container: document.querySelector('#resource_player'),\n        width: box.offsetWidth,\n        height: 500,\n        token: data.token,\n        autoplay: false,\n        vid: data.vid,\n        playbackRates: [],\n        showCurrentTimeDisplay: true,\n        showDurationDisplay: true,\n        disableSeek: 0, // 是否禁止拖拽， 0：可以， 1：禁止\n        user_name: _that.userInfo.userName, // 用户名， 主要用于数据统计\n        user_number: _that.userInfo.userNo, // 用户id， 主要用于数据统计\n      })\n      setTimeout(()=>{\n        _that.resource_player.play()\n      },500)\n\n    }\n    const play = (data, startTime = 0) => {\n      window.s2j_onVideoPlay = () => {\n      }\n      window.s2j_onFullScreen = () => {\n      }\n      window.s2j_onNormalScreen = () => {\n      }\n      window.s2j_onPlayOver = () => {\n      }\n      window.s2j_onVideoPause = () => {\n      }\n      const box = videoBox['value']\n      if (!box) {\n        play(data, startTime)\n        return\n      }\n\n      window.s2j_onPlayerInitOver = () => {\n      }\n      if (map.resource_player) {\n        map.resource_player.changeVid({\n          vid: data.vid,\n          playsafe: data.token,\n          watchStartTime: startTime || 0,\n          ts: data.ts,\n          sign: data.sign,\n          width: box.offsetWidth,\n          height: 500,\n          autoplay: false\n        })\n      } else {\n        document.querySelector('#resource_player').innerHTML = '';\n        map.resource_player = window.polyvPlayer({\n          wrap: '#resource_player',\n          width: box.offsetWidth,\n          height: 500,\n          history_video_duration: 2,\n          forceH5: true,\n          hideSwitchPlayer: true,\n          code: data.code,\n          autoplay: false,\n          speed: true,\n          playsafe: data.token,\n          watchStartTime: startTime,\n          ts: data.ts,\n          sign: data.sign,\n          vid: data.vid,\n          viewerInfo: {\n            viewerId: map.userInfo.userNo,\n            viewerName: map.userInfo.userName\n          }\n        })\n      }\n    }\n    if(modelValue.value) {\n      if(id.value) {\n        getView()\n      }\n    }\n    return {\n      opts,\n      ctrl,\n      modelValue,\n      videoBox,\n      handleClose\n    }\n  }\n})\n</script>\n<style lang=\"scss\">\n.preview_dialog {\n  .el-dialog__footer {\n    padding: 0;\n  }\n}\n</style>\n<style scoped>\n.video_body_content{\n  position: relative;\n  min-height: 500px;\n}\n.video_win {\n  height: 500px;\n}\n</style>\n"],"names":["_sfc_main","defineComponent","name","props","id","default","setup","emit","modelValue","toRefs","opts","reactive","map","resource_player","ctrl","_that","BPlayer","width","box","offsetWidth","token","data","autoplay","playbackRates","disableSeek","setTimeout","play","startTime","window","s2j_onNormalScreen","s2j_onPlayerInitOver","changeVid","playsafe","sign","polyvPlayer","hideSwitchPlayer","code","viewerName","userInfo","userName","value","loading","materialPreView","then","res","vodPlatform","baiJiaYunPlay","videoBox","_hoisted_1","class","ref","_ctx","title","handleClose","_withDirectives","_openBlock","_createElementBlock","_createElementVNode","_hoisted_2","_directive_loading"],"mappings":"kIAWAA,EAAAC,EAAA,CACEC,KAAA,UACAC,MAAA,sCAKEC,GAAA,aAEEC,QAAA,KAGJC,MAAAH,GAAAI,KAAAA,IACE,MAAAH,GAAAA,EAAAI,WAAAA,GAAAC,EAAAN,aAEAO,EAAAC,EAAA,gBAGAC,EAAAD,EAAA,CACEE,gBAAA,iCAIFC,EAAAH,EAAA,gGA8BEI,EAAAF,gBAAA,IAAAG,QAAA,sDAEEC,MAAAC,EAAAC,uBAEAC,MAAAC,EAAAD,MACAE,UAAA,YAEAC,cAAA,oDAGAC,YAAA,gEAIFC,YAAA,sCAKFC,EAAA,CAAAL,EAAAM,EAAA,kEAKEC,OAAAC,mBAAA,mFAOAX,GAKAU,OAAAE,qBAAA,yBAGElB,EAAAC,gBAAAkB,UAAA,WAEEC,SAAAX,EAAAD,kCAGAa,KAAAZ,EAAAY,KACAhB,MAAAC,EAAAC,8FAMFP,EAAAC,gBAAAe,OAAAM,YAAA,yBAEEjB,MAAAC,EAAAC,2DAIAgB,kBAAA,EACAC,KAAAf,EAAAe,KACAd,UAAA,WAEAU,SAAAX,EAAAD,+BAGAa,KAAAZ,EAAAY,sDAIEI,WAAAzB,EAAA0B,SAAAC,cApCJb,EAAAL,EAAAM,EAuCF,EAOF,OALAnB,EAAAgC,iBAxFE1B,EAAA2B,SAAA,EACAC,EAAA,CAAAtC,GAAAA,EAAAoC,QAAAG,MAAAC,IACEhC,EAAAiC,YAAAD,EAAAC,8BAEEnB,EAAAkB,sBAEAE,EAAAF,GAEF9B,EAAA2B,SAAA,CAAA,KAqFJ,4BAIEM,uBA7GF,iIAgHF,IAnJOC,EAAA,CAAAC,MAAA,yBACE7C,GAAA,kBAAqB8C,IAAA,WAAeD,MAAA,gHAFjC,cAAAE,EAAA3C,WAAyB,eAAA,iBAA8B4C,MAAA,GAAU,eAAAD,EAAAE,YAA4BpC,MAAA,IAAa,kBAAA,EAAuB,wBAAA,oBAC3IqC,GAAAC,IAAAC,EAAA,MAAAR,EAAA,CACES,EAAA,MAAAC,EAAA,KAAA,SADyC,CAAAC,EAAAR,EAAArC,KAAA2B"}