@sgrsoft/vpe-react-sdk 0.1.21 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -114,6 +114,7 @@ export function App() {
114
114
  | devTestAppId | string | vpe-core-sdk 기본값 | No | 개발 테스트용 AppId |
115
115
  | token | string | vpe-core-sdk 기본값 | No | 스트림 URL 토큰 |
116
116
  | override | object | vpe-core-sdk 기본값 | No | 이벤트/동작 오버라이드 |
117
+ | ads | AdOptions | - | No | Pre-roll 광고 설정 (Google IMA) |
117
118
  | layout | ControlBarLayout \| Variant \| Responsive | SDK 기본 레이아웃 | No | 컨트롤바 레이아웃 |
118
119
 
119
120
  참고
@@ -575,6 +576,38 @@ export function App() {
575
576
  />
576
577
  ```
577
578
 
579
+ ### ads
580
+ - Pre-roll 광고를 설정합니다. Google IMA SDK 기반으로 동작합니다.
581
+ - `tagUrl`에 VAST 태그 URL을 전달하면 콘텐츠 재생 전에 광고가 자동 재생됩니다.
582
+ - 광고 재생 중 콘텐츠 비디오는 자동으로 일시정지되고, 컨트롤바가 숨겨집니다.
583
+ - 광고 완료/스킵/에러 후 콘텐츠가 자동 재생됩니다.
584
+ ```tsx
585
+ <VpePlayer
586
+ accessKey="YOUR_ACCESS_KEY"
587
+ hls={Hls}
588
+ options={{
589
+ playlist: [
590
+ {
591
+ file: "https://CDN_DOMAIN/example.m3u8"
592
+ }
593
+ ],
594
+ autostart: true,
595
+ muted: true,
596
+ ads: {
597
+ tagUrl: "https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",
598
+ enabled: true, // 기본값: true. false로 설정하면 광고 비활성화
599
+ },
600
+ }}
601
+ />
602
+ ```
603
+
604
+ **AdOptions 타입**
605
+
606
+ | 옵션 | 타입 | 기본값 | 필수 | 설명 |
607
+ | --- | --- | --- | --- | --- |
608
+ | tagUrl | string | - | Yes | VAST/VMAP 광고 태그 URL |
609
+ | enabled | boolean | `true` | No | 광고 활성화 여부 |
610
+
578
611
  ---
579
612
 
580
613
  ### layout
@@ -800,6 +833,10 @@ playerRef.current?.addPrevSource([
800
833
  | skipBack | 뒤로 건너뜀 |
801
834
  | playlistChange | 플레이리스트 변경 |
802
835
  | error | 오류 발생 |
836
+ | adStart | 광고 재생 시작 |
837
+ | adComplete | 광고 재생 완료 |
838
+ | adSkip | 사용자가 광고 스킵 |
839
+ | adError | 광고 로드/재생 에러 |
803
840
 
804
841
  ## One Click Multi DRM 예제
805
842
  ```ts
@@ -864,3 +901,96 @@ options={{
864
901
  ],
865
902
  }}
866
903
  ```
904
+
905
+ ## Pre-roll 광고 (Google IMA)
906
+
907
+ Google IMA SDK를 사용한 Pre-roll 영상 광고를 지원합니다.
908
+ `options.ads.tagUrl`에 VAST 태그 URL을 전달하면 콘텐츠 재생 전에 광고가 자동으로 재생됩니다.
909
+
910
+ - Google IMA SDK는 외부에서 자동 로드됩니다 (번들에 포함되지 않음)
911
+ - 광고 재생 중 콘텐츠 비디오는 자동으로 일시정지되고, 컨트롤바가 숨겨집니다
912
+ - 광고 완료/스킵/에러 후 콘텐츠가 자동 재생됩니다
913
+ - `ads` 옵션이 없으면 기존과 동일하게 동작합니다
914
+
915
+ ### React (ESM) 예제
916
+
917
+ ```tsx
918
+ "use client";
919
+
920
+ import Hls from "hls.js";
921
+ import { VpePlayer } from "@sgrsoft/vpe-react-sdk";
922
+
923
+ export default function AdPlayer() {
924
+ return (
925
+ <VpePlayer
926
+ accessKey="YOUR_ACCESS_KEY"
927
+ hls={Hls}
928
+ options={{
929
+ playlist: [
930
+ {
931
+ file: "https://CDN_DOMAIN/example.m3u8",
932
+ poster: "https://CDN_DOMAIN/poster.jpg",
933
+ },
934
+ ],
935
+ autostart: true,
936
+ muted: true,
937
+ ads: {
938
+ tagUrl: "https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",
939
+ },
940
+ }}
941
+ onEvent={(event) => {
942
+ switch (event.type) {
943
+ case "adStart":
944
+ console.log("광고 시작");
945
+ break;
946
+ case "adComplete":
947
+ console.log("광고 완료");
948
+ break;
949
+ case "adSkip":
950
+ console.log("광고 스킵");
951
+ break;
952
+ case "adError":
953
+ console.log("광고 에러", event.data?.message);
954
+ break;
955
+ }
956
+ }}
957
+ />
958
+ );
959
+ }
960
+ ```
961
+
962
+ ### UMD 예제
963
+
964
+ ```html
965
+ <script src="https://player.vpe.naverncp.com/v2/ncplayer.js?access_key=YOUR_ACCESS_KEY"></script>
966
+ <script src="https://cdn.jsdelivr.net/npm/hls.js@1"></script>
967
+
968
+ <div id="video"></div>
969
+
970
+ <script>
971
+ const player = new ncplayer("video", {
972
+ playlist: [
973
+ { file: "https://CDN_DOMAIN/example.m3u8" },
974
+ ],
975
+ autostart: true,
976
+ muted: true,
977
+ ads: {
978
+ tagUrl: "https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",
979
+ },
980
+ });
981
+
982
+ player.on("adStart", function(e) { console.log("광고 시작"); });
983
+ player.on("adComplete", function(e) { console.log("광고 완료"); });
984
+ player.on("adSkip", function(e) { console.log("광고 스킵"); });
985
+ player.on("adError", function(e) { console.log("광고 에러", e.data?.message); });
986
+ </script>
987
+ ```
988
+
989
+ ### 광고 이벤트
990
+
991
+ | 이벤트 | 설명 |
992
+ | --- | --- |
993
+ | adStart | 광고 재생 시작 |
994
+ | adComplete | 광고 재생 완료 |
995
+ | adSkip | 사용자가 광고 스킵 |
996
+ | adError | 광고 로드/재생 에러 (`event.data.message`에 상세 메시지) |