vue-files-preview
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
43 lines (42 loc) • 1.21 kB
JavaScript
import { defineComponent as r, ref as u, watch as i, shallowRef as d, onMounted as c, onBeforeUnmount as s, openBlock as v, createElementBlock as f, createElementVNode as m } from "vue";
import { getFileRenderByFile as p } from "../../utils/utils.mjs";
const R = { class: "video-preview web-full-screen" }, h = /* @__PURE__ */ r({
__name: "index",
props: {
file: { default: () => null },
url: { default: () => null },
name: {}
},
setup(n) {
const t = n, e = u(null);
i(
() => t.file,
(o) => {
o && (e.value && URL.revokeObjectURL(e.value), p(o).then((a) => {
e.value = a, l.value.src = e.value;
}));
},
{ immediate: !0 }
);
const l = d(null);
return c(() => {
l.value.addEventListener("loadedmetadata", () => {
l.value.play();
});
}), s(() => {
l.value.pause(), t.file && URL.revokeObjectURL(e.value);
}), (o, a) => (v(), f("div", R, [
m("video", {
ref_key: "videoPreviewRef",
ref: l,
class: "player-video-main",
controls: "",
autoplay: ""
}, null, 512)
]));
}
});
export {
h as default
};
//# sourceMappingURL=index.vue2.mjs.map