mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 17:51:20 -08:00
refactor(core): CORE-09 isolate source operations and settle cancelled switches
This commit is contained in:
1 parent
874dac9f22
commit
44f4e083a9
29 files changed
+4512
-255
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import type { PlayHost } from '../media/hosts'
|
||||
import type { PlaybackMethods } from '../media/types'
|
||||
import { captureSource } from '../source/operation'
|
||||
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']>>> } {
|
||||
@@ -13,12 +14,22 @@ export default function playMix<Media extends Pick<PlaybackMethods, 'play'>>(art
|
||||
|
||||
def(art, 'play', {
|
||||
async value() {
|
||||
const active = captureSource(art)
|
||||
const result = await $video.play()
|
||||
notice.show = i18n.get('Play')
|
||||
if (!active())
|
||||
return result
|
||||
const message = i18n.get('Play')
|
||||
if (!active())
|
||||
return result
|
||||
notice.show = message
|
||||
if (!active())
|
||||
return result
|
||||
art.emit('play')
|
||||
|
||||
if (option.mutex) {
|
||||
for (let index = 0; index < instances.length; index++) {
|
||||
if (!active())
|
||||
break
|
||||
const instance = instances[index]!
|
||||
if (instance !== art) {
|
||||
instance.pause()
|
||||
|
||||
Reference in new issue
Block a user