コード例 #1
0
        /// <summary>
        /// 單一鏡頭即時影像播放
        /// </summary>
        /// <param name="iCH">鏡頭編號 (0~15)</param>
        /// <param name="iAudio">傳輸聲音資料
        /// 0: do not send audio data
        /// 1: send audio data, if any
        /// </param>
        /// <param name="iStream">使用串流
        /// 0: use primary stream
        /// 1: try to use secondary stream
        /// </param>
        /// <returns></returns>
        public int Device_RealPlay(int iCH, int iAudio, int iStream)
        {
            int rtnVal = 0;

            try
            {
                Device_Logout();
                channel = iCH;

                apv = new VideoMediaElementCore.MediaElementCore(iCH + 1, 0);
                wpfmain.Children.Add(apv);
                wpfmain.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(wpfmain_MouseLeftButtonUp);
                apv.set_size(elementHost1.Width, elementHost1.Height);
                //apv.set_aes_key("1234567890123456");
                Console.WriteLine("Ip = {0} Port = {1}", IP, PORT);
                apv.set_source(0, IP, PORT, iCH, (byte)iAudio, (byte)iStream, 1);
                apv.set_print_msg(1);
                //MessageBox.Show();
                //wpfmain.Children.Add(apv);

                //0 => send request to get one frame
                //1 => send request to get one I-frame
                //2 => play continuous stream
                apv.set_read_mode(2);
                apv.play();

                rtnVal = 1;
            }
            catch (Exception ex)
            {
                _ErrDesc = ex.Message;
            }

            return(rtnVal);
        }
コード例 #2
0
        private int _PlayBackByTime(int iCH, int iAudio, string sStartTime, int is_utc)
        {
            int rtnVal = 0;

            try
            {
                Device_Logout();
                channel = iCH;

                apv = new VideoMediaElementCore.MediaElementCore(iCH + 1, 1);
                wpfmain.Children.Add(apv);
                wpfmain.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(wpfmain_MouseLeftButtonUp);
                apv.set_size(elementHost1.Width, elementHost1.Height);
                //apv.set_aes_key("1234567890123456");
                if (is_utc == 0)
                {
                    apv.set_source_l(1, IP, PORT, iCH, (byte)iAudio, ConvertToTimestamp(DateTime.Parse(sStartTime)));
                }
                else
                {
                    apv.set_source_l(1, IP, PORT, iCH, (byte)iAudio, ConvertToTimestamp(DateTime.Parse(sStartTime)));
                }
                //apv.set_playback_cmd(1, 1); //2014/07/21_CTS
                apv.set_print_msg(1);

                apv.play();
                System.Threading.Thread.Sleep(1000);
                apv.set_playback_cmd(1, 1);

                rtnVal = 1;
            }
            catch (Exception ex)
            {
                _ErrDesc = ex.Message;
            }

            return(rtnVal);
        }