import{_ as a,c as i,o as n,a7 as s,j as l}from"./chunks/framework.DXlgpajS.js";const y=JSON.parse('{"title":"Video Ads","description":"","frontmatter":{},"headers":[],"relativePath":"en/plugin/ads.md","filePath":"en/plugin/ads.md","lastUpdated":1700976201000}'),e={name:"en/plugin/ads.md"},p=s('

Video Ads ​

Demo ​

👉 View Full Demo

Installation ​

bash
npm install artplayer-plugin-ads
bash
yarn add artplayer-plugin-ads
bash
pnpm add artplayer-plugin-ads
html
<script src="path/to/artplayer-plugin-ads.js"></script>

CDN ​

bash
https://cdn.jsdelivr.net/npm/artplayer-plugin-ads/dist/artplayer-plugin-ads.js
bash
https://unpkg.com/artplayer-plugin-ads/dist/artplayer-plugin-ads.js

Usage ​

',8),t=l("div",{className:"run-code","data-libs":"./uncompiled/artplayer-plugin-ads/index.js"}," ▶ Run Code ",-1),h=s(`
js
var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
    autoSize: true,
    fullscreen: true,
    fullscreenWeb: true,
    plugins: [
        artplayerPluginAds({
            // HTML ad, ignored if it's a video ad
            html: '<img src="/assets/sample/poster.jpg">',

            // URL of the video ad
            video: '/assets/sample/test1.mp4',

            // Ad redirect URL, no redirection if empty
            url: 'http://artplayer.org',

            // The duration that must be watched, which can't be skipped, in seconds
            // If this value is greater than or equal to totalDuration, the ad can't be closed early
            // If this value is less than or equal to 0, then the ad can be closed at any time
            playDuration: 5,

            // Total duration of the ad, in seconds
            totalDuration: 10,

            // Whether the video ad is muted by default
            muted: false,

            // Multilingual support
            i18n: {
                close: 'Close ad',
                countdown: '%s seconds',
                detail: 'See details',
                canBeClosed: '%s seconds until the ad can be closed',
            },
        }),
    ],
});

// ad is clicked
art.on('artplayerPluginAds:click', (ads) => {
    console.info(ads);
});

// Ad skipped
art.on('artplayerPluginAds:skip', (ads) => {
    console.info(ads);
});
`,1),r=[p,t,h];function k(d,E,c,b,o,g){return n(),i("div",null,r)}const m=a(e,[["render",k]]);export{y as __pageData,m as default};