vue-files-preview
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
3 lines (2 loc) • 826 B
JavaScript
;const e=require("vue"),u=require("../../utils/utils.js"),i={class:"video-preview web-full-screen"},s=e.defineComponent({__name:"index",props:{file:{default:()=>null},url:{default:()=>null},name:{}},setup(r){const o=r,l=e.ref(null);e.watch(()=>o.file,n=>{n&&(l.value&&URL.revokeObjectURL(l.value),u.getFileRenderByFile(n).then(a=>{l.value=a,t.value.src=l.value}))},{immediate:!0});const t=e.shallowRef(null);return e.onMounted(()=>{t.value.addEventListener("loadedmetadata",()=>{t.value.play()})}),e.onBeforeUnmount(()=>{t.value.pause(),o.file&&URL.revokeObjectURL(l.value)}),(n,a)=>(e.openBlock(),e.createElementBlock("div",i,[e.createElementVNode("video",{ref_key:"videoPreviewRef",ref:t,class:"player-video-main",controls:"",autoplay:""},null,512)]))}});module.exports=s;
//# sourceMappingURL=index.vue2.js.map