@sgrsoft/vpe-core-sdk 0.9.0 → 0.10.0
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/dist/main.d.ts +5 -0
- package/dist/options.d.ts +1 -0
- package/dist/vpe-core-sdk.cjs.js +1 -1
- package/dist/vpe-core-sdk.es.js +148 -107
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
package/dist/options.d.ts
CHANGED
package/dist/vpe-core-sdk.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const g={common:{cancel:"Cancel",auto:"Auto",normal:"Normal",notUse:"Not used",prev:"Previous video",next:"Next video",delayText:"seconds until auto-play",license:"License",play:"Play",pause:"Pause",replay:"Replay",fullOn:"Fullscreen",fullOff:"Exit fullscreen",muteOn:"Mute",muteOff:"Unmute",captionOff:"Turn off captions",captionOn:"Turn on captions",setting:"Settings",live:"LIVE",miniPlayer:"Mini player",isMute:"You are muted.",subtitle:"Subtitles",subtitleNot:"Subtitles not available"},settings:{autoplay:"Autoplay",playbackRate:"Playback speed",captions:"Subtitles",quality:"Quality"},error:{"01":{title:"Cannot play video",desc:"Invalid access. Please check your access_key."},"02":{title:"Cannot play video",desc:"You do not have permission to play this video."},"03":{title:"Authentication Failed",desc:"The network connection is unstable."},"04":{title:"Cannot play video",desc:"The video could not be played."},"05":{title:"Cannot play video",desc:"The license is not valid."},"06":{title:"Cannot play video",desc:"Monthly basic API calls exceeded. Please switch to a paid version."},"07":{title:"Cannot play video",desc:"Unsupported format."},"08":{title:"Cannot play video",desc:"Invalid URL format."},"09":{title:"Cannot play video",desc:"The live stream is OFFLINE."},10:{title:"Cannot play video",desc:"Cannot play DASH video on iOS."},11:{title:"Cannot play video",desc:"Invalid DRM token."},12:{title:"Cannot play video",desc:"Failed to communicate with the DRM license server."},13:{title:"Cannot play video",desc:"FairPlay certificate validation failed."},14:{title:"Cannot play video",desc:"Screen capture / screen recording has been detected."},15:{title:"Player Execution Failed",desc:"Required module was not loaded. (hls.js)"},16:{title:"Player Execution Failed",desc:"Required module was not loaded. (dash.js)"}},alternative:{hour:"hour(s)",minute:"minute(s)",second:"second(s)",after:"In a moment",afterMin:"min",afterHour:"hour",afterDay:"day",startPlay:"Video will start in {timeTxt}.",nextPlay:"Next video will play in {timeTxt} seconds.",afterPlay:"Scheduled"}},m={common:{cancel:"취소",auto:"자동",normal:"보통",notUse:"사용안함",prev:"이전 동영상",next:"다음 동영상",delayText:"초 뒤 자동재생",license:"라이선스",play:"재생",pause:"일시정지",replay:"다시보기",fullOn:"전체화면",fullOff:"전체화면 해제",muteOn:"음소거",muteOff:"음소거 해제",captionOff:"자막끄기",captionOn:"자막켜기",setting:"설정",live:"실시간",miniPlayer:"미니플레이어",isMute:"음소거 상태입니다.",subtitle:"자막",subtitleNot:"자막 사용 불가"},settings:{autoplay:"자동재생",playbackRate:"재생 속도",captions:"자막",quality:"해상도"},error:{"01":{title:"동영상을 재생할 수 없음",desc:"잘못된 접근입니다. access_key를 확인해주세요."},"02":{title:"동영상을 재생할 수 없음",desc:"동영상을 재생할 권한이 없습니다."},"03":{title:"인증 실패",desc:"네트워크 연결이 원활하지 않습니다."},"04":{title:"동영상을 재생할 수 없음",desc:"동영상을 재생할 수 없습니다."},"05":{title:"동영상을 재생할 수 없음",desc:"라이선스가 유효하지 않습니다."},"06":{title:"동영상을 재생할 수 없음",desc:"월 기본 제공 호출 건수를 초과하였습니다. 유료 버전으로 전환 후 사용 부탁 드립니다."},"07":{title:"동영상을 재생할 수 없음",desc:"지원하지 않는 형식입니다."},"08":{title:"동영상을 재생할 수 없음",desc:"URL 형식이 잘못되었습니다."},"09":{title:"동영상을 재생할 수 없음",desc:"라이브스트림이 OFFLINE 입니다."},10:{title:"동영상을 재생할 수 없음",desc:"iOS에서 Dash 비디오를 재생할 수 없습니다."},11:{title:"동영상을 재생할 수 없음",desc:"DRM 토큰이 잘못되었습니다."},12:{title:"동영상을 재생할 수 없음",desc:"DRM 라이선스 서버와 통신에 실패하였습니다."},13:{title:"동영상을 재생할 수 없음",desc:"FairPlay 인증서 검증에 실패하였습니다."},14:{title:"동영상을 재생할 수 없음",desc:"화면 캡쳐 / 화면 녹화가 감지되었습니다."},15:{title:"플레이어 실행 실패",desc:"필수 모듈이 로드되지 않았습니다. (hls.js)"},16:{title:"플레이어 실행 실패",desc:"필수 모듈이 로드되지 않았습니다. (dash.js)"}},alternative:{hour:"시",minute:"분",second:"초",after:"잠시 ",afterMin:"분 ",afterHour:"시간 ",afterDay:"일 ",startPlay:"{timeTxt} 후 영상이 시작됩니다.",nextPlay:"{timeTxt}초 후 다음 영상이 재생됩니다.",afterPlay:"예정"}},h={common:{cancel:"キャンセル",auto:"自動",normal:"標準",notUse:"使用しない",prev:"前の動画",next:"次の動画",delayText:"秒後に自動再生",license:"ライセンス",play:"再生",pause:"一時停止",replay:"リプレイ",fullOn:"全画面表示",fullOff:"全画面表示を終了",muteOn:"ミュート",muteOff:"ミュート解除",captionOff:"字幕をオフにする",captionOn:"字幕をオンにする",setting:"設定",live:"ライブ",miniPlayer:"ミニプレーヤー",isMute:"ミュート状態です。",subtitle:"字幕",subtitleNot:"字幕は利用できません"},settings:{autoplay:"自動再生",playbackRate:"再生速度",captions:"字幕",quality:"画質"},error:{"01":{title:"動画を再生できません",desc:"不正なアクセスです。access_keyを確認してください。"},"02":{title:"動画を再生できません",desc:"この動画を再生する権限がありません。"},"03":{title:"認証に失敗しました",desc:"ネットワーク接続が不安定です。"},"04":{title:"動画を再生できません",desc:"動画を再生できませんでした。"},"05":{title:"動画を再生できません",desc:"ライセンスが無効です。"},"06":{title:"動画を再生できません",desc:"月間の基本提供呼び出し回数を超過しました。有料版に切り替えてご利用ください。"},"07":{title:"動画を再生できません",desc:"サポートされていない形式です。"},"08":{title:"動画を再生できません",desc:"URLの形式が正しくありません。"},"09":{title:"動画を再生できません",desc:"ライブストリームはオフラインです。"},10:{title:"動画を再生できません",desc:"iOSではDASHビデオを再生できません。"},11:{title:"動画を再生できません",desc:"DRMトークンが無効です。"},12:{title:"動画を再生できません",desc:"DRMライセンスサーバーとの通信に失敗しました。"},13:{title:"動画を再生できません",desc:"FairPlay証明書の検証に失敗しました。"},14:{title:"動画を再生できません",desc:"画面キャプチャ/画面録画が検出されました。"},15:{title:"プレーヤーの起動に失敗しました",desc:"必須モジュールが読み込まれていません。(hls.js)"},16:{title:"プレーヤーの起動に失敗しました",desc:"必須モジュールが読み込まれていません。(dash.js)"}},alternative:{hour:"時間",minute:"分",second:"秒",after:"しばらくして",afterMin:"分後",afterHour:"時間後",afterDay:"日後",startPlay:"{timeTxt}後に動画が始まります。",nextPlay:"{timeTxt}秒後に次の動画が再生されます。",afterPlay:"予定"}},d={en:g,ko:m,ja:h},v=()=>typeof navigator<"u"&&typeof navigator.language<"u";function S(t){const e=t.split("-")[0];return e in d?e:"en"}function p(t){let e="en";t?e=t:v()&&(e=navigator.language);const n=S(e);return d[n]}p();const b={AF:"Afghanistan",AX:"Åland Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia (Plurinational State of)",BQ:"Bonaire, Sint Eustatius and Saba",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",CV:"Cabo Verde",KH:"Cambodia",CM:"Cameroon",CA:"Canada",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:"China",CX:"Christmas Island",CC:"Cocos (Keeling) Islands",CO:"Colombia",KM:"Comoros",CG:"Congo",CD:"Congo (Democratic Republic of the)",CK:"Cook Islands",CR:"Costa Rica",CI:"Côte d'Ivoire",HR:"Croatia",CU:"Cuba",CW:"Curaçao",CY:"Cyprus",CZ:"Czech Republic",DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:"Gambia",GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GG:"Guernsey",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and McDonald Islands",VA:"Holy See",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran (Islamic Republic of)",IQ:"Iraq",IE:"Ireland",IM:"Isle of Man",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JE:"Jersey",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",KP:"Korea (Democratic People's Republic of)",KR:"Korea, Republic of",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MK:"Macedonia (the former Yugoslav Republic of)",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia (Federated States of)",MD:"Moldova (Republic of)",MC:"Monaco",MN:"Mongolia",ME:"Montenegro",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:"Netherlands",NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:"Palestine, State of",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:"Pitcairn",PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russian Federation",RW:"Rwanda",BL:"Saint Barthélemy",SH:"Saint Helena, Ascension and Tristan da Cunha",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin (French part)",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten (Dutch part)",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:"Taiwan",TJ:"Tajikistan",TZ:"Tanzania, United Republic of",TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States of America",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela (Bolivarian Republic of)",VN:"Viet Nam",VG:"Virgin Islands (British)",VI:"Virgin Islands (U.S.)",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"},M={gov:{prod:{log:"https://papi.vpe.gov-ntruss.com/player/maSync",report:"https://log.vpe.gov-ntruss.com/stats"},beta:{log:"https://papi.beta-vpe.gov-ntruss.com/player/maSync",report:"https://log.beta-vpe.gov-ntruss.com/stats"}},pub:{prod:{log:"https://papi.vpe.naverncp.com/player/maSync",report:"https://log.vpe.naverncp.com/stats"},beta:{log:"https://papi.beta-vpe.naverncp.com/player/maSync",report:"https://log.beta-vpe.naverncp.com/stats"}}};let s={video:{},browser:{},device:{},connection:{},screen:{},player_version:"latest",extra:{sessionId:null,playerType:"VPE React Native"},log_type:"vpe",privacy:{cookie_enabled:!0}},l={platform:"pub",stage:"prod",sync:!1,syncResult:{}};const C=new Date().getTime(),y=()=>{const t=new Date,e=i=>String(i).padStart(2,"0"),n=`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())} ${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}`,a=Math.floor(t.getTime()/1e3),r=new Date().getTime()-C;return{logDate:n,logDateUnix:a,thisSec:r}};function I(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function w(t,e){Object.entries(e).forEach(([n,a])=>{I(a)?(t[n]||(t[n]={}),Object.entries(a).forEach(([r,i])=>{i!=null&&(t[n][r]=i)})):a!=null&&(t[n]=a)})}function P(t){const e=[];return t?.r1&&e.push(t.r1),t?.r2&&e.push(t.r2),t?.r3&&e.push(t.r3),e.join(" ")}function R(t){try{const e=l.syncResult?.geoLocation;e&&(t.address=P(e),t.isp=e.net||"",t.ip=l.syncResult?.ip||"",t.nation=e.country||"")}catch{}}const T=async t=>{if(!t)return;const{platform:e,stage:n}=l,a=M[e][n].log;try{const i=await(await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({access_key:t})})).json();l.sync=i.result?.sync||!1,l.syncResult=i.result||{};const{logDate:o,logDateUnix:c}=y();return s.extra.logDate=o,s.extra.logDateUnix=c,l.syncResult?.geoLocation&&R(s.extra),i}catch(r){return console.error("MA config initialization failed:",r),null}};async function B(t,e,n,a,r){l.platform=t,l.stage=e,w(s,n),a&&(s.extra.vpePackageId=a),r&&(s.extra.vpeKey=r),s.extra.nation?s.browser.country=b[s.extra.nation]||"Korea, Republic of":s.browser.country="Korea, Republic of";const{logDate:i,logDateUnix:o}=y();s.extra.logDate=i,s.extra.logDateUnix=o,s.extra.created_at=o}const A=(t={})=>{const e={autostart:!0,muted:!1,aspectRatio:"16/9",objectFit:"contain",controls:!0,keyboardShortcut:!1,startMutedInfoNotVisible:!1,allowsPictureInPicture:!1,staysActiveInBackground:!1,screenRecordingPrevention:!1,modalFullscreen:!1,lang:"ko",ui:"all",controlBtn:{play:!0,fullscreen:!0,progressBar:!0,volume:!1,times:!0,pictureInPicture:!0,setting:!0,subtitle:!0},progressBarColor:"#4299f5",controlActiveTime:3e3,playRateSetting:[.5,.75,1,1.5,2],autoPause:!1,repeat:!1,setStartTime:void 0,playIndex:0,lowLatencyMode:!0,touchGestures:!0,descriptionNotVisible:!1,devTestAppId:void 0,token:"",visibleWatermark:!1,watermarkText:"NAVER CLOUD PLATFORM",watermarkConfig:{randPosition:!0,randPositionInterVal:3e3,x:10,y:10,opacity:.5},captionStyle:{fontSize:12,color:"#ffffff",backgroundColor:"rgba(0, 0, 0, 0.4)",edgeStyle:"dropshadow"},override:null},n={...e,...t};return t.controlBtn&&(n.controlBtn={...e.controlBtn,...t.controlBtn}),t.watermarkConfig&&(n.watermarkConfig={...e.watermarkConfig,...t.watermarkConfig}),t.captionStyle&&(n.captionStyle={...e.captionStyle,...t.captionStyle}),n.objectFit==="fill"&&(n.objectFit="stretch"),n.controlBtn?.progressBar===void 0&&(n.controlBtn.progressBar=!0),n},L={gov:{prod:{config:"aHR0cHM6Ly9wYXBpLnZwZS5nb3YtbnRydXNzLmNvbS9wbGF5ZXIvY29uZmln",report:"aHR0cHM6Ly9sb2cudnBlLmdvdi1udHJ1c3MuY29tL3N0YXRz"},beta:{config:"aHR0cHM6Ly9wYXBpLmJldGEtdnBlLmdvdi1udHJ1c3MuY29tL3BsYXllci9jb25maWc=",report:"aHR0cHM6Ly9sb2cuYmV0YS12cGUuZ292LW50cnVzcy5jb20vc3RhdHM="}},pub:{prod:{config:"aHR0cHM6Ly9wYXBpLnZwZS5uYXZlcm5jcC5jb20vcGxheWVyL2NvbmZpZw==",report:"aHR0cHM6Ly9sb2cudnBlLm5hdmVybmNwLmNvbS9zdGF0cw=="},beta:{config:"aHR0cHM6Ly9wYXBpLmJldGEtdnBlLm5hdmVybmNwLmNvbS9wbGF5ZXIvY29uZmln",report:"aHR0cHM6Ly9sb2cuYmV0YS12cGUubmF2ZXJuY3AuY29tL3N0YXRz"}}};let u=[];const E=t=>{try{return atob(t)}catch(e){return console.error("Base64 decoding failed:",e),""}};class N{serverConfig={};playerInfo=null;accessKey;appId;platform;stage;isDev;translator;errorState;constructor({accessKey:e,appId:n,platform:a,stage:r,isDev:i=!1,language:o}){this.accessKey=e,this.appId=n||location.origin,this.platform=a,this.stage=r,this.isDev=i,this.translator=p(o),this.errorState={errorCode:null,errorMessage:null}}async initialize(){const e=["accessKey","appId","E0002","E0001","E0003"],n="VPE Player: accessKey 또는 appId가 없어 키 인증을 건너뜁니다.";if([this[e[0]],this[e[1]]].some(i=>!i))return console.warn(n),{error:this.setErrorRun(e[2])};const r=i=>(this.serverConfig=i,this.playerInfo=this.createPlayerInfo(i),this.playerInfo);try{const i=await this.performKeyCheck();if(i.code!==200)return{error:this.setErrorRun(e[3])};const o=r(i);return await B(this.platform,this.stage,o,this.appId,this.accessKey),await T(this.accessKey),{options:this.serverConfig.result?.options,playerInfo:o}}catch(i){return console.error("VPE SDK Initialization failed:",i),{error:this.setErrorRun(e[4])}}}async performKeyCheck(){const e=["?preview=true","config","Content-Type","application/json","access_key","domain","POST"],n=this.isDev?e[0]:"",a=E(L[this.platform][this.stage][e[1]])+n,r=JSON.stringify([e[4],e[5]].reduce((o,c,f)=>(o[c]=[this.accessKey,this.appId][f],o),{})),i=await fetch(a,{method:e[6],headers:{[e[2]]:e[3]},body:r});if(!i.ok)throw new Error(["API","Error:",i.status,i.statusText].join(" "));return i.json()}getBrowserInfo(){const e=navigator.userAgent;return/Edg\/(\d+\.\d+)/.test(e)?{origin:"Edge",version:RegExp.$1}:/Chrome\/(\d+\.\d+)/.test(e)&&!e.includes("Edg")?{origin:"Chrome",version:RegExp.$1}:/Firefox\/(\d+\.\d+)/.test(e)?{origin:"Firefox",version:RegExp.$1}:/Version\/(\d+\.\d+)/.test(e)&&e.includes("Safari")?{origin:"Safari",version:RegExp.$1}:{origin:"Unknown",version:"Unknown"}}createPlayerInfo(e){const[n,a]=e.result.name.split("|"),r=navigator.connection||navigator.mozConnection||navigator.webkitConnection,i=this.getBrowserInfo(),o=navigator.userAgentData;return{cid:e.result.cid,player_name:n,player_version:a,pricing:e.result.pricing,maUse:e.result.options?.maUse==="Y"?"Y":"N",browser:{lang:navigator.language,ua:navigator.userAgent},screen:{width:window.screen.width,height:window.screen.height},connection:{network:r?.effectiveType??"unknown",downlink:r?.downlink??null,rtt:r?.rtt??null,save_data:r?.saveData??!1},device:{platform:o?.platform??"Unknown",mobile:o?.mobile??!1,memory:navigator.deviceMemory??null,processor:navigator.hardwareConcurrency??null},video:{url:""},extra:{vpeKey:this.accessKey,playerType:"VPE",playerVersion:a,device:o?.platform??"Unknown",os:o?.platform??"Unknown",osOrigin:o?.platform??"Unknown",osVersion:o?.platformVersion??"Unknown",vpePackageId:this.appId,actionDuration:0,actionType:"ready",browser:i.origin,browserOrigin:i.origin,browserVersion:i.version,protocol:location.protocol,quality:"Other",qualityOrigin:"Auto",host:`${this.appId}&${o?.platform??"Unknown"}&${o?.platformVersion??"Unknown"}`,location:`${this.appId}://appView/video/vpe`,title:""}}}setErrorRun(e){const n=e.slice(-2),a=this.translator.error[n]||this.translator.error["01"],r={errorCode:e,errorMessage:a};return this.errorState=r,console.error("ncplayer : ",r),r}getErrorState(){return this.errorState}isPaidTier(){return this.serverConfig.result?.pricing==="pay"}isInitialized(){return!!this.serverConfig.result}getValidatedOptions(e){const n=A(this.serverConfig.result?.options?.options),a={...n,...e??{}};return e?.controlBtn&&(a.controlBtn={...n.controlBtn,...e.controlBtn}),e?.watermarkConfig&&(a.watermarkConfig={...n.watermarkConfig,...e.watermarkConfig}),a.playlist&&!Array.isArray(a.playlist)&&(a.playlist=[{file:a.playlist}]),u=a.playlist||[],a}getPlaylist(){return u||[]}$t(e){const n=e.split(".");let a=this.translator;for(const r of n)if(a&&typeof a=="object"&&r in a)a=a[r];else return e;return typeof a=="string"?a:e}}module.exports=N;
|
|
1
|
+
"use strict";const h={common:{cancel:"Cancel",auto:"Auto",normal:"Normal",notUse:"Not used",prev:"Previous video",next:"Next video",delayText:"seconds until auto-play",license:"License",play:"Play",pause:"Pause",replay:"Replay",fullOn:"Fullscreen",fullOff:"Exit fullscreen",muteOn:"Mute",muteOff:"Unmute",captionOff:"Turn off captions",captionOn:"Turn on captions",setting:"Settings",live:"LIVE",miniPlayer:"Mini player",isMute:"You are muted.",subtitle:"Subtitles",subtitleNot:"Subtitles not available"},settings:{autoplay:"Autoplay",playbackRate:"Playback speed",captions:"Subtitles",quality:"Quality"},error:{"01":{title:"Cannot play video",desc:"Invalid access. Please check your access_key."},"02":{title:"Cannot play video",desc:"You do not have permission to play this video."},"03":{title:"Authentication Failed",desc:"The network connection is unstable."},"04":{title:"Cannot play video",desc:"The video could not be played."},"05":{title:"Cannot play video",desc:"The license is not valid."},"06":{title:"Cannot play video",desc:"Monthly basic API calls exceeded. Please switch to a paid version."},"07":{title:"Cannot play video",desc:"Unsupported format."},"08":{title:"Cannot play video",desc:"Invalid URL format."},"09":{title:"Cannot play video",desc:"The live stream is OFFLINE."},10:{title:"Cannot play video",desc:"Cannot play DASH video on iOS."},11:{title:"Cannot play video",desc:"Invalid DRM token."},12:{title:"Cannot play video",desc:"Failed to communicate with the DRM license server."},13:{title:"Cannot play video",desc:"FairPlay certificate validation failed."},14:{title:"Cannot play video",desc:"Screen capture / screen recording has been detected."},15:{title:"Player Execution Failed",desc:"Required module was not loaded. (hls.js)"},16:{title:"Player Execution Failed",desc:"Required module was not loaded. (dash.js)"}},alternative:{hour:"hour(s)",minute:"minute(s)",second:"second(s)",after:"In a moment",afterMin:"min",afterHour:"hour",afterDay:"day",startPlay:"Video will start in {timeTxt}.",nextPlay:"Next video will play in {timeTxt} seconds.",afterPlay:"Scheduled"}},v={common:{cancel:"취소",auto:"자동",normal:"보통",notUse:"사용안함",prev:"이전 동영상",next:"다음 동영상",delayText:"초 뒤 자동재생",license:"라이선스",play:"재생",pause:"일시정지",replay:"다시보기",fullOn:"전체화면",fullOff:"전체화면 해제",muteOn:"음소거",muteOff:"음소거 해제",captionOff:"자막끄기",captionOn:"자막켜기",setting:"설정",live:"실시간",miniPlayer:"미니플레이어",isMute:"음소거 상태입니다.",subtitle:"자막",subtitleNot:"자막 사용 불가"},settings:{autoplay:"자동재생",playbackRate:"재생 속도",captions:"자막",quality:"해상도"},error:{"01":{title:"동영상을 재생할 수 없음",desc:"잘못된 접근입니다. access_key를 확인해주세요."},"02":{title:"동영상을 재생할 수 없음",desc:"동영상을 재생할 권한이 없습니다."},"03":{title:"인증 실패",desc:"네트워크 연결이 원활하지 않습니다."},"04":{title:"동영상을 재생할 수 없음",desc:"동영상을 재생할 수 없습니다."},"05":{title:"동영상을 재생할 수 없음",desc:"라이선스가 유효하지 않습니다."},"06":{title:"동영상을 재생할 수 없음",desc:"월 기본 제공 호출 건수를 초과하였습니다. 유료 버전으로 전환 후 사용 부탁 드립니다."},"07":{title:"동영상을 재생할 수 없음",desc:"지원하지 않는 형식입니다."},"08":{title:"동영상을 재생할 수 없음",desc:"URL 형식이 잘못되었습니다."},"09":{title:"동영상을 재생할 수 없음",desc:"라이브스트림이 OFFLINE 입니다."},10:{title:"동영상을 재생할 수 없음",desc:"iOS에서 Dash 비디오를 재생할 수 없습니다."},11:{title:"동영상을 재생할 수 없음",desc:"DRM 토큰이 잘못되었습니다."},12:{title:"동영상을 재생할 수 없음",desc:"DRM 라이선스 서버와 통신에 실패하였습니다."},13:{title:"동영상을 재생할 수 없음",desc:"FairPlay 인증서 검증에 실패하였습니다."},14:{title:"동영상을 재생할 수 없음",desc:"화면 캡쳐 / 화면 녹화가 감지되었습니다."},15:{title:"플레이어 실행 실패",desc:"필수 모듈이 로드되지 않았습니다. (hls.js)"},16:{title:"플레이어 실행 실패",desc:"필수 모듈이 로드되지 않았습니다. (dash.js)"}},alternative:{hour:"시",minute:"분",second:"초",after:"잠시 ",afterMin:"분 ",afterHour:"시간 ",afterDay:"일 ",startPlay:"{timeTxt} 후 영상이 시작됩니다.",nextPlay:"{timeTxt}초 후 다음 영상이 재생됩니다.",afterPlay:"예정"}},S={common:{cancel:"キャンセル",auto:"自動",normal:"標準",notUse:"使用しない",prev:"前の動画",next:"次の動画",delayText:"秒後に自動再生",license:"ライセンス",play:"再生",pause:"一時停止",replay:"リプレイ",fullOn:"全画面表示",fullOff:"全画面表示を終了",muteOn:"ミュート",muteOff:"ミュート解除",captionOff:"字幕をオフにする",captionOn:"字幕をオンにする",setting:"設定",live:"ライブ",miniPlayer:"ミニプレーヤー",isMute:"ミュート状態です。",subtitle:"字幕",subtitleNot:"字幕は利用できません"},settings:{autoplay:"自動再生",playbackRate:"再生速度",captions:"字幕",quality:"画質"},error:{"01":{title:"動画を再生できません",desc:"不正なアクセスです。access_keyを確認してください。"},"02":{title:"動画を再生できません",desc:"この動画を再生する権限がありません。"},"03":{title:"認証に失敗しました",desc:"ネットワーク接続が不安定です。"},"04":{title:"動画を再生できません",desc:"動画を再生できませんでした。"},"05":{title:"動画を再生できません",desc:"ライセンスが無効です。"},"06":{title:"動画を再生できません",desc:"月間の基本提供呼び出し回数を超過しました。有料版に切り替えてご利用ください。"},"07":{title:"動画を再生できません",desc:"サポートされていない形式です。"},"08":{title:"動画を再生できません",desc:"URLの形式が正しくありません。"},"09":{title:"動画を再生できません",desc:"ライブストリームはオフラインです。"},10:{title:"動画を再生できません",desc:"iOSではDASHビデオを再生できません。"},11:{title:"動画を再生できません",desc:"DRMトークンが無効です。"},12:{title:"動画を再生できません",desc:"DRMライセンスサーバーとの通信に失敗しました。"},13:{title:"動画を再生できません",desc:"FairPlay証明書の検証に失敗しました。"},14:{title:"動画を再生できません",desc:"画面キャプチャ/画面録画が検出されました。"},15:{title:"プレーヤーの起動に失敗しました",desc:"必須モジュールが読み込まれていません。(hls.js)"},16:{title:"プレーヤーの起動に失敗しました",desc:"必須モジュールが読み込まれていません。(dash.js)"}},alternative:{hour:"時間",minute:"分",second:"秒",after:"しばらくして",afterMin:"分後",afterHour:"時間後",afterDay:"日後",startPlay:"{timeTxt}後に動画が始まります。",nextPlay:"{timeTxt}秒後に次の動画が再生されます。",afterPlay:"予定"}},y={en:h,ko:v,ja:S},b=()=>typeof navigator<"u"&&typeof navigator.language<"u";function M(t){const e=t.split("-")[0];return e in y?e:"en"}function g(t){let e="en";t?e=t:b()&&(e=navigator.language);const a=M(e);return y[a]}g();const C={AF:"Afghanistan",AX:"Åland Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia (Plurinational State of)",BQ:"Bonaire, Sint Eustatius and Saba",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",CV:"Cabo Verde",KH:"Cambodia",CM:"Cameroon",CA:"Canada",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:"China",CX:"Christmas Island",CC:"Cocos (Keeling) Islands",CO:"Colombia",KM:"Comoros",CG:"Congo",CD:"Congo (Democratic Republic of the)",CK:"Cook Islands",CR:"Costa Rica",CI:"Côte d'Ivoire",HR:"Croatia",CU:"Cuba",CW:"Curaçao",CY:"Cyprus",CZ:"Czech Republic",DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:"Gambia",GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GG:"Guernsey",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and McDonald Islands",VA:"Holy See",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran (Islamic Republic of)",IQ:"Iraq",IE:"Ireland",IM:"Isle of Man",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JE:"Jersey",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",KP:"Korea (Democratic People's Republic of)",KR:"Korea, Republic of",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MK:"Macedonia (the former Yugoslav Republic of)",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia (Federated States of)",MD:"Moldova (Republic of)",MC:"Monaco",MN:"Mongolia",ME:"Montenegro",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:"Netherlands",NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:"Palestine, State of",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:"Pitcairn",PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russian Federation",RW:"Rwanda",BL:"Saint Barthélemy",SH:"Saint Helena, Ascension and Tristan da Cunha",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin (French part)",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten (Dutch part)",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:"Taiwan",TJ:"Tajikistan",TZ:"Tanzania, United Republic of",TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States of America",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela (Bolivarian Republic of)",VN:"Viet Nam",VG:"Virgin Islands (British)",VI:"Virgin Islands (U.S.)",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"},I={gov:{prod:{log:"https://papi.vpe.gov-ntruss.com/player/maSync",report:"https://log.vpe.gov-ntruss.com/stats"},beta:{log:"https://papi.beta-vpe.gov-ntruss.com/player/maSync",report:"https://log.beta-vpe.gov-ntruss.com/stats"}},pub:{prod:{log:"https://papi.vpe.naverncp.com/player/maSync",report:"https://log.vpe.naverncp.com/stats"},beta:{log:"https://papi.beta-vpe.naverncp.com/player/maSync",report:"https://log.beta-vpe.naverncp.com/stats"}}};let c={video:{},browser:{},device:{},connection:{},screen:{},player_version:"latest",extra:{sessionId:null,playerType:"VPE React Native"},log_type:"vpe",privacy:{cookie_enabled:!0}},u={platform:"pub",stage:"prod",sync:!1,syncResult:{}};const w=new Date().getTime(),m=()=>{const t=new Date,e=r=>String(r).padStart(2,"0"),a=`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())} ${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}`,n=Math.floor(t.getTime()/1e3),o=new Date().getTime()-w;return{logDate:a,logDateUnix:n,thisSec:o}};function P(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function R(t,e){Object.entries(e).forEach(([a,n])=>{P(n)?(t[a]||(t[a]={}),Object.entries(n).forEach(([o,r])=>{r!=null&&(t[a][o]=r)})):n!=null&&(t[a]=n)})}function T(t){const e=[];return t?.r1&&e.push(t.r1),t?.r2&&e.push(t.r2),t?.r3&&e.push(t.r3),e.join(" ")}function A(t){try{const e=u.syncResult?.geoLocation;e&&(t.address=T(e),t.isp=e.net||"",t.ip=u.syncResult?.ip||"",t.nation=e.country||"")}catch{}}const B=async t=>{if(!t)return;const{platform:e,stage:a}=u,n=I[e][a].log;try{const r=await(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({access_key:t})})).json();u.sync=r.result?.sync||!1,u.syncResult=r.result||{};const{logDate:i,logDateUnix:s}=m();return c.extra.logDate=i,c.extra.logDateUnix=s,u.syncResult?.geoLocation&&A(c.extra),r}catch(o){return console.error("MA config initialization failed:",o),null}};async function N(t,e,a,n,o){u.platform=t,u.stage=e,R(c,a),n&&(c.extra.vpePackageId=n),o&&(c.extra.vpeKey=o),c.extra.nation?c.browser.country=C[c.extra.nation]||"Korea, Republic of":c.browser.country="Korea, Republic of";const{logDate:r,logDateUnix:i}=m();c.extra.logDate=r,c.extra.logDateUnix=i,c.extra.created_at=i}const L=(t={})=>{const e={autostart:!0,muted:!1,aspectRatio:"16/9",objectFit:"contain",controls:!0,keyboardShortcut:!1,startMutedInfoNotVisible:!1,allowsPictureInPicture:!1,staysActiveInBackground:!1,screenRecordingPrevention:!1,modalFullscreen:!1,lang:"ko",ui:"all",controlBtn:{play:!0,fullscreen:!0,progressBar:!0,volume:!1,times:!0,pictureInPicture:!0,setting:!0,subtitle:!0},progressBarColor:"#4299f5",controlActiveTime:3e3,playRateSetting:[.5,.75,1,1.5,2],autoPause:!1,repeat:!1,setStartTime:void 0,playIndex:0,lowLatencyMode:!0,touchGestures:!0,descriptionNotVisible:!1,devTestAppId:void 0,token:"",visibleWatermark:!1,iosFullscreenNativeMode:!0,watermarkText:"NAVER CLOUD PLATFORM",watermarkConfig:{randPosition:!0,randPositionInterVal:3e3,x:10,y:10,opacity:.5},captionStyle:{fontSize:12,color:"#ffffff",backgroundColor:"rgba(0, 0, 0, 0.4)",edgeStyle:"dropshadow"},override:null},a={...e,...t};return t.controlBtn&&(a.controlBtn={...e.controlBtn,...t.controlBtn}),t.watermarkConfig&&(a.watermarkConfig={...e.watermarkConfig,...t.watermarkConfig}),t.captionStyle&&(a.captionStyle={...e.captionStyle,...t.captionStyle}),a.objectFit==="fill"&&(a.objectFit="stretch"),a.controlBtn?.progressBar===void 0&&(a.controlBtn.progressBar=!0),a},E={gov:{prod:{config:"aHR0cHM6Ly9wYXBpLnZwZS5nb3YtbnRydXNzLmNvbS9wbGF5ZXIvY29uZmln",report:"aHR0cHM6Ly9sb2cudnBlLmdvdi1udHJ1c3MuY29tL3N0YXRz"},beta:{config:"aHR0cHM6Ly9wYXBpLmJldGEtdnBlLmdvdi1udHJ1c3MuY29tL3BsYXllci9jb25maWc=",report:"aHR0cHM6Ly9sb2cuYmV0YS12cGUuZ292LW50cnVzcy5jb20vc3RhdHM="}},pub:{prod:{config:"aHR0cHM6Ly9wYXBpLnZwZS5uYXZlcm5jcC5jb20vcGxheWVyL2NvbmZpZw==",report:"aHR0cHM6Ly9sb2cudnBlLm5hdmVybmNwLmNvbS9zdGF0cw=="},beta:{config:"aHR0cHM6Ly9wYXBpLmJldGEtdnBlLm5hdmVybmNwLmNvbS9wbGF5ZXIvY29uZmln",report:"aHR0cHM6Ly9sb2cuYmV0YS12cGUubmF2ZXJuY3AuY29tL3N0YXRz"}}};let f=[];const D=t=>{try{return atob(t)}catch(e){return console.error("Base64 decoding failed:",e),""}};class k{serverConfig={};playerInfo=null;accessKey;appId;platform;stage;isDev;translator;errorState;constructor({accessKey:e,appId:a,platform:n,stage:o,isDev:r=!1,language:i}){this.accessKey=e,this.appId=a||location.origin,this.platform=n,this.stage=o,this.isDev=r,this.translator=g(i),this.errorState={errorCode:null,errorMessage:null}}async initialize(){const e=["accessKey","appId","E0002","E0001","E0003"],a="VPE Player: accessKey 또는 appId가 없어 키 인증을 건너뜁니다.";if([this[e[0]],this[e[1]]].some(r=>!r))return console.warn(a),{error:this.setErrorRun(e[2])};const o=r=>(this.serverConfig=r,this.playerInfo=this.createPlayerInfo(r),this.playerInfo);try{const r=await this.performKeyCheck();if(r.code!==200)return{error:this.setErrorRun(e[3])};const i=o(r);return await N(this.platform,this.stage,i,this.appId,this.accessKey),await B(this.accessKey),{options:this.serverConfig.result?.options,playerInfo:i}}catch(r){return console.error("VPE SDK Initialization failed:",r),{error:this.setErrorRun(e[4])}}}async performKeyCheck(){const e=["?preview=true","config","Content-Type","application/json","access_key","domain","POST"],a=this.isDev?e[0]:"",n=D(E[this.platform][this.stage][e[1]])+a,o=JSON.stringify([e[4],e[5]].reduce((i,s,l)=>(i[s]=[this.accessKey,this.appId][l],i),{})),r=await fetch(n,{method:e[6],headers:{[e[2]]:e[3]},body:o});if(!r.ok)throw new Error(["API","Error:",r.status,r.statusText].join(" "));return r.json()}getBrowserInfo(){const e=navigator.userAgent;return/Edg\/(\d+\.\d+)/.test(e)?{origin:"Edge",version:RegExp.$1}:/Chrome\/(\d+\.\d+)/.test(e)&&!e.includes("Edg")?{origin:"Chrome",version:RegExp.$1}:/Firefox\/(\d+\.\d+)/.test(e)?{origin:"Firefox",version:RegExp.$1}:/Version\/(\d+\.\d+)/.test(e)&&e.includes("Safari")?{origin:"Safari",version:RegExp.$1}:{origin:"Unknown",version:"Unknown"}}createPlayerInfo(e){const[a,n]=e.result.name.split("|"),o=navigator.connection||navigator.mozConnection||navigator.webkitConnection,r=this.getBrowserInfo(),i=navigator.userAgentData;return{cid:e.result.cid,player_name:a,player_version:n,pricing:e.result.pricing,maUse:e.result.options?.maUse==="Y"?"Y":"N",browser:{lang:navigator.language,ua:navigator.userAgent},screen:{width:window.screen.width,height:window.screen.height},connection:{network:o?.effectiveType??"unknown",downlink:o?.downlink??null,rtt:o?.rtt??null,save_data:o?.saveData??!1},device:{platform:i?.platform??"Unknown",mobile:i?.mobile??!1,memory:navigator.deviceMemory??null,processor:navigator.hardwareConcurrency??null},video:{url:""},extra:{vpeKey:this.accessKey,playerType:"VPE",playerVersion:n,device:i?.platform??"Unknown",os:i?.platform??"Unknown",osOrigin:i?.platform??"Unknown",osVersion:i?.platformVersion??"Unknown",vpePackageId:this.appId,actionDuration:0,actionType:"ready",browser:r.origin,browserOrigin:r.origin,browserVersion:r.version,protocol:location.protocol,quality:"Other",qualityOrigin:"Auto",host:`${this.appId}&${i?.platform??"Unknown"}&${i?.platformVersion??"Unknown"}`,location:`${this.appId}://appView/video/vpe`,title:""}}}setErrorRun(e){const a=e.slice(-2),n=this.translator.error[a]||this.translator.error["01"],o={errorCode:e,errorMessage:n};return this.errorState=o,console.error("ncplayer : ",o),o}getErrorState(){return this.errorState}isPaidTier(){return this.serverConfig.result?.pricing==="pay"}isInitialized(){return!!this.serverConfig.result}getValidatedOptions(e){const a=L(this.serverConfig.result?.options?.options),n={...a,...e??{}};return e?.controlBtn&&(n.controlBtn={...a.controlBtn,...e.controlBtn}),e?.watermarkConfig&&(n.watermarkConfig={...a.watermarkConfig,...e.watermarkConfig}),n.playlist&&!Array.isArray(n.playlist)&&(n.playlist=[{file:n.playlist}]),f=n.playlist||[],n}getPlaylist(){return f||[]}$t(e){const a=e.split(".");let n=this.translator;for(const o of a)if(n&&typeof n=="object"&&o in n)n=n[o];else return e;return typeof n=="string"?n:e}async hlsPaser(e){const a=[];if(!e||e.indexOf(".m3u8")===-1)return a;const n=(i,s)=>{try{return new URL(s,i).toString()}catch{return s}},o=i=>{const s=i.match(/RESOLUTION=(\d+)x(\d+)/);if(s)return`${s[2]}p`;const l=i.match(/BANDWIDTH=(\d+)/);return l?`${Math.round(Number(l[1])/1e3)}kbps`:"auto"},r=i=>{const s=i.split(/\r?\n/).map(l=>l.trim()).filter(l=>l.length>0);for(let l=0;l<s.length;l+=1){const p=s[l];if(p.startsWith("#EXT-X-STREAM-INF")){const d=s[l+1];d&&!d.startsWith("#")&&(a.push({quality:o(p),url:n(e,d),levelIndex:a.length}),l+=1)}}};try{const i=await fetch(e);if(!i.ok)return a;const s=await i.text();return s&&r(s),a}catch(i){return console.error("HLS 파싱 실패:",i),a}}}module.exports=k;
|
package/dist/vpe-core-sdk.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const h = {
|
|
2
2
|
common: {
|
|
3
3
|
cancel: "Cancel",
|
|
4
4
|
auto: "Auto",
|
|
@@ -72,7 +72,7 @@ const g = {
|
|
|
72
72
|
nextPlay: "Next video will play in {timeTxt} seconds.",
|
|
73
73
|
afterPlay: "Scheduled"
|
|
74
74
|
}
|
|
75
|
-
},
|
|
75
|
+
}, v = {
|
|
76
76
|
common: {
|
|
77
77
|
cancel: "취소",
|
|
78
78
|
auto: "자동",
|
|
@@ -182,7 +182,7 @@ const g = {
|
|
|
182
182
|
nextPlay: "{timeTxt}초 후 다음 영상이 재생됩니다.",
|
|
183
183
|
afterPlay: "예정"
|
|
184
184
|
}
|
|
185
|
-
},
|
|
185
|
+
}, S = {
|
|
186
186
|
common: {
|
|
187
187
|
cancel: "キャンセル",
|
|
188
188
|
auto: "自動",
|
|
@@ -253,23 +253,23 @@ const g = {
|
|
|
253
253
|
nextPlay: "{timeTxt}秒後に次の動画が再生されます。",
|
|
254
254
|
afterPlay: "予定"
|
|
255
255
|
}
|
|
256
|
-
},
|
|
257
|
-
en:
|
|
258
|
-
ko:
|
|
259
|
-
ja:
|
|
260
|
-
},
|
|
261
|
-
function
|
|
256
|
+
}, y = {
|
|
257
|
+
en: h,
|
|
258
|
+
ko: v,
|
|
259
|
+
ja: S
|
|
260
|
+
}, b = () => typeof navigator < "u" && typeof navigator.language < "u";
|
|
261
|
+
function M(t) {
|
|
262
262
|
const e = t.split("-")[0];
|
|
263
|
-
return e in
|
|
263
|
+
return e in y ? e : "en";
|
|
264
264
|
}
|
|
265
|
-
function
|
|
265
|
+
function g(t) {
|
|
266
266
|
let e = "en";
|
|
267
|
-
t ? e = t :
|
|
268
|
-
const
|
|
269
|
-
return
|
|
267
|
+
t ? e = t : b() && (e = navigator.language);
|
|
268
|
+
const a = M(e);
|
|
269
|
+
return y[a];
|
|
270
270
|
}
|
|
271
|
-
|
|
272
|
-
const
|
|
271
|
+
g();
|
|
272
|
+
const C = {
|
|
273
273
|
AF: "Afghanistan",
|
|
274
274
|
AX: "Åland Islands",
|
|
275
275
|
AL: "Albania",
|
|
@@ -519,7 +519,7 @@ const b = {
|
|
|
519
519
|
YE: "Yemen",
|
|
520
520
|
ZM: "Zambia",
|
|
521
521
|
ZW: "Zimbabwe"
|
|
522
|
-
},
|
|
522
|
+
}, I = {
|
|
523
523
|
gov: {
|
|
524
524
|
prod: {
|
|
525
525
|
log: "https://papi.vpe.gov-ntruss.com/player/maSync",
|
|
@@ -541,7 +541,7 @@ const b = {
|
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
};
|
|
544
|
-
let
|
|
544
|
+
let c = {
|
|
545
545
|
video: {},
|
|
546
546
|
browser: {},
|
|
547
547
|
device: {},
|
|
@@ -556,46 +556,46 @@ let s = {
|
|
|
556
556
|
privacy: {
|
|
557
557
|
cookie_enabled: !0
|
|
558
558
|
}
|
|
559
|
-
},
|
|
559
|
+
}, u = {
|
|
560
560
|
platform: "pub",
|
|
561
561
|
stage: "prod",
|
|
562
562
|
sync: !1,
|
|
563
563
|
syncResult: {}
|
|
564
564
|
};
|
|
565
|
-
const
|
|
566
|
-
const t = /* @__PURE__ */ new Date(), e = (
|
|
565
|
+
const w = (/* @__PURE__ */ new Date()).getTime(), m = () => {
|
|
566
|
+
const t = /* @__PURE__ */ new Date(), e = (r) => String(r).padStart(2, "0"), a = `${t.getFullYear()}-${e(t.getMonth() + 1)}-${e(t.getDate())} ${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}`, n = Math.floor(t.getTime() / 1e3), o = (/* @__PURE__ */ new Date()).getTime() - w;
|
|
567
567
|
return {
|
|
568
|
-
logDate:
|
|
569
|
-
logDateUnix:
|
|
570
|
-
thisSec:
|
|
568
|
+
logDate: a,
|
|
569
|
+
logDateUnix: n,
|
|
570
|
+
thisSec: o
|
|
571
571
|
};
|
|
572
572
|
};
|
|
573
|
-
function
|
|
573
|
+
function P(t) {
|
|
574
574
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
575
575
|
}
|
|
576
|
-
function
|
|
577
|
-
Object.entries(e).forEach(([
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
})) :
|
|
576
|
+
function R(t, e) {
|
|
577
|
+
Object.entries(e).forEach(([a, n]) => {
|
|
578
|
+
P(n) ? (t[a] || (t[a] = {}), Object.entries(n).forEach(([o, r]) => {
|
|
579
|
+
r != null && (t[a][o] = r);
|
|
580
|
+
})) : n != null && (t[a] = n);
|
|
581
581
|
});
|
|
582
582
|
}
|
|
583
|
-
function
|
|
583
|
+
function T(t) {
|
|
584
584
|
const e = [];
|
|
585
585
|
return t?.r1 && e.push(t.r1), t?.r2 && e.push(t.r2), t?.r3 && e.push(t.r3), e.join(" ");
|
|
586
586
|
}
|
|
587
|
-
function
|
|
587
|
+
function A(t) {
|
|
588
588
|
try {
|
|
589
|
-
const e =
|
|
590
|
-
e && (t.address =
|
|
589
|
+
const e = u.syncResult?.geoLocation;
|
|
590
|
+
e && (t.address = T(e), t.isp = e.net || "", t.ip = u.syncResult?.ip || "", t.nation = e.country || "");
|
|
591
591
|
} catch {
|
|
592
592
|
}
|
|
593
593
|
}
|
|
594
|
-
const
|
|
594
|
+
const B = async (t) => {
|
|
595
595
|
if (!t) return;
|
|
596
|
-
const { platform: e, stage:
|
|
596
|
+
const { platform: e, stage: a } = u, n = I[e][a].log;
|
|
597
597
|
try {
|
|
598
|
-
const
|
|
598
|
+
const r = await (await fetch(n, {
|
|
599
599
|
method: "POST",
|
|
600
600
|
headers: {
|
|
601
601
|
"Content-Type": "application/json"
|
|
@@ -604,19 +604,19 @@ const T = async (t) => {
|
|
|
604
604
|
access_key: t
|
|
605
605
|
})
|
|
606
606
|
})).json();
|
|
607
|
-
|
|
608
|
-
const { logDate:
|
|
609
|
-
return
|
|
610
|
-
} catch (
|
|
611
|
-
return console.error("MA config initialization failed:",
|
|
607
|
+
u.sync = r.result?.sync || !1, u.syncResult = r.result || {};
|
|
608
|
+
const { logDate: i, logDateUnix: s } = m();
|
|
609
|
+
return c.extra.logDate = i, c.extra.logDateUnix = s, u.syncResult?.geoLocation && A(c.extra), r;
|
|
610
|
+
} catch (o) {
|
|
611
|
+
return console.error("MA config initialization failed:", o), null;
|
|
612
612
|
}
|
|
613
613
|
};
|
|
614
|
-
async function
|
|
615
|
-
|
|
616
|
-
const { logDate:
|
|
617
|
-
|
|
614
|
+
async function N(t, e, a, n, o) {
|
|
615
|
+
u.platform = t, u.stage = e, R(c, a), n && (c.extra.vpePackageId = n), o && (c.extra.vpeKey = o), c.extra.nation ? c.browser.country = C[c.extra.nation] || "Korea, Republic of" : c.browser.country = "Korea, Republic of";
|
|
616
|
+
const { logDate: r, logDateUnix: i } = m();
|
|
617
|
+
c.extra.logDate = r, c.extra.logDateUnix = i, c.extra.created_at = i;
|
|
618
618
|
}
|
|
619
|
-
const
|
|
619
|
+
const L = (t = {}) => {
|
|
620
620
|
const e = {
|
|
621
621
|
autostart: !0,
|
|
622
622
|
muted: !1,
|
|
@@ -654,6 +654,7 @@ const A = (t = {}) => {
|
|
|
654
654
|
devTestAppId: void 0,
|
|
655
655
|
token: "",
|
|
656
656
|
visibleWatermark: !1,
|
|
657
|
+
iosFullscreenNativeMode: !0,
|
|
657
658
|
watermarkText: "NAVER CLOUD PLATFORM",
|
|
658
659
|
watermarkConfig: {
|
|
659
660
|
randPosition: !0,
|
|
@@ -669,18 +670,18 @@ const A = (t = {}) => {
|
|
|
669
670
|
edgeStyle: "dropshadow"
|
|
670
671
|
},
|
|
671
672
|
override: null
|
|
672
|
-
},
|
|
673
|
-
return t.controlBtn && (
|
|
673
|
+
}, a = { ...e, ...t };
|
|
674
|
+
return t.controlBtn && (a.controlBtn = {
|
|
674
675
|
...e.controlBtn,
|
|
675
676
|
...t.controlBtn
|
|
676
|
-
}), t.watermarkConfig && (
|
|
677
|
+
}), t.watermarkConfig && (a.watermarkConfig = {
|
|
677
678
|
...e.watermarkConfig,
|
|
678
679
|
...t.watermarkConfig
|
|
679
|
-
}), t.captionStyle && (
|
|
680
|
+
}), t.captionStyle && (a.captionStyle = {
|
|
680
681
|
...e.captionStyle,
|
|
681
682
|
...t.captionStyle
|
|
682
|
-
}),
|
|
683
|
-
},
|
|
683
|
+
}), a.objectFit === "fill" && (a.objectFit = "stretch"), a.controlBtn?.progressBar === void 0 && (a.controlBtn.progressBar = !0), a;
|
|
684
|
+
}, E = {
|
|
684
685
|
gov: {
|
|
685
686
|
prod: {
|
|
686
687
|
config: "aHR0cHM6Ly9wYXBpLnZwZS5nb3YtbnRydXNzLmNvbS9wbGF5ZXIvY29uZmln",
|
|
@@ -702,15 +703,15 @@ const A = (t = {}) => {
|
|
|
702
703
|
}
|
|
703
704
|
}
|
|
704
705
|
};
|
|
705
|
-
let
|
|
706
|
-
const
|
|
706
|
+
let f = [];
|
|
707
|
+
const D = (t) => {
|
|
707
708
|
try {
|
|
708
709
|
return atob(t);
|
|
709
710
|
} catch (e) {
|
|
710
711
|
return console.error("Base64 decoding failed:", e), "";
|
|
711
712
|
}
|
|
712
713
|
};
|
|
713
|
-
class
|
|
714
|
+
class k {
|
|
714
715
|
serverConfig = {};
|
|
715
716
|
playerInfo = null;
|
|
716
717
|
accessKey;
|
|
@@ -721,43 +722,43 @@ class N {
|
|
|
721
722
|
translator;
|
|
722
723
|
errorState;
|
|
723
724
|
// SDK 초기화에 필요한 기본 옵션을 보관한다.
|
|
724
|
-
constructor({ accessKey: e, appId:
|
|
725
|
-
this.accessKey = e, this.appId =
|
|
725
|
+
constructor({ accessKey: e, appId: a, platform: n, stage: o, isDev: r = !1, language: i }) {
|
|
726
|
+
this.accessKey = e, this.appId = a || location.origin, this.platform = n, this.stage = o, this.isDev = r, this.translator = g(i), this.errorState = {
|
|
726
727
|
errorCode: null,
|
|
727
728
|
errorMessage: null
|
|
728
729
|
};
|
|
729
730
|
}
|
|
730
731
|
// 인증 키를 확인하고 서버 설정 및 MA를 초기화한다.
|
|
731
732
|
async initialize() {
|
|
732
|
-
const e = ["accessKey", "appId", "E0002", "E0001", "E0003"],
|
|
733
|
-
if ([this[e[0]], this[e[1]]].some((
|
|
734
|
-
return console.warn(
|
|
735
|
-
const
|
|
733
|
+
const e = ["accessKey", "appId", "E0002", "E0001", "E0003"], a = "VPE Player: accessKey 또는 appId가 없어 키 인증을 건너뜁니다.";
|
|
734
|
+
if ([this[e[0]], this[e[1]]].some((r) => !r))
|
|
735
|
+
return console.warn(a), { error: this.setErrorRun(e[2]) };
|
|
736
|
+
const o = (r) => (this.serverConfig = r, this.playerInfo = this.createPlayerInfo(r), this.playerInfo);
|
|
736
737
|
try {
|
|
737
|
-
const
|
|
738
|
-
if (
|
|
738
|
+
const r = await this.performKeyCheck();
|
|
739
|
+
if (r.code !== 200)
|
|
739
740
|
return { error: this.setErrorRun(e[3]) };
|
|
740
|
-
const
|
|
741
|
-
return await
|
|
741
|
+
const i = o(r);
|
|
742
|
+
return await N(this.platform, this.stage, i, this.appId, this.accessKey), await B(this.accessKey), {
|
|
742
743
|
options: this.serverConfig.result?.options,
|
|
743
|
-
playerInfo:
|
|
744
|
+
playerInfo: i
|
|
744
745
|
};
|
|
745
|
-
} catch (
|
|
746
|
-
return console.error("VPE SDK Initialization failed:",
|
|
746
|
+
} catch (r) {
|
|
747
|
+
return console.error("VPE SDK Initialization failed:", r), { error: this.setErrorRun(e[4]) };
|
|
747
748
|
}
|
|
748
749
|
}
|
|
749
750
|
// AccessKey 유효성을 검사하기 위해 서버에 구성 정보를 요청한다.
|
|
750
751
|
async performKeyCheck() {
|
|
751
|
-
const e = ["?preview=true", "config", "Content-Type", "application/json", "access_key", "domain", "POST"],
|
|
752
|
-
[e[4], e[5]].reduce((
|
|
753
|
-
),
|
|
752
|
+
const e = ["?preview=true", "config", "Content-Type", "application/json", "access_key", "domain", "POST"], a = this.isDev ? e[0] : "", n = D(E[this.platform][this.stage][e[1]]) + a, o = JSON.stringify(
|
|
753
|
+
[e[4], e[5]].reduce((i, s, l) => (i[s] = [this.accessKey, this.appId][l], i), {})
|
|
754
|
+
), r = await fetch(n, {
|
|
754
755
|
method: e[6],
|
|
755
756
|
headers: { [e[2]]: e[3] },
|
|
756
|
-
body:
|
|
757
|
+
body: o
|
|
757
758
|
});
|
|
758
|
-
if (!
|
|
759
|
-
throw new Error(["API", "Error:",
|
|
760
|
-
return
|
|
759
|
+
if (!r.ok)
|
|
760
|
+
throw new Error(["API", "Error:", r.status, r.statusText].join(" "));
|
|
761
|
+
return r.json();
|
|
761
762
|
}
|
|
762
763
|
// 브라우저 UA 문자열을 파싱해 종류와 버전을 반환한다.
|
|
763
764
|
getBrowserInfo() {
|
|
@@ -766,11 +767,11 @@ class N {
|
|
|
766
767
|
}
|
|
767
768
|
// 서버에서 받은 정보와 클라이언트 환경을 합쳐 PlayerInfo를 구성한다.
|
|
768
769
|
createPlayerInfo(e) {
|
|
769
|
-
const [
|
|
770
|
+
const [a, n] = e.result.name.split("|"), o = navigator.connection || navigator.mozConnection || navigator.webkitConnection, r = this.getBrowserInfo(), i = navigator.userAgentData;
|
|
770
771
|
return {
|
|
771
772
|
cid: e.result.cid,
|
|
772
|
-
player_name:
|
|
773
|
-
player_version:
|
|
773
|
+
player_name: a,
|
|
774
|
+
player_version: n,
|
|
774
775
|
pricing: e.result.pricing,
|
|
775
776
|
maUse: e.result.options?.maUse === "Y" ? "Y" : "N",
|
|
776
777
|
browser: {
|
|
@@ -782,14 +783,14 @@ class N {
|
|
|
782
783
|
height: window.screen.height
|
|
783
784
|
},
|
|
784
785
|
connection: {
|
|
785
|
-
network:
|
|
786
|
-
downlink:
|
|
787
|
-
rtt:
|
|
788
|
-
save_data:
|
|
786
|
+
network: o?.effectiveType ?? "unknown",
|
|
787
|
+
downlink: o?.downlink ?? null,
|
|
788
|
+
rtt: o?.rtt ?? null,
|
|
789
|
+
save_data: o?.saveData ?? !1
|
|
789
790
|
},
|
|
790
791
|
device: {
|
|
791
|
-
platform:
|
|
792
|
-
mobile:
|
|
792
|
+
platform: i?.platform ?? "Unknown",
|
|
793
|
+
mobile: i?.mobile ?? !1,
|
|
793
794
|
memory: navigator.deviceMemory ?? null,
|
|
794
795
|
processor: navigator.hardwareConcurrency ?? null
|
|
795
796
|
},
|
|
@@ -797,21 +798,21 @@ class N {
|
|
|
797
798
|
extra: {
|
|
798
799
|
vpeKey: this.accessKey,
|
|
799
800
|
playerType: "VPE",
|
|
800
|
-
playerVersion:
|
|
801
|
-
device:
|
|
802
|
-
os:
|
|
803
|
-
osOrigin:
|
|
804
|
-
osVersion:
|
|
801
|
+
playerVersion: n,
|
|
802
|
+
device: i?.platform ?? "Unknown",
|
|
803
|
+
os: i?.platform ?? "Unknown",
|
|
804
|
+
osOrigin: i?.platform ?? "Unknown",
|
|
805
|
+
osVersion: i?.platformVersion ?? "Unknown",
|
|
805
806
|
vpePackageId: this.appId,
|
|
806
807
|
actionDuration: 0,
|
|
807
808
|
actionType: "ready",
|
|
808
|
-
browser:
|
|
809
|
-
browserOrigin:
|
|
810
|
-
browserVersion:
|
|
809
|
+
browser: r.origin,
|
|
810
|
+
browserOrigin: r.origin,
|
|
811
|
+
browserVersion: r.version,
|
|
811
812
|
protocol: location.protocol,
|
|
812
813
|
quality: "Other",
|
|
813
814
|
qualityOrigin: "Auto",
|
|
814
|
-
host: `${this.appId}&${
|
|
815
|
+
host: `${this.appId}&${i?.platform ?? "Unknown"}&${i?.platformVersion ?? "Unknown"}`,
|
|
815
816
|
location: `${this.appId}://appView/video/vpe`,
|
|
816
817
|
title: ""
|
|
817
818
|
}
|
|
@@ -819,11 +820,11 @@ class N {
|
|
|
819
820
|
}
|
|
820
821
|
// 에러 코드를 번역하고 공통 포맷으로 반환한다.
|
|
821
822
|
setErrorRun(e) {
|
|
822
|
-
const
|
|
823
|
+
const a = e.slice(-2), n = this.translator.error[a] || this.translator.error["01"], o = {
|
|
823
824
|
errorCode: e,
|
|
824
|
-
errorMessage:
|
|
825
|
+
errorMessage: n
|
|
825
826
|
};
|
|
826
|
-
return this.errorState =
|
|
827
|
+
return this.errorState = o, console.error("ncplayer : ", o), o;
|
|
827
828
|
}
|
|
828
829
|
// 마지막 에러 상태를 반환한다.
|
|
829
830
|
getErrorState() {
|
|
@@ -839,12 +840,12 @@ class N {
|
|
|
839
840
|
}
|
|
840
841
|
// 서버 옵션과 전달된 옵션을 병합해 유효한 플레이어 옵션을 생성한다.
|
|
841
842
|
getValidatedOptions(e) {
|
|
842
|
-
const
|
|
843
|
-
return e?.controlBtn && (
|
|
843
|
+
const a = L(this.serverConfig.result?.options?.options), n = { ...a, ...e ?? {} };
|
|
844
|
+
return e?.controlBtn && (n.controlBtn = { ...a.controlBtn, ...e.controlBtn }), e?.watermarkConfig && (n.watermarkConfig = { ...a.watermarkConfig, ...e.watermarkConfig }), n.playlist && !Array.isArray(n.playlist) && (n.playlist = [{ file: n.playlist }]), f = n.playlist || [], n;
|
|
844
845
|
}
|
|
845
846
|
// 정규화된 플레이리스트를 반환한다.
|
|
846
847
|
getPlaylist() {
|
|
847
|
-
return
|
|
848
|
+
return f || [];
|
|
848
849
|
}
|
|
849
850
|
/**
|
|
850
851
|
*
|
|
@@ -852,16 +853,56 @@ class N {
|
|
|
852
853
|
*/
|
|
853
854
|
// 다국어 키를 점 표기법으로 찾아 문자열을 반환한다.
|
|
854
855
|
$t(e) {
|
|
855
|
-
const
|
|
856
|
-
let
|
|
857
|
-
for (const
|
|
858
|
-
if (
|
|
859
|
-
|
|
856
|
+
const a = e.split(".");
|
|
857
|
+
let n = this.translator;
|
|
858
|
+
for (const o of a)
|
|
859
|
+
if (n && typeof n == "object" && o in n)
|
|
860
|
+
n = n[o];
|
|
860
861
|
else
|
|
861
862
|
return e;
|
|
862
|
-
return typeof
|
|
863
|
+
return typeof n == "string" ? n : e;
|
|
864
|
+
}
|
|
865
|
+
async hlsPaser(e) {
|
|
866
|
+
const a = [];
|
|
867
|
+
if (!e || e.indexOf(".m3u8") === -1)
|
|
868
|
+
return a;
|
|
869
|
+
const n = (i, s) => {
|
|
870
|
+
try {
|
|
871
|
+
return new URL(s, i).toString();
|
|
872
|
+
} catch {
|
|
873
|
+
return s;
|
|
874
|
+
}
|
|
875
|
+
}, o = (i) => {
|
|
876
|
+
const s = i.match(/RESOLUTION=(\d+)x(\d+)/);
|
|
877
|
+
if (s)
|
|
878
|
+
return `${s[2]}p`;
|
|
879
|
+
const l = i.match(/BANDWIDTH=(\d+)/);
|
|
880
|
+
return l ? `${Math.round(Number(l[1]) / 1e3)}kbps` : "auto";
|
|
881
|
+
}, r = (i) => {
|
|
882
|
+
const s = i.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
|
|
883
|
+
for (let l = 0; l < s.length; l += 1) {
|
|
884
|
+
const p = s[l];
|
|
885
|
+
if (p.startsWith("#EXT-X-STREAM-INF")) {
|
|
886
|
+
const d = s[l + 1];
|
|
887
|
+
d && !d.startsWith("#") && (a.push({
|
|
888
|
+
quality: o(p),
|
|
889
|
+
url: n(e, d),
|
|
890
|
+
levelIndex: a.length
|
|
891
|
+
}), l += 1);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
try {
|
|
896
|
+
const i = await fetch(e);
|
|
897
|
+
if (!i.ok)
|
|
898
|
+
return a;
|
|
899
|
+
const s = await i.text();
|
|
900
|
+
return s && r(s), a;
|
|
901
|
+
} catch (i) {
|
|
902
|
+
return console.error("HLS 파싱 실패:", i), a;
|
|
903
|
+
}
|
|
863
904
|
}
|
|
864
905
|
}
|
|
865
906
|
export {
|
|
866
|
-
|
|
907
|
+
k as default
|
|
867
908
|
};
|