mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 17:01:20 -08:00
feat: update version to 1.1.0 and enhance VAST plugin with new event handling and configuration options
This commit is contained in:
1 parent
4a980971f7
commit
486231f04b
3 files changed
+31
-12
No files matched your search
@@ -45,16 +45,21 @@ export default function artplayerPluginVast(callback) {
|
||||
|
||||
imaPlayer = new Player(ima, $video, $container, adsRenderingSettings, playerOptions)
|
||||
|
||||
imaPlayer.addEventListener('AdStarted', () => {
|
||||
imaPlayer.addEventListener('AdContentPauseRequested', () => {
|
||||
isAdPlaying = true
|
||||
$container.style.display = 'block'
|
||||
})
|
||||
|
||||
imaPlayer.addEventListener('AdComplete', () => {
|
||||
imaPlayer.addEventListener('AdContentResumeRequested', () => {
|
||||
isAdPlaying = false
|
||||
$container.style.display = 'none'
|
||||
})
|
||||
|
||||
imaPlayer.addEventListener('AdStarted', () => {
|
||||
isAdPlaying = true
|
||||
$container.style.display = 'block'
|
||||
})
|
||||
|
||||
imaPlayer.addEventListener('AdError', (event) => {
|
||||
console.error('VAST Ad Error:', event.detail)
|
||||
isAdPlaying = false
|
||||
@@ -73,23 +78,29 @@ export default function artplayerPluginVast(callback) {
|
||||
imaPlayer = null
|
||||
}
|
||||
|
||||
function playUrl(url) {
|
||||
function playUrl(url, config = {}) {
|
||||
if (isAdPlaying)
|
||||
return
|
||||
if (!imaPlayer)
|
||||
initPlayer()
|
||||
const request = new ima.AdsRequest()
|
||||
request.adTagUrl = url
|
||||
for (const key in config) {
|
||||
request[key] = config[key]
|
||||
}
|
||||
imaPlayer.playAds(request)
|
||||
}
|
||||
|
||||
function playRes(res) {
|
||||
function playRes(res, config = {}) {
|
||||
if (isAdPlaying)
|
||||
return
|
||||
if (!imaPlayer)
|
||||
initPlayer()
|
||||
const request = new ima.AdsRequest()
|
||||
request.adsResponse = res
|
||||
for (const key in config) {
|
||||
request[key] = config[key]
|
||||
}
|
||||
imaPlayer.playAds(request)
|
||||
}
|
||||
|
||||
@@ -98,8 +109,13 @@ export default function artplayerPluginVast(callback) {
|
||||
art,
|
||||
playUrl,
|
||||
playRes,
|
||||
init: initPlayer,
|
||||
ima,
|
||||
imaPlayer,
|
||||
adsRenderingSettings,
|
||||
playerOptions,
|
||||
get imaPlayer() {
|
||||
return imaPlayer
|
||||
},
|
||||
get container() {
|
||||
return $container
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user