Ejemplo n.º 1
0
        public virtual void SetupVideo(Guid id)
        {
            global::Android.App.Application.SynchronizationContext.Post(_ =>
            {
                AgoraVideoViewHolder <FrameLayout> container = _containers.FirstOrDefault(a => a.GUID == id);
                if (container == null)
                {
                    return;
                }

                SurfaceView layout = RtcEngine.CreateRendererView(container.NativeView.Context);
                layout.SetZOrderMediaOverlay(true);
                container.NativeView.AddView(layout);
                VideoCanvas canvas            = new VideoCanvas(layout, (int)container.VideoView.Mode, (int)container.StreamUID);
                container.VideoView.IsOffline = false;
                if (container.StreamUID == 0 || container.StreamUID == _myId)
                {
                    _agoraEngine?.SetupLocalVideo(canvas);
                    _agoraEngine?.StartPreview();
                }
                else
                {
                    _agoraEngine?.SetupRemoteVideo(canvas);
                }
                container.NativeView.Visibility = ViewStates.Visible;
            }, null);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Setups the video.
 /// </summary>
 /// <param name="uid">Uid.</param>
 public virtual void SetupVideo(uint uid)
 {
     global::Android.App.Application.SynchronizationContext.Post(_ =>
     {
         AgoraVideoViewHolder <FrameLayout>[] containers = _containers.Where(a => a.StreamUID == uid).ToArray();
         if (containers.Length == 0)
         {
             return;
         }
         containers.ToList().ForEach(container => {
             SurfaceView layout = RtcEngine.CreateRendererView(container.NativeView.Context);
             layout.SetZOrderMediaOverlay(true);
             container.NativeView.AddView(layout);
             VideoCanvas canvas            = new VideoCanvas(layout, (int)container.VideoView.Mode, (int)uid);
             container.VideoView.IsOffline = false;
             if (_agoraEngine != null)
             {
                 if (uid == 0 || uid == _myId)
                 {
                     _agoraEngine.SetupLocalVideo(canvas);
                     _agoraEngine.StartPreview();
                 }
                 else
                 {
                     _agoraEngine.SetupRemoteVideo(canvas);
                 }
             }
             container.NativeView.Visibility = ViewStates.Visible;
         });
     }, null);
 }
Ejemplo n.º 3
0
        private void SetupLocalVideo()
        {
            FrameLayout container   = (FrameLayout)FindViewById(Resource.Id.local_video_view_container);
            SurfaceView surfaceView = RtcEngine.CreateRendererView(BaseContext);

            surfaceView.SetZOrderMediaOverlay(true);
            container.AddView(surfaceView);
            _rtcEngine.SetupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RenderModeAdaptive, 0));
        }
Ejemplo n.º 4
0
        public Preview(Context context, SurfaceView sv) : base(context)
        {
            mSurfaceView = sv;
            //        addView(mSurfaceView);

            mHolder = mSurfaceView.Holder;
            mHolder.AddCallback(this);
            mHolder.SetType(SurfaceType.PushBuffers);
            //mSurfaceView.setZOrderOnTop(true);
            mSurfaceView.SetZOrderMediaOverlay(true);
            SetBackgroundColor(Color.Transparent);
        }
Ejemplo n.º 5
0
        private void SetupLocalVideo()
        {
            FrameLayout container = (FrameLayout)FindViewById(Resource.Id.local_video_view_container);

            _localVideoView = RtcEngine.CreateRendererView(BaseContext);
            _localVideoView.SetZOrderMediaOverlay(true);
            container.AddView(_localVideoView);
            AgoraEngine.SetupLocalVideo(new VideoCanvas(_localVideoView, VideoCanvas.RenderModeAdaptive, 0));
            if (!string.IsNullOrEmpty(AgoraSettings.Current.EncryptionPhrase))
            {
                AgoraEngine.SetEncryptionMode(AgoraSettings.Current.EncryptionType.GetModeString());
                AgoraEngine.SetEncryptionSecret(AgoraSettings.Current.EncryptionPhrase);
            }
            AgoraEngine.StartPreview();
        }
Ejemplo n.º 6
0
 private void SetupLocalVideo()
 {
     try
     {
         FrameLayout container = (FrameLayout)FindViewById(Resource.Id.local_video_view_container);
         _localVideoView = RtcEngine.CreateRendererView(BaseContext);
         _localVideoView.SetZOrderMediaOverlay(true);
         container.AddView(_localVideoView);
         AgoraEngine.SetupLocalVideo(new VideoCanvas(_localVideoView, VideoCanvas.RenderModeAdaptive, 0));
         if (!string.IsNullOrEmpty(""))
         {
             AgoraEngine.SetEncryptionMode("aes-128-xts");
             AgoraEngine.SetEncryptionSecret("");
         }
         AgoraEngine.StartPreview();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Ejemplo n.º 7
0
 private void SetupLocalVideo()
 {
     try
     {
         FrameLayout container = (FrameLayout)FindViewById(Resource.Id.local_video_view_container);
         LocalVideoView = RtcEngine.CreateRendererView(BaseContext);
         LocalVideoView.SetZOrderMediaOverlay(true);
         container.AddView(LocalVideoView);
         //AgoraEngine.SetupLocalVideo(new VideoCanvas(LocalVideoView, VideoCanvas.RenderModeAdaptive, 0)); >> Old
         AgoraEngine.SetupLocalVideo(new VideoCanvas(LocalVideoView, VideoCanvas.RenderModeHidden, 0));
         if (!string.IsNullOrEmpty(""))
         {
             AgoraEngine.SetEncryptionMode("aes-128-xts");
             AgoraEngine.SetEncryptionSecret("");
         }
         AgoraEngine.StartPreview();
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            // 防止發生預期錯誤用:
            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
            StrictMode.SetVmPolicy(builder.Build());

            // 顯示最上方的app名稱
            //Android.Support.V7.Widget.Toolbar toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            //SetSupportActionBar(toolbar);

            FindViewById <Button>(Resource.Id.btn_rec).Click  += Rec_Click;
            FindViewById <Button>(Resource.Id.btn_view).Click += View_Click;

            // 跑馬燈
            TextView tv = FindViewById <TextView>(Resource.Id.mytv);

            tv.Selected = true;

            // 設定使用說明的按鈕
            AlertDialog.Builder alert_tips    = new AlertDialog.Builder(this); // For Button_Tips
            AlertDialog.Builder alert_initial = new AlertDialog.Builder(this); // For initial tips dialog

            if (show_time == 0)
            {
                alert_initial.SetTitle("使用順序");
                alert_initial.SetMessage("1. 測謊規則 -> 開始測謊 -> 查看影像.\n2. 請詳細閱讀\u201C測謊規則\u201C.\n3. 閱讀完畢後,即可\u201C開始測謊\u201C.\n4. \u201C查看影像\u201C可預覽影像,方便確認影像品質!");
                alert_initial.SetIcon(Android.Resource.Drawable.IcDialogInfo);
                alert_initial.SetPositiveButton(" ok", new EventHandler <DialogClickEventArgs>((sender, e) => { }));
                alert_initial.Show();
                show_time++;
            }

            FindViewById <Button>(Resource.Id.btn_tips).Click += (sender, e) =>
            {
                alert_tips.SetTitle("測謊說明");
                alert_tips.SetMessage("1. 確保受測者臉部完全包覆於黃色提示框內.\n"
                                      + "2. 請確保問題可讓受測者於6秒內回答完畢,敘述問題完畢後,即可按下**開始測謊**錄製影像,6秒後將自動停止錄影.\n"
                                      + "3. 錄製完畢後,按下**查看影像**預覽影像品質.\n"
                                      + "4. 請確認影片品質並檢查Wi-Fi功能是否開啟,無誤即可按下**上傳檔案**,等待數秒後即獲得測謊結果.\n"
                                      + "5. 最後,由衷的邀請您按下**填寫回饋單**,給予我們寶貴的建議,謝謝體驗!!!");
                alert_tips.SetIcon(Android.Resource.Drawable.IcDialogInfo);

                alert_tips.Show();
            };
            alert_tips.SetPositiveButton(" ok", new EventHandler <DialogClickEventArgs>((sender, e) => { }));

            // 相機與錄製功能設定
            _MediaRecorder = new MediaRecorder();
            Camera         = Camera.Open();
            surfaceView    = FindViewById <SurfaceView>(Resource.Id.surfaceView);

            _Holder = surfaceView.Holder;

            _SurfaceHolderCallBack = new SurfaceHolderCallBack(this, Camera, _MediaRecorder);
            _Holder.AddCallback(_SurfaceHolderCallBack);
            _Holder.SetType(SurfaceType.PushBuffers);

            // For rectangle on surfaceview
            sv_rec = FindViewById <SurfaceView>(Resource.Id.surface_rec);
            holder = sv_rec.Holder;
            sv_rec.Holder.SetFormat(Android.Graphics.Format.Transparent);
            holder.SetFormat(Android.Graphics.Format.Transparent);
            sv_rec.SetZOrderMediaOverlay(true);
            sv_rec.SetZOrderOnTop(true);
            holder.AddCallback(this);
        } // End of OnCreate()