StageUp
Web SDKAdvertisements

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.

๐ŸŽฏ Basic Usage

Simple Video Ad

// 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
});

Handling Click Events

AdStage.ads.video('video-container', {
  width: 640,
  height: 360,
  onClick: (adData) => {
    console.log('๋น„๋””์˜ค ๊ด‘๊ณ  ํด๋ฆญ๋จ:', adData);
    // ์‚ฌ์šฉ์ž ์ •์˜ ๋กœ์ง ์ถ”๊ฐ€ ๊ฐ€๋Šฅ
  }
});

โš™๏ธ Configuration Options

Basic Options

OptionTypeDefaultDescription
widthnumber640Video width (px)
heightnumber360Video height (px)
autoplaybooleantrueWhether to autoplay
mutedbooleantrueWhether to mute
controlsbooleanfalseShow default controls
onClickfunctionundefinedCallback function executed on click

Advanced Options

OptionTypeDefaultDescription
loopbooleantrueWhether to loop playback
playsinlinebooleantrueInline playback (mobile)
customControlsobjectundefinedDetailed control settings

Filtering Options

OptionTypeDefaultDescription
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).

๐Ÿ’ก Real-World Implementation Examples

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>

๐Ÿš€ Advanced Features

Custom Controls

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    // ์ „์ฒดํ™”๋ฉด ๋ฒ„ํŠผ ์ˆจ๊น€
  }
});

Responsive Video

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
  });
});

Specifying a Particular Ad ID

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
});

๐Ÿ”ง Optimization Tips

1. Leverage Dynamic Resizing

The SDK automatically optimizes the container to fit the video size.

// 16:9 ๋น„์œจ ์ž๋™ ์œ ์ง€
AdStage.ads.video('video-container', {
  width: '100%',
  height: 'auto'  // ๋น„์œจ์— ๋งž์ถฐ ์ž๋™ ์กฐ์ •
});

2. Background Loading

Ads load in the background, so you can receive a slot ID immediately.

// ์ฆ‰์‹œ ์Šฌ๋กฏ ID ๋ฐ˜ํ™˜
const slotId = AdStage.ads.video('video-container');
console.log('์Šฌ๋กฏ ์ƒ์„ฑ๋จ:', slotId);  // ์ฆ‰์‹œ ์‹คํ–‰
 
// ์‹ค์ œ ๊ด‘๊ณ ๋Š” ๋น„๋™๊ธฐ๋กœ ๋กœ๋“œ๋จ

3. Leverage Automatic Cleanup

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() ํ˜ธ์ถœํ•  ํ•„์š” ์—†์Œ

๐ŸŽจ Styling

Leveraging CSS Classes

You can apply styles using the CSS classes that the SDK adds automatically.

/* ๊ด‘๊ณ  ์ปจํ…Œ์ด๋„ˆ ๊ธฐ๋ณธ ์Šคํƒ€์ผ */
.adstage-video-ad {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}
 
/* ๋กœ๋”ฉ ์ƒํƒœ */
.adstage-loading {
  opacity: 0.7;
  background: linear-gradient(90deg, #000 25%, #333 50%, #000 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}
 
@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
 
/* ๋กœ๋”ฉ ์™„๋ฃŒ */
.adstage-loaded {
  opacity: 1;
  transition: opacity 0.3s ease;
}
 
/* ์˜ค๋ฅ˜ ์ƒํƒœ */
.adstage-error {
  border: 1px solid #ff6b6b;
  background-color: #ffe0e0;
}

Checking Slot Status

// ๋ชจ๋“  ์Šฌ๋กฏ ํ™•์ธ
const allSlots = AdStage.ads.getAllSlots();
console.log('์ „์ฒด ๊ด‘๊ณ  ์Šฌ๋กฏ:', allSlots);
 
// ํŠน์ • ์Šฌ๋กฏ ํ™•์ธ
const slot = AdStage.ads.getSlotById(slotId);
console.log('์Šฌ๋กฏ ์ •๋ณด:', slot);

Table of Contents