Lifecycle hook

This commit is contained in:
ThatOneCalculator 2022-07-13 22:10:58 -07:00
parent 55e389ba61
commit 95005327a3
2 changed files with 13 additions and 7 deletions

View File

@ -39,8 +39,6 @@ const props = withDefaults(defineProps<{
}>(), {
});
new Vlitejs('#player');
const audioEl = $ref<HTMLAudioElement | null>();
let hide = $ref(true);
@ -49,7 +47,10 @@ function volumechange() {
}
onMounted(() => {
if (audioEl) audioEl.volume = ColdDeviceStorage.get('mediaVolume');
if (audioEl) {
audioEl.volume = ColdDeviceStorage.get('mediaVolume');
new Vlitejs('#player');
}
});
</script>

View File

@ -26,7 +26,7 @@
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { ref, onMounted } from 'vue';
import * as misskey from 'misskey-js';
import 'vlitejs/dist/vlite.css';
import Vlitejs from 'vlitejs';
@ -37,10 +37,15 @@ const props = defineProps<{
video: misskey.entities.DriveFile;
}>();
Vlitejs.registerPlugin('pip', VlitejsPip);
const videoEl = $ref<HTMLVideoElement | null>();
new Vlitejs('#player', {
plugins: ['pip'],
onMounted(() => {
if (videoEl) {
Vlitejs.registerPlugin('pip', VlitejsPip);
new Vlitejs('#player', {
plugins: ['pip'],
});
}
});
const hide = ref((defaultStore.state.nsfw === 'force') ? true : props.video.isSensitive && (defaultStore.state.nsfw !== 'ignore'));