<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="/js/HiVeWebRtcPlayer/webrtcadapter.js"></script>
<script src="/js/HiVeWebRtcPlayer/HiVeWebRtcPlayer.js"></script>
<div class="map_popup_cctv">
    <dl>
        <dt>
            <p class="lctn_nm">${cctv.istl_lctn_nm}</p>
            <p class="fr black restTime">남은 재생시간 : <span id="restTime">30</span>&nbsp;초&nbsp;</p>
            <a href="javascript:cctvClose('${cctv.cctv_mngm_nmbr}')" id="cctvClose" title="CCTV영상닫기"><img src="/images/cctv/xbtn.png" alt="CCTV영상닫기"/></a>
        </dt>
        <dl>
            <p align="center">
                <video id="11" width="300" height="240" autoplay playsinline muted></video>
<%--                <video id="video" class="video-js" preload="auto" width="300" height="240" muted="mute" autoplay></video>--%>
            </p>
        </dl>
    </dl>
</div>
<div id="dialog" class="selector ui-dialog-content ui-widget-content" style="width: auto; min-height: 0px; height: 116px; display:none;">
</div>
<script type="text/javascript">
    <%--let strm_http_addr = "${cctv.strm_http_addr}";--%>
    <%--openCCTV(strm_http_addr);--%>

    let WEB_RTC_SVR_IP = "${cctv.WEB_RTC_SVR_IP}";
    let WEB_RTC_SVR_PORT = "${cctv.WEB_RTC_SVR_PORT}";
    let WEB_RTC_ID = "${cctv.WEB_RTC_ID}";
	
	const cctvArr = window.opener.getCctvArr();
	let cctvObj;
	cctvArr.map((item)=>{
		if (item.cctv_mngm_nmbr === ${cctv.cctv_mngm_nmbr}) {
			cctvObj = item;
		}
	})
  	$(window).bind('beforeunload', ()=>{
        if (cctvObj) {
        	cctvObj.cctvMarker.setImage(cctvObj.normalImage);
        	cctvObj.click = false;
        }
    })
    var webrtcPlayer1 = new HiVeWebRtcPlayer("11", WEB_RTC_SVR_IP, WEB_RTC_SVR_PORT, WEB_RTC_ID);
    openCCTV();
	function getOpenerCctvNmber(){
		return ${cctv.cctv_mngm_nmbr};
	}
</script>
