feat(vap播放组件): 修复苹果端走原生video播放的问题
This commit is contained in:
parent
81d3307899
commit
500cce3d15
@ -93,10 +93,47 @@ const errorMessage = ref('')
|
||||
let player = null
|
||||
let playToken = 0
|
||||
let cleanupPlayerVideoGuards = null
|
||||
let vapInlinePlaybackPatched = false
|
||||
|
||||
const teleportToBody = computed(() => props.mode === 'overlay')
|
||||
const resolvedSrc = computed(() => resolveProtectedAssetUrl(props.src))
|
||||
|
||||
function patchVapInlinePlayback() {
|
||||
if (vapInlinePlaybackPatched) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const probePlayer = new Vap()
|
||||
const proto = Object.getPrototypeOf(probePlayer)
|
||||
|
||||
if (!proto || typeof proto.initVideo !== 'function') {
|
||||
return
|
||||
}
|
||||
|
||||
if (proto.__likeiInlinePlaybackPatched) {
|
||||
vapInlinePlaybackPatched = true
|
||||
return
|
||||
}
|
||||
|
||||
const originalInitVideo = proto.initVideo
|
||||
proto.initVideo = function patchedInitVideo(...args) {
|
||||
const result = originalInitVideo.apply(this, args)
|
||||
enforceVideoPlaybackAttributes(this?.video, this?.options?.mute)
|
||||
return result
|
||||
}
|
||||
|
||||
proto.__likeiInlinePlaybackPatched = true
|
||||
vapInlinePlaybackPatched = true
|
||||
|
||||
if (typeof probePlayer.destroy === 'function') {
|
||||
probePlayer.destroy()
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Failed to patch VAP inline playback hooks:', error)
|
||||
}
|
||||
}
|
||||
|
||||
function enforceVideoPlaybackAttributes(video, shouldMute) {
|
||||
if (!video) {
|
||||
return
|
||||
@ -238,6 +275,7 @@ async function startPlay() {
|
||||
|
||||
try {
|
||||
await nextTick()
|
||||
patchVapInlinePlayback()
|
||||
|
||||
if (!containerRef.value || currentToken !== playToken) {
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user