mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-11 13:56:15 -08:00
feat: update version to 1.0.2 and enhance ad event handling in VAST plugin
This commit is contained in:
1 parent
eccea444b0
commit
68b40de93c
2 files changed
+17
-14
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "artplayer-plugin-vast",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "VAST plugin for ArtPlayer",
|
||||
"author": "Harvey Zack <laozhaochaguan@gmail.com>",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -37,35 +37,38 @@ export default function artplayerPluginVast(callback) {
|
||||
}
|
||||
|
||||
function initPlayer() {
|
||||
if (imaPlayer)
|
||||
return imaPlayer
|
||||
|
||||
$container = createContainer()
|
||||
$player.appendChild($container)
|
||||
|
||||
imaPlayer = new Player(ima, $video, $container, adsRenderingSettings, playerOptions)
|
||||
|
||||
// ✅ 事件绑定
|
||||
imaPlayer.onAdStarted = () => {
|
||||
imaPlayer.addEventListener('AdStarted', () => {
|
||||
isAdPlaying = true
|
||||
$container.style.display = 'block'
|
||||
art.pause()
|
||||
}
|
||||
})
|
||||
|
||||
imaPlayer.onAdEnd = () => {
|
||||
imaPlayer.addEventListener('AdComplete', () => {
|
||||
isAdPlaying = false
|
||||
$container.style.display = 'none'
|
||||
art.play()
|
||||
}
|
||||
})
|
||||
|
||||
imaPlayer.onAdError = (error) => {
|
||||
console.error('VAST Ad Error:', error)
|
||||
imaPlayer.addEventListener('AdError', (event) => {
|
||||
console.error('VAST Ad Error:', event.detail)
|
||||
isAdPlaying = false
|
||||
$container.style.display = 'none'
|
||||
art.play()
|
||||
}
|
||||
})
|
||||
|
||||
return imaPlayer
|
||||
}
|
||||
|
||||
function destroyPlayer() {
|
||||
if ($container && $container.parentNode) {
|
||||
if (imaPlayer?.destroy)
|
||||
imaPlayer.destroy()
|
||||
if ($container?.parentNode)
|
||||
$container.parentNode.removeChild($container)
|
||||
}
|
||||
$container = null
|
||||
imaPlayer = null
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user