JLChen
2021-11-30 efad979b6fae76fb37a4de7e94e6bac0a85cb72c
HDL-ON_Android/LeChengVideoActivity.cs
@@ -31,7 +31,9 @@
    {
        private static LeChengVideoActivity CurtActivity;
        //
        private string URL = "openapi.easy4ip.com:443";
        private string URL = "openapi.easy4ip.com:443"; //海外(正式)
        private static string URL_LC_CHINA = "openapi.lechange.cn:443"; //中国大陆(正式)
        private static string URL_LC_Overseas = "openapi.easy4ip.com:443"; //中国大陆(正式)
        public string AccessToken = "";
        public string DeviceId = "";
        public string Psk = "";
@@ -112,8 +114,7 @@
            mPlayWindow = new LCOpenSDK_PlayWindow();
            mPlayWindow.InitPlayWindow(this, flWindowContent, 0, true);
            if (Location == 1)
                URL = "openapi.easy4ip.com:443";
        }
        /// <summary>
@@ -121,6 +122,14 @@
        /// </summary>
        private void InitLCSDK()
        {
            if (Location == 1)
            {
                URL = URL_LC_Overseas;
            }else {
                URL = URL_LC_CHINA;
            }
            InitParams initParams = new InitParams(this, URL, AccessToken);
            LCOpenSDK_Api.InitOpenApi(initParams);
        }
@@ -133,6 +142,8 @@
            try
            {
                LCOpenSDK_ParamReal paramReal = new LCOpenSDK_ParamReal(AccessToken, DeviceId, 0, Psk, PlayToken, 1, false, true);
                //PlayEventListener listener = new PlayEventListener();//实现播放事件监听回调 2021-10-15 目前不能监听,监听了会空异常
                //mPlayWindow.WindowListener = listener;//实现播放事件监听回调
                mPlayWindow.PlayRtspReal(paramReal);
            }
            catch (System.Exception e)
@@ -147,6 +158,7 @@
        public void Stop()
        {
            mPlayWindow.StopRtspReal(true);//关闭视频
            //mPlayWindow.WindowListener = null;
        }
        /// <summary>
@@ -156,8 +168,14 @@
        {
            CloseAudio();// 关闭Audio
            LCOpenSDK_Talk.Listener = new AudioTalkerListener();//设置对讲监听
            //2021-10-29 对讲请求类型,call呼叫,如果不传,默认为talk
            string talkType = "talk";
            if (Type == 1)//0监控,1对讲
            {
                talkType = "call";
            }
            // 对讲参数
            LCOpenSDK_ParamTalk paramTalk = new LCOpenSDK_ParamTalk(AccessToken, DeviceId, -1, Psk, PlayToken, true);
            LCOpenSDK_ParamTalk paramTalk = new LCOpenSDK_ParamTalk(AccessToken, DeviceId, -1, Psk, PlayToken, true, talkType);
            LCOpenSDK_Talk.PlayTalk(paramTalk);
        }
@@ -348,6 +366,7 @@
                try
                {
                    System.Console.WriteLine("LC OnTalkResult error:" + error + "  type:" + type);
                    bool talkResult = false;
                    if (type == 99 || error.Equals("-1000") || error.Equals("0") || error.Equals("1") || error.Equals("3"))
                    {
@@ -397,5 +416,19 @@
            }
        }
        /// <summary>
        /// 播放、预览结果回调
        /// resultSource:  0--RTSP  1--HLS  5--DHHTTP  99--OPENAPI
        /// </summary>
        class PlayEventListener : LCOpenSDK_EventListener
        {
            public override void OnPlayerResult(int index, string code, int resultSource)
            {
                base.OnPlayerResult(index, code, resultSource);
                System.Console.WriteLine("LC OnPlayerResult index:" + index + "  code:" + code + "  resultSource:"+ resultSource);
            }
        }
    }
}