From efad979b6fae76fb37a4de7e94e6bac0a85cb72c Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期二, 30 十一月 2021 13:14:28 +0800
Subject: [PATCH] 2021-11-30 1.修复乐橙Android,没调用拒接接口问题。

---
 HDL-ON_Android/LeChengVideoActivity.cs |  140 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 135 insertions(+), 5 deletions(-)

diff --git a/HDL-ON_Android/LeChengVideoActivity.cs b/HDL-ON_Android/LeChengVideoActivity.cs
index 9020958..1d26881 100644
--- a/HDL-ON_Android/LeChengVideoActivity.cs
+++ b/HDL-ON_Android/LeChengVideoActivity.cs
@@ -21,6 +21,7 @@
 using Com.Lechange.Opensdk.Media;
 using HDL_ON.DAL.Server;
 using HDL_ON_Android.LeChengView.Form;
+using Java.IO;
 using Java.Lang;
 
 namespace HDL_ON_Android
@@ -30,13 +31,17 @@
     {
         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"; //涓浗澶ч檰(姝e紡)
+        private static string URL_LC_Overseas = "openapi.easy4ip.com:443"; //涓浗澶ч檰(姝e紡)
         public string AccessToken = "";
         public string DeviceId = "";
         public string Psk = "";
         public string PlayToken = "";//鎾斁playToken
         public string CallId = "";//鍛煎彨Id
         private int Type = 0;//0鐩戞帶锛�1瀵硅
+        private string DeviceName = "";// 澶囨敞
+
         /// <summary>
         /// 0:鍥藉唴锛�1娴峰
         /// </summary>
@@ -65,6 +70,7 @@
             Type = Intent.GetIntExtra("Type", 0);//0鐩戞帶锛�1瀵硅//1
             Location = Intent.GetIntExtra("Location", 0);//1
             CallId = Intent.GetStringExtra("callId");//1384766990812426242
+            DeviceName = Intent.GetStringExtra("DeviceName");
 
             InitLCSDK();
 
@@ -95,7 +101,7 @@
             ivBack = (ImageView)FindViewById(Resource.Id.videoBackImg);
             tvName = (TextView)FindViewById(Resource.Id.nameText);
 
-            tvName.SetText("DeviceName", null);
+            tvName.SetText(DeviceName, null);
             ivBack.SetOnClickListener(this);
 
         }
@@ -108,8 +114,7 @@
             mPlayWindow = new LCOpenSDK_PlayWindow();
             mPlayWindow.InitPlayWindow(this, flWindowContent, 0, true);
 
-            if (Location == 1)
-                URL = "openapi.easy4ip.com:443";
+           
         }
 
         /// <summary>
@@ -117,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);
         }
@@ -129,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)
@@ -143,6 +158,7 @@
         public void Stop()
         {
             mPlayWindow.StopRtspReal(true);//鍏抽棴瑙嗛
+            //mPlayWindow.WindowListener = null;
         }
 
         /// <summary>
@@ -152,8 +168,14 @@
         {
             CloseAudio();// 鍏抽棴Audio
             LCOpenSDK_Talk.Listener = new AudioTalkerListener();//璁剧疆瀵硅鐩戝惉
+            //2021-10-29 瀵硅璇锋眰绫诲瀷锛宑all鍛煎彨锛屽鏋滀笉浼狅紝榛樿涓簍alk
+            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);
         }
 
@@ -182,6 +204,99 @@
         public bool CloseAudio()
         {
             return mPlayWindow.StopAudio() == 0;
+        }
+
+        /// <summary>
+        /// 寮�閿�
+        /// </summary>
+        public void Unlock()
+        {
+            //
+            Dictionary<string, object> dic = new Dictionary<string, object>();
+            dic.Add("deviceId", this.DeviceId);
+            dic.Add("callId", this.CallId);
+
+            var requestJson = HttpUtil.GetSignRequestJson(dic);
+            var revertObj = HttpUtil.RequestHttpsPostFroHome("/home-wisdom/platform/imou/openDoorbell", requestJson);
+            if (revertObj.Code == StateCode.SUCCESS)
+            {
+                Toast.MakeText(this, Resources.GetString(Resource.String.unlock_success), ToastLength.Short).Show();
+            }
+            else
+            {
+                Toast.MakeText(this, Resources.GetString(Resource.String.unlock_fail), ToastLength.Short).Show();
+            }
+        }
+
+        ///// <summary>
+        ///// 鍙戦�佸箍鎾紝閫氱煡鍒锋柊鍥惧簱鐨勬樉绀�
+        ///// </summary>
+        ///// <param name="path"></param>
+        //void SendBroadcastScanFile(Context context, string path)
+        //{
+        //    // 鍙戦�佸箍鎾紝閫氱煡鍒锋柊鍥惧簱鐨勬樉绀�
+        //    Intent scanIntent = new Intent(Intent.ActionMediaScannerScanFile);
+        //    scanIntent.SetData(Android.Net.Uri.FromFile(new File(path)));
+        //    context.SendBroadcast(scanIntent);
+        //}
+
+        /// <summary>
+        /// 鎴浘
+        /// </summary>
+        /// <param name="path"></param>
+        public void SnapShot(string path)
+        {
+            try
+            {
+                int code = mPlayWindow.SnapShot(path);
+                if (code == 0)
+                {
+                    //2021-09-01 澧炲姞鍙戦�佸箍鎾紝閫氱煡鍒锋柊鍥惧簱鐨勬樉绀�
+                    HDLONUtils.SendBroadcastScanFile(this, path);
+
+                    //Android.Provider.MediaStore.Images.Media.InsertImage(this.getContentResolver(), path, "ss", "ss");
+                    Toast.MakeText(this, Resources.GetString(Resource.String.screenshot_success), ToastLength.Short).Show();
+                }
+                else
+                {
+                    Toast.MakeText(this, Resources.GetString(Resource.String.screenshot_fail), ToastLength.Short).Show();
+                }
+            }
+            catch (System.Exception e)
+            {
+                string error = e.Message;
+            }
+            
+            //杩愯鍒拌繖锛宲hotoFile宸茬粡瀛樺湪锛岃繖閲岄渶瑕佽幏寰楄繖涓枃浠剁殑uri
+            //* 鍒嗕袱绉嶆儏鍐碉紝android7.0浠ヤ笂鍜屼互涓�
+            // 鍏堝瓨鍏ヤ复鏃剁洰褰曪紝鐒跺悗鍐嶇Щ鍔ㄥ埌鐩稿唽鐩綍涓�
+            //File photoFile = new File(path);
+            //Android.Net.Uri photoUri;
+
+            //if (Build.VERSION.SdkInt >= 24)
+            //if (Build.VERSION.PreviewSdkInt >= 24)
+            //{
+
+            //    /**
+            //     * FileProvider.getUriForFile(),杩欎釜鏂规硶涓渶瑕佸~鍐欎笁涓弬鏁帮紝
+            //     * 绗竴涓狢ontext锛�
+            //     * 绗簩涓猄
+            //     * tring 浠绘剰
+            //     * 绗笁涓狥ile
+            //     */
+            //    photoUri = FileProvider.GetUriForFile(this, "HDL Video SnapShot", photoFile);
+
+            //}
+            //else
+            //{
+            //    photoUri = Android.Net.Uri.FromFile(photoFile);
+            //}
+    
+        }
+
+        private ContentResolver getContentResolver()
+        {
+            throw new NotImplementedException();
         }
 
         /// <summary>
@@ -251,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"))
                     {
@@ -300,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);
+            }
+
+           
+        }
     }
 }

--
Gitblit v1.8.0