Example #1
0
        void BtnMonStart_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //获取本窗口的句柄
                int        handle     = 0;
                HwndSource hwndSource = HwndSource.FromVisual(this) as HwndSource;
                if (hwndSource != null)
                {
                    hwndSource.AddHook(WndProc);
                    handle = hwndSource.Handle.ToInt32();
                }
                int intReturn;

                SRCMON_PARAM monParam = new SRCMON_PARAM();
                monParam.sVocIp   = Converter.String2ByteArray("192.168.6.7", ScreenMPDefines.SIZE_IPADDRESS);
                monParam.nPort    = 3010;
                monParam.nChannel = 0;
                intReturn         = ScreenMPInterop.VLSMonStart(ref monParam, null, handle);
                AppendMessage(string.Format("MonStartReturn:{0}", intReturn));
            }
            catch (Exception ex)
            {
                AppendMessage(string.Format("Fail.\t{0}", ex.Message));
            }
        }
Example #2
0
 void BtnStop_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         //关闭播放器
         int intValue = ScreenMPInterop.VLSMonCloseWnd();
         AppendMessage(string.Format("CloseWndReturn:{0}", intValue));
         mHwndPlayer = IntPtr.Zero;
     }
     catch (Exception ex)
     {
         AppendMessage(ex.Message);
     }
 }
Example #3
0
        private void StopSMon()
        {
            try
            {
                StopSMonObject(false);

                if (mIsScrWinOpened)
                {
                    int intReturn;
                    intReturn = ScreenMPInterop.VLSMonStop();
                    CurrentApp.WriteLog("StoSMon", string.Format("MonStopReturn:{0}", intReturn));
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
Example #4
0
        void SliderPosition_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            try
            {
                var pos      = SliderPosition.Value;
                int intValue = (int)pos;

                mPlayedLength = intValue;

                //设置播放位置
                intValue = ScreenMPInterop.VLSMonSetPlayPos(intValue);
                AppendMessage(string.Format("SetPlayPosReturn:{0}", intValue));
            }
            catch (Exception ex)
            {
                AppendMessage(ex.Message);
            }
        }
Example #5
0
        void SliderScale_MouseLeftButtonUp(object send, MouseButtonEventArgs e)
        {
            try
            {
                var scale = SliderScale.Value;
                if (scale > 0)
                {
                    mScale = (int)scale;

                    //设置缩放
                    int intValue = ScreenMPInterop.VLSMonSetScale(mScale);
                    AppendMessage(string.Format("SetScaleReturn:{0}", intValue));
                }
            }
            catch (Exception ex)
            {
                AppendMessage(ex.Message);
            }
        }
Example #6
0
        public void CloseSMonPanel()
        {
            try
            {
                StopSMonObject(true);

                if (mIsScrWinOpened)
                {
                    int intReturn;
                    intReturn = ScreenMPInterop.VLSMonStop();
                    CurrentApp.WriteLog("StoSMon", string.Format("MonStopReturn:{0}", intReturn));
                }

                RemoveMonObject();
                if (PageParent != null)
                {
                    PageParent.ClosePanel(2);
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
Example #7
0
        private void DealStartSMonResponse(ReturnMessage retMessage)
        {
            try
            {
                if (retMessage.ListData == null || retMessage.ListData.Count < 2)
                {
                    CurrentApp.WriteLog("StartSMonResponse", string.Format("ListData count invalid"));
                    return;
                }
                string strMonID   = retMessage.ListData[0];
                string strMonPort = retMessage.ListData[1];
                if (strMonID == mMonitorObject.MonID)
                {
                    MonitorObject monObj = mMonitorObject;
                    int           intMonPort;
                    if (!int.TryParse(strMonPort, out intMonPort))
                    {
                        CurrentApp.WriteLog("StartSMonResponse", string.Format("Monitor port invalid"));
                        return;
                    }
                    string strHost   = monObj.Other03;  //录屏服务器的地址
                    string strChanID = monObj.Other01;
                    int    intChanID;
                    if (!int.TryParse(strChanID, out intChanID))
                    {
                        CurrentApp.WriteLog("StartSMonResponse", string.Format("Channel ID invalid"));
                        return;
                    }

                    OperationReturn optReturn = Utils.DownloadMediaUtils(CurrentApp.Session);
                    if (!optReturn.Result)
                    {
                        CurrentApp.WriteLog("StartSMonResponse",
                                            string.Format("DownloadMediaUtil fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }

                    //获取本窗口的句柄
                    int        handle     = 0;
                    HwndSource hwndSource = HwndSource.FromVisual(this) as HwndSource;
                    if (hwndSource != null)
                    {
                        //hwndSource.AddHook(WndProc);
                        handle = hwndSource.Handle.ToInt32();
                    }
                    int intReturn;
                    //设置反馈进度的频率
                    intReturn = ScreenMPInterop.VLSMonSetWaterMark(1);
                    CurrentApp.WriteLog("StartSMonResponse", string.Format("VLSMonSetWaterMarkReturn:{0}", intReturn));
                    //设置窗口尺寸
                    int intScale = 100;
                    if (ListUserParams != null)
                    {
                        var userParam = ListUserParams.FirstOrDefault(p => p.ParamID == S2102Consts.UP_PLAYSCREEN_SCALE);
                        if (userParam != null)
                        {
                            int temp;
                            if (int.TryParse(userParam.ParamValue, out temp))
                            {
                                if (temp > 0 && temp <= 100)
                                {
                                    intScale = temp;
                                }
                            }
                        }
                    }
                    intReturn = ScreenMPInterop.VLSMonSetScale(intScale);
                    CurrentApp.WriteLog("StartSMonResponse", string.Format("VLSMonSetScaleReturn:{0}", intReturn));
                    SRCMON_PARAM param = new SRCMON_PARAM();
                    param.sVocIp   = Converter.String2ByteArray(strHost, ScreenMPDefines.SIZE_IPADDRESS);
                    param.nPort    = (ushort)intMonPort;
                    param.nChannel = (ushort)intChanID;
                    intReturn      = ScreenMPInterop.VLSMonStart(ref param, null, handle);
                    CurrentApp.WriteLog("StartSMonResponse", string.Format("VLSMonStartReturn:{0}", intReturn));
                    if (intReturn == 0)
                    {
                        mIsScrWinOpened = true;
                        IntPtr hwdPlayer = ScreenMPInterop.VLSMonGetPlayerHwnd();

                        //窗口置顶
                        if (ListUserParams != null)
                        {
                            var userParam =
                                ListUserParams.FirstOrDefault(p => p.ParamID == S2102Consts.UP_PLAYSCREEN_TOPMOST);
                            if (userParam != null &&
                                userParam.ParamValue == "1" &&
                                hwdPlayer != IntPtr.Zero)
                            {
                                intReturn = User32Interop.SetWindowPos(hwdPlayer, -1, 0, 0, 0, 0, 3);
                                CurrentApp.WriteLog("StartSMonResponse", string.Format("SetWindowPos:{0}", intReturn));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CurrentApp.WriteLog("StartSMonResponse", string.Format("Fail.\t{0}", ex.Message));
            }
        }
Example #8
0
        void BtnPlay_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                mPlayedLength          = 0;
                mTotalLength           = 60;
                SliderPosition.Maximum = 60;
                SliderPosition.Minimum = 0;
                SliderPosition.Value   = 0;
                int intTotalLength = 0;

                //获取本窗口的句柄
                int        handle     = 0;
                HwndSource hwndSource = HwndSource.FromVisual(this) as HwndSource;
                if (hwndSource != null)
                {
                    hwndSource.AddHook(WndProc);
                    handle = hwndSource.Handle.ToInt32();
                }

                //string file = string.Format(@"E:\20130819\00\001\ASCHN000000000002000120150609044520744.vls");
                string file = string.Format(@"test.vls");
                int    intReturn;
                bool   boolReturn;
                //设置反馈进度的频率
                intReturn = ScreenMPInterop.VLSMonSetWaterMark(1);
                AppendMessage(string.Format("SetWaterMarkReturn:{0}", intReturn));
                //播放录屏数据
                intReturn = ScreenMPInterop.VLSMonPlay(file, null, handle);
                AppendMessage(string.Format("PlayReturn:{0}", intReturn));
                if (intReturn == 0)
                {
                    //获取播放窗口句柄
                    IntPtr ptr = ScreenMPInterop.VLSMonGetPlayerHwnd();
                    AppendMessage(string.Format("IntPtr:{0}", ptr));
                    mHwndPlayer = ptr;

                    //窗口置顶
                    if (mHwndPlayer != IntPtr.Zero)
                    {
                        intReturn = User32Interop.SetWindowPos(mHwndPlayer, -1, 0, 0, 0, 0, 3);
                        AppendMessage(string.Format("SetWinPosReturn:{0}", intReturn));
                    }

                    //设置标题
                    if (mHwndPlayer != IntPtr.Zero)
                    {
                        boolReturn = User32Interop.SetWindowText(mHwndPlayer, file);
                        AppendMessage(string.Format("SetWinTxtReturn:{0}", boolReturn));
                    }
                }

                //获取媒体文件总时长
                intReturn = ScreenMPInterop.VLSMonGetFileTotalTime(file, ref intTotalLength, false);
                AppendMessage(string.Format("GetTotalTimeReturn:{0}", intReturn));
                if (intReturn == 0)
                {
                    mTotalLength = intTotalLength;

                    SliderPosition.Maximum = mTotalLength;
                    string str = string.Format("{0}/{1}", Converter.Second2Time(mPlayedLength),
                                               Converter.Second2Time(mTotalLength));

                    ShowStateMessage(str);
                }
            }
            catch (Exception ex)
            {
                AppendMessage(ex.Message);
            }
        }