Video Ads Video ads are video-based ads that deliver high engagement and visual impact. The AdStage SDK uses an HTML5 video player and supports mobile optimization and a variety of playback options.
// HTML์ ์ปจํ
์ด๋ ์ค๋น
// <div id="video-container"></div>
// SDK ์ด๊ธฐํ (ํ ๋ฒ๋ง)
AdStage. init ({
apiKey: process.env. NEXT_PUBLIC_ADSTAGE_API_KEY
});
// ๊ธฐ๋ณธ ๋น๋์ค ๊ด๊ณ ์์ฑ
AdStage.ads. video ( 'video-container' , {
width: 640 ,
height: 360
});
AdStage.ads. video ( 'video-container' , {
width: 640 ,
height: 360 ,
onClick : ( adData ) => {
console. log ( '๋น๋์ค ๊ด๊ณ ํด๋ฆญ๋จ:' , adData);
// ์ฌ์ฉ์ ์ ์ ๋ก์ง ์ถ๊ฐ ๊ฐ๋ฅ
}
});
Option Type Default Description widthnumber640Video width (px) heightnumber360Video height (px) autoplaybooleantrueWhether to autoplay mutedbooleantrueWhether to mute controlsbooleanfalseShow default controls onClickfunctionundefinedCallback function executed on click
Option Type Default Description loopbooleantrueWhether to loop playback playsinlinebooleantrueInline playback (mobile) customControlsobjectundefinedDetailed control settings
Option Type Default Description adIdstringundefinedSpecify a particular ad ID language'ko' | 'en' | 'ja' | 'zh'undefinedFilter by language deviceType'MOBILE' | 'DESKTOP'undefinedFilter by device country'KR' | 'US' | 'JP' | 'CN' | 'DE'undefinedFilter by country
Note : Video ads are designed to be optimized for a single video (maxAds: 1).
HTML (CDN) JavaScript (ES6) React Next.js App Next.js Provider
The simplest CDN approach lets you use it directly in HTML.
<! DOCTYPE html >
< html >
< head >
< meta charset = "UTF-8" >
< title >๋น๋์ค ๊ด๊ณ ์์ </ title >
</ head >
< body >
< h1 >๋ด ์น์ฌ์ดํธ</ h1 >
<!-- ๋น๋์ค ๊ด๊ณ ์ปจํ
์ด๋ -->
< div id = "video-container" style = "width: 640px; height: 360px; margin: 20px auto; border: 1px solid #ddd; border-radius: 8px;" >
๋ก๋ฉ ์ค...
</ div >
<!-- AdStage SDK ๋ก๋ -->
< script src = "https://unpkg.com/@adstage/web-sdk/dist/index.umd.js" ></ script >
< script >
// SDK ์ด๊ธฐํ
AdStage. init ({
apiKey: 'your-api-key'
});
// ๋น๋์ค ๊ด๊ณ ์์ฑ
AdStage.ads. video ( 'video-container' , {
width: 640 ,
height: 360 ,
autoplay: true ,
muted: true
});
</ script >
</ body >
</ html >
You can finely configure the individual controls of the video player.
AdStage.ads. video ( 'video-container' , {
width: 640 ,
height: 360 ,
controls: true ,
customControls: {
hidePlayButton: false , // ์ฌ์ ๋ฒํผ ํ์
hideProgressBar: false , // ์งํ๋ฐ ํ์
hideVolumeSlider: false , // ๋ณผ๋ฅจ ์ฌ๋ผ์ด๋ ํ์
hideFullscreenButton: true // ์ ์ฒดํ๋ฉด ๋ฒํผ ์จ๊น
}
});
How to adjust the video size according to the screen size.
// ๋ฏธ๋์ด ์ฟผ๋ฆฌ๋ฅผ ํ์ฉํ ๋ฐ์ํ ๊ตฌํ
const getResponsiveVideoSize = () => {
if (window.innerWidth <= 768 ) {
return { width: '100%' , height: 200 }; // ๋ชจ๋ฐ์ผ
} else if (window.innerWidth <= 1024 ) {
return { width: 640 , height: 300 }; // ํ๋ธ๋ฆฟ
} else {
return { width: 640 , height: 360 }; // ๋ฐ์คํฌํฑ
}
};
const { width , height } = getResponsiveVideoSize ();
AdStage.ads. video ( 'video-container' , {
width,
height,
autoplay: true ,
muted: true ,
deviceType: window.innerWidth <= 768 ? 'MOBILE' : 'DESKTOP'
});
// ์๋์ฐ ๋ฆฌ์ฌ์ด์ฆ ์ ์ฌ์์ฑ
window. addEventListener ( 'resize' , () => {
// ๊ธฐ์กด ๊ด๊ณ ์ ๊ฑฐ ํ ์๋ก ์์ฑ
AdStage.ads. destroy (slotId);
const newSize = getResponsiveVideoSize ();
slotId = AdStage.ads. video ( 'video-container' , {
... newSize,
autoplay: true ,
muted: true
});
});
Use this when you want to display only a specific video ad.
AdStage.ads. video ( 'video-container' , {
width: 640 ,
height: 360 ,
adId: 'video-ad-789' // ํน์ ๊ด๊ณ ID
});
The SDK automatically optimizes the container to fit the video size.
// 16:9 ๋น์จ ์๋ ์ ์ง
AdStage.ads. video ( 'video-container' , {
width: '100%' ,
height: 'auto' // ๋น์จ์ ๋ง์ถฐ ์๋ ์กฐ์
});
Ads load in the background, so you can receive a slot ID immediately.
// ์ฆ์ ์ฌ๋กฏ ID ๋ฐํ
const slotId = AdStage.ads. video ( 'video-container' );
console. log ( '์ฌ๋กฏ ์์ฑ๋จ:' , slotId); // ์ฆ์ ์คํ
// ์ค์ ๊ด๊ณ ๋ ๋น๋๊ธฐ๋ก ๋ก๋๋จ
When the container is removed from the DOM, the ad is automatically cleaned up as well.
const slotId = AdStage.ads. video ( 'video-container' );
// DOM์์ ์ปจํ
์ด๋ ์ ๊ฑฐ ์ ์๋ ์ ๋ฆฌ๋จ
document. getElementById ( 'video-container' ). remove ();
// ์๋์ผ๋ก destroy() ํธ์ถํ ํ์ ์์
You can apply styles using the CSS classes that the SDK adds automatically.
/* ๊ด๊ณ ์ปจํ
์ด๋ ๊ธฐ๋ณธ ์คํ์ผ */
.adstage-video-ad {
position : relative ;
overflow : hidden ;
border-radius : 8 px ;
background : #000 ;
}
/* ๋ก๋ฉ ์ํ */
.adstage-loading {
opacity : 0.7 ;
background : linear-gradient ( 90 deg , #000 25 % , #333 50 % , #000 75 % );
background-size : 200 % 100 % ;
animation : loading 1.5 s infinite ;
}
@keyframes loading {
0% { background-position : 200 % 0 ; }
100% { background-position : -200 % 0 ; }
}
/* ๋ก๋ฉ ์๋ฃ */
.adstage-loaded {
opacity : 1 ;
transition : opacity 0.3 s ease ;
}
/* ์ค๋ฅ ์ํ */
.adstage-error {
border : 1 px solid #ff6b6b ;
background-color : #ffe0e0 ;
}
// ๋ชจ๋ ์ฌ๋กฏ ํ์ธ
const allSlots = AdStage.ads. getAllSlots ();
console. log ( '์ ์ฒด ๊ด๊ณ ์ฌ๋กฏ:' , allSlots);
// ํน์ ์ฌ๋กฏ ํ์ธ
const slot = AdStage.ads. getSlotById (slotId);
console. log ( '์ฌ๋กฏ ์ ๋ณด:' , slot);