refactor(core): CORE-06 type media surfaces and playback hosts

This commit is contained in:
Harvey Zhao committed 2026-09-11 01:18:14 +08:00
1 parent 97d320bd74
commit ee859e4804
27 files changed
+2152 -79

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import type { PlayHost } from '../media/hosts'
import type { PlaybackMethods } from '../media/types'
import { def } from '../utils'
export default function playMix<Media extends Pick<PlaybackMethods, 'play'>>(art: PlayHost<Media>): asserts art is PlayHost<Media> & { play: () => Promise<Awaited<ReturnType<Media['play']>>> } {
const {
i18n,
notice,
option,
constructor: { instances },
template: { $video },
} = art
def(art, 'play', {
async value() {
const result = await $video.play()
notice.show = i18n.get('Play')
art.emit('play')
if (option.mutex) {
for (let index = 0; index < instances.length; index++) {
const instance = instances[index]!
if (instance !== art) {
instance.pause()
}
}
}
return result
},
})
}