mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 18:41:20 -08:00
update vue template
This commit is contained in:
1 parent
0c0bcecb9e
commit
4b55b97e9e
91 files changed
+228
-1701
No files matched your search
@@ -0,0 +1,24 @@
|
||||
<script setup>
|
||||
import { reactive } from 'vue'
|
||||
import Artplayer from './Artplayer.vue'
|
||||
|
||||
const option = reactive({
|
||||
url: 'https://artplayer.org/assets/sample/video.mp4',
|
||||
autoSize: true,
|
||||
})
|
||||
|
||||
const style = reactive({
|
||||
width: '600px',
|
||||
height: '400px',
|
||||
margin: '60px auto 0',
|
||||
})
|
||||
|
||||
function getInstance(art) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(art)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Artplayer :option="option" :style="style" @get-instance="getInstance" />
|
||||
</template>
|
||||
@@ -0,0 +1,53 @@
|
||||
<script setup>
|
||||
import Artplayer from 'artplayer'
|
||||
|
||||
// test i18n
|
||||
import fr from 'artplayer/i18n/fr'
|
||||
import id from 'artplayer/i18n/id'
|
||||
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref, shallowRef } from 'vue'
|
||||
|
||||
// test plugins
|
||||
import artplayerPluginDanmuku from '../../../artplayer-plugin-danmuku'
|
||||
import artplayerPluginDocumentPip from '../../../artplayer-plugin-document-pip'
|
||||
|
||||
const props = defineProps({
|
||||
option: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['getInstance'])
|
||||
|
||||
const art = shallowRef(null)
|
||||
const $container = ref(null)
|
||||
|
||||
onMounted(() => {
|
||||
art.value = new Artplayer({
|
||||
...props.option,
|
||||
container: $container.value,
|
||||
i18n: { id, fr },
|
||||
lang: 'fr',
|
||||
plugins: [
|
||||
artplayerPluginDocumentPip(),
|
||||
artplayerPluginDanmuku({
|
||||
danmuku: 'https://artplayer.org/assets/sample/danmuku.xml',
|
||||
}),
|
||||
],
|
||||
})
|
||||
nextTick(() => {
|
||||
emit('getInstance', art.value)
|
||||
})
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (art.value) {
|
||||
art.value.destroy(false)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div ref="$container" />
|
||||
</template>
|
||||
@@ -0,0 +1,4 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
|
||||
createApp(App).mount('#app')
|
||||
Reference in new issue
Block a user