refactor: Update VAST plugin in Artplayer

This commit is contained in:
Harvey Zack committed 2024-08-23 23:23:50 +08:00
1 parent f9192ff852
commit 87b0506f51
5 files changed
+32 -17

No files matched your search

+6 -5
View File
@@ -23,31 +23,32 @@ export default function artplayerPluginVast(callback) {
width: '100%',
height: '100%',
zIndex: '150',
display: 'none',
});
const player = new Player(ima, $video, $container, adsRenderingSettings, playerOptions);
const imaPlayer = new Player(ima, $video, $container, adsRenderingSettings, playerOptions);
function playUrl(url) {
const playAdsRequest = new ima.AdsRequest();
playAdsRequest.adTagUrl = url;
player.playAds(playAdsRequest);
imaPlayer.playAds(playAdsRequest);
}
function playRes(res) {
const playAdsRequest = new ima.AdsRequest();
playAdsRequest.adsResponse = res;
player.playAds(playAdsRequest);
imaPlayer.playAds(playAdsRequest);
}
if (typeof callback === 'function') {
await callback({ art, id, ima, player, $container, playUrl, playRes });
await callback({ art, id, ima, imaPlayer, $container, playUrl, playRes });
}
return {
name: 'artplayerPluginVast',
id,
ima,
player,
imaPlayer,
$container,
};
};
@@ -3,9 +3,15 @@ import type Artplayer from 'artplayer';
export = artplayerPluginVast;
export as namespace artplayerPluginVast;
type Option = {
//
};
type Option = (params: {
art: Artplayer;
id: string;
ima: any;
imaPlayer: any;
$container: HTMLDivElement;
playUrl: (url: string) => void;
playRes: (res: string) => void;
}) => void;
type Result = {
name: 'artplayerPluginVast';