동영상 광고
동영상 광고(InStream Video Ad)는 동영상 컨텐츠 재생 전, 재생 중 또는 재생 후에 삽입되는 광고형태입니다.
본 페이지는 전/중/후 광고 호출을 위한 비디오 스케줄 매니저 GfpVideoAdScheduleManager (이하 VSM)
사용 가이드입니다.
동영상 광고가 재생될 Player 는 서비스가 사용하는 Player 를 주입받는 형태입니다.
플레이어 설정을 참고해 주시기 바랍니다.
[Step 1] Dependency 추가
- Kotlin DSL
- Groovy
dependencies {
implementation(platform("com.naver.gfpsdk:nam-bom:8.2.6"))
implementation("com.naver.gfpsdk:nam-core")
implementation("com.naver.gfpsdk:nam-ndavideo") // Naver InStream ads extension
}
dependencies {
implementation platform('com.naver.gfpsdk:nam-bom:8.2.6')
implementation 'com.naver.gfpsdk:nam-core'
implementation 'com.naver.gfpsdk:nam-ndavideo' // Naver InStream ads extension
}
[Step 2] Player 레이아웃이 포함될 수 있는 ViewGroup 추가
비디오 광고를 게재하기 위해서는 먼저 광고를 게재하려는 Activity
또는 Fragment
의 레이아웃에
비디오 광고와 본영상이 재생될 수 있는 영역에 대한 ViewGroup
을 추가해야 합니다.
아래 예제에서는 RelativeLayout
ViewGroup 에 video_ad_container
라는 id 로 비디오 광고가 게재될 Layout 을 선언했습니다.
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<RelativeLayout
android:id="@+id/video_ad_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#000000"
app:layout_constraintDimensionRatio="16:9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
[Step 3] Player 와 광고 UI 가 포함될 레이아웃 생성
비디오 광고가 재생되는데 필요한 Player(AdVideoPlayer 에 대한 구현이 되어있어야 함) 와 광고 UI 가 포함될 레이아웃을 선언합니다.
아래는 player 와 광고 ui 가 포함될 frame layout 을 포함하는 레이아웃에 대한 예시 이며,
생성된 ad_video_player
와 ad_ui_container
는 광고 로더인 GfpVideoAdScheduleManager
의 생성자에서 사용됩니다.
아래에서 생성한 xml 파일의 이름은 video_ad_exoplayer_layout.xml
이라고 가정합니다.
outer_text_ad_container
의 경우 SMR 광고에서 사용되는 리마인드 광고에 사용되는 영역이고 아래와 같이 별도로 설정하게 됩니다.
videoAdScheduleManager.setOuterRemindTextAdViewContainer(outerTextAdContainer);
다만 이번 샘플에서는 사용되지 않습니다.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.naver.gfpsdk.adssample.video.SampleExoPlayerView
android:id="@+id/ad_video_player"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true" />
<FrameLayout
android:id="@+id/ad_ui_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/outer_text_ad_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
[Step 4] AdParam 과 VideoAdScheduleParam 생성
비디오 광고 요청을 위한 광고 파라미터(AdParam
) 와 스케줄 파라미터(VideoAdScheduleParam
)를 구성합니다.
4-1. AdParam
광고 요청 정보 를 참고하여 광고 요청에 대한 AdParam
를 생성합니다.
다른 광고와는 다르게, Ad Unit ID
는 필수 값이 아니고, 동영상 관련 파라미터를 필수로 받게 됩니다. 위 'AdParam' 정보 페이지에서 동영상 관련 파라미터를 참고해 주세요.
AdParam
구성시, setAdUnitId
설정이 불필요하며 설정시 무시 됩니다.
4-2 VideoAdScheduleParam
- 컨텐츠 길이(
contentDuration
)
필수 입력값 이며, 초단위로 정확히 입력해야 스케줄이 정상 동작 합니다.
- 스케줄아이디(
adScheduleId
)
필수값이며 NAM 담당자로 부터 사전에 안내 받아야 합니다.
- 스케줄 정책 설정(
setAdSchedulePolicy
)
전/중/후 광고를 선택적으로 제외할 수 있습니다.
부가적인 값으로, 각 스케쥴 아이디마다 NAM 어드민에서 설정한 정책이 있습니다.
어드민에 설정은 했지만 서비스에서 off 를 원할 때 사용됩니다.
- (라이브 컨텐츠의 경우) 컨텐츠 시작 시점(
setContentStartOffset
)
컨텐츠 시작 시점 기준으로 광고 스케줄 오프셋이 조정됩니다.
- Kotlin
- Java
val adParam = AdParam.Builder()
.setRefererPageUrl("https://tv.naver.com/r/")
.setCurrentPageUrl("https://tv.naver.com/v/36037577/list/67096")
.setVrr(1) // SMR 광고에서 Remind Ad를 요청할지 (1 = request, 0 = don't request)
.addCustomParam("lo", "Y") // Loudness Normalization 적용 여부
.addCustomParam("pt", "635") // 콘텐츠 클립 전체 시간 (second 단위)
.addCustomParam("pcmo", "mo") // pc or mo or tv - mo로 고정된 값 사용
.addCustomParam("vid", "0A7CFF5F2F5791DEE667757BD6F9E80411AA") // video ID
.addCustomParam("tid", "3Cb51Nn2ufoyPok6Tpct-A") // 트랜잭션 ID
.addCustomParam("cp", "1403") // 제휴사(창작자) 구분 ID
.addCustomParam("chl", "motline") // 채널 구분 ID
.addCustomParam("cl", "20539479") // 클립 ID
.addCustomParam("svc", "WAVVE_AOS") // 서비스 ID - 고정된 값 (NAM 담당자 통해 확인해 주세요.)
.addCustomParam("cc", "N") // 어린이 보호 콘텐츠 적용 여부
.addCustomParam("AreaId", "clip") // 광고 영역
.build()
/** 이하는 스케줄 정보 수신 이후 SDK 에서 설정합니다.
* 스케줄과 별도로 설정하고자 할 때만 사용해 주세요.
* .setVcl() // 비디오 켄텐츠 길이
* .setVri() // 비디오 스케줄 요청 아이디
* .setVrr() // 리마인드 광고 여부
* .setVsd() // 비디오 전/중/후 여부
* .setVsi() // 비디오 스케줄 아이디
*/
val contentDuration = 653L // 초 단위의 컨텐츠 영상 길이
val adScheduleId = "WAVVE_SCH" // Ad Unit ID 처럼 NAM 담당자에게 안내 받아야 함
val pre = true
val mid = false // 영상 중간에 광고 없음 선택
val post = true
val videoAdScheduleParam = VideoAdScheduleParam.Builder(adScheduleId)
.setDuration(contentDuration)
.setAdSchedulePolicy(pre, mid, post)
.setAdNoticeDurationSec(5) // mid 광고 시작 전 안내 문구 표시 시간
.build()
AdParam adParam = new AdParam.Builder()
.setRefererPageUrl("https://tv.naver.com/r/")
.setCurrentPageUrl("https://tv.naver.com/v/36037577/list/67096")
.setVrr(1) // SMR 광고 에서 Remind Ad를 요청할지 (1 = request, 0 = don't request)
.addCustomParam("lo", "Y") // Loudness Normalazation 적용 여부
.addCustomParam("pt", "635") // 콘텐츠 클립 전체 시간 (second 단위)
.addCustomParam("pcmo", "mo") // pc or mo or tv - mo로 고정된 값 사용
.addCustomParam("vid", "0A7CFF5F2F5791DEE667757BD6F9E80411AA") // video ID
.addCustomParam("tid", "3Cb51Nn2ufoyPok6Tpct-A") // 트랜잭션 ID
.addCustomParam("cp", "1403") // 제휴사(창작자) 구분 ID
.addCustomParam("chl", "motline") // 채널 구분 ID
.addCustomParam("cl", "20539479") // 클립 ID
.addCustomParam("svc", "WAVVE_AOS") // 서비스 ID - 고정된 값 (NAM 담당자 통해 확인해 주세요.)
.addCustomParam("cc", "N") // 어린이 보호 콘텐츠 적용 여부
.addCustomParam("AreaId", "clip") // 광고 영역
.build();
/** 이하는 스케줄 정보 수신 이후 SDK 에서 설정합니다.
* 스케줄과 별도로 설정하고자 할 때만 사용해 주세요.
* .setVcl() // 비디오 켄텐츠 길이
* .setVri() // 비디오 스케줄 요청 아이디
* .setVrr() // 리마인드 광고 여부
* .setVsd() // 비디오 전/중/후 여부
* .setVsi() // 비디오 스케줄 아이디
*/
long contentDuration = 653L; // 초 단위의 컨텐츠 영상 길이
String adScheduleId = "WAVVE_SCH"; // Ad Unit ID 처럼 NAM 담당자에게 안내 받아야 함
boolean pre = true;
boolean mid = false; //영상 중간에 광고 없음 선택
boolean post = true;
VideoAdScheduleParam videoAdScheduleParam = new VideoAdScheduleParam.Builder(adScheduleId)
.setDuration(contentDuration)
.setAdSchedulePolicy(pre, mid, post)
.setAdNoticeDurationSec(5) // mid 광고 시작 전 안내 문구 표시 시간
.build();
4-3 비디오 광고 옵션 설정
GfpVideoAdScheduleManager
setVideoAdOptions() 을 통해 비디오 광고 옵션을 설정합니다.
GfpVideoAdOptions
에는 bitrateKbps
, videoLoadTimeout(ms)
, hls
지원여부를 설정할 수 있습니다.
-
hls 는 기본 미지원입니다.
( video/mp4만 지원 )
-
bitrateKbps 로 광고의 품질을 결정합니다.
기본값은 -1로 IMA 의 경우 자동 셋팅, 네이버 광고의 경우에는 최저 (hls 미지원 시) 해상도의 광고가 재생됩니다.
-
videoLoadTimeout 은 재생 start 요청 후 해당 시간까지 실제 재생이되지 않으면 에러를 발생시킵니다.