|
@@ -11,10 +11,10 @@ export const Component = defineComponent({
|
|
|
compId: string().isRequired,
|
|
|
},
|
|
|
setup(props) {
|
|
|
- const { store, controls, actions } = useEditor();
|
|
|
+ const { store, controls, actions, helper } = useEditor();
|
|
|
const comp = useCompData(props.compId);
|
|
|
const { value } = comp;
|
|
|
- const videoRef = ref();
|
|
|
+ const videoRef = ref<HTMLVideoElement>();
|
|
|
|
|
|
async function changeVal() {
|
|
|
try {
|
|
@@ -26,17 +26,30 @@ export const Component = defineComponent({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function updateSize() {
|
|
|
+ const { videoWidth, videoHeight } = videoRef.value as HTMLVideoElement;
|
|
|
+ if (videoHeight == 0 || videoWidth == 0) return;
|
|
|
+ const t = value.ratio || videoWidth * 1.0 / videoHeight;
|
|
|
+ comp.setH(comp.getW() / t);
|
|
|
+ actions.onCompLayoutUpdated(comp);
|
|
|
+ helper.extendStreamCard( store.currStreamCardId );
|
|
|
+ }
|
|
|
+
|
|
|
watch(
|
|
|
() => [value.ratio],
|
|
|
() => {
|
|
|
- const { videoWidth, videoHeight } = videoRef.value;
|
|
|
- const t = value.ratio || videoWidth / videoHeight;
|
|
|
- comp.setH(comp.getW() / t);
|
|
|
- actions.onCompLayoutUpdated(comp);
|
|
|
+ updateSize();
|
|
|
}
|
|
|
);
|
|
|
onMounted(() => {
|
|
|
- videoRef.value.addEventListener("play", () => {
|
|
|
+ const el = videoRef.value as HTMLVideoElement;
|
|
|
+ el.addEventListener("loadedmetadata", ()=>{
|
|
|
+ if (value.ratio == 0 && comp.layout.size[0] / comp.layout.size[1] != value.ratio) {
|
|
|
+ updateSize();
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ el.addEventListener("play", () => {
|
|
|
controls.mediaCtrl.pauseOtherMedia(props.compId);
|
|
|
});
|
|
|
controls.mediaCtrl.setMediasInstance(props.compId, videoRef.value);
|