/// <summary> /// 停止播放流媒体 /// </summary> public void StopPlay() { this.btnPlay.Enabled = false; if (ChannelId > 0) { if (this.btnRecord.Checked) { // 正在录制则进行停止 LogAppend("正在停止视频录制..."); // 停止录像 this.btnRecord.Checked = false; PlayerMethods.CarEyePlayer_StopManuRecording(ChannelId); LogAppend("视频录制已停止."); } // 预览停止代码 PlayerMethods.CarEyePlayer_CloseStream(ChannelId); UrlApiHelper.ControlVideo(Token.TerminalId, Token.LogicChn, VedioControlType.Stop); ChannelId = -1; } LinkToken(null); mImagePath = null; mVideoPath = null; UpdateDisplayStatus(); }
/// <summary> /// 控件销毁时进行资源释放 /// </summary> /// <param name="e"></param> protected override void OnHandleDestroyed(EventArgs e) { // 释放资源 if (ChannelId > 0) { // 相应资源回收处理代码 PlayerMethods.CarEyePlayer_CloseStream(ChannelId); ChannelId = -1; } base.OnHandleDestroyed(e); }
/// <summary> /// 设置截图存储路径 /// </summary> /// <param name="aPath"></param> public void SetImagePath(string aPath) { if (string.IsNullOrEmpty(aPath)) { return; } mImagePath = aPath; if (ChannelId > 0) { PlayerMethods.CarEyePlayer_SetManuPicShotPath(ChannelId, mImagePath); } }
/// <summary> /// 设置视频存储路径 /// </summary> /// <param name="aPath"></param> public void SetVideoPath(string aPath) { if (string.IsNullOrEmpty(aPath)) { return; } mVideoPath = aPath; if (ChannelId > 0) { PlayerMethods.CarEyePlayer_SetManuRecordPath(ChannelId, mVideoPath); } }
/// <summary> /// 静音切换 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSound_Click(object sender, EventArgs e) { if (!IsPlaying) { return; } if (this.btnSound.Checked) { this.btnSound.Checked = false; PlayerMethods.CarEyePlayer_StopSound(); return; } mParent.PlayChnSound(ChannelId); }
/// <summary> /// 开始播放流媒体 /// </summary> /// <returns></returns> public bool StartPlay() { if (ChannelId > 0) { return(true); } if (Token == null) { LogAppend("无效的监控终端。。。"); return(false); } if (string.IsNullOrEmpty(this.Token.Url)) { LogAppend("视频监控地址无效。。。"); return(false); } // TCP连接 YUY2显示,软解码 ChannelId = PlayerMethods.CarEyePlayer_OpenStream(this.Token.Url, this.lblView.Handle, RENDER_FORMAT.DISPLAY_FORMAT_YUY2, 1, string.Empty, string.Empty, mPlayerCallBack, this.Handle, false); if (ChannelId <= 0) { this.btnPlay.Enabled = true; LogAppend("视频监控打开失败..."); return(false); } // 设置缓存 // 最大帧缓存为30,超过该值将只播放I帧 PlayerMethods.CarEyePlayer_SetFrameCache(ChannelId, 3); mParent.PlayChnSound(ChannelId); // 按比例播放 PlayerMethods.CarEyePlayer_SetShownToScale(ChannelId, 1); // 设置抓图和录制存放路径 GenRecordPath(); PlayerMethods.CarEyePlayer_SetManuRecordPath(ChannelId, mVideoPath); GenScreenPath(); PlayerMethods.CarEyePlayer_SetManuPicShotPath(ChannelId, mImagePath); this.btnPlay.Checked = true; this.btnPlay.Enabled = true; UpdateDisplayStatus(true); return(true); }
/// <summary> /// 录像 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRecord_Click(object sender, EventArgs e) { this.btnRecord.Enabled = false; if (this.btnRecord.Checked) { // 停止录像 this.btnRecord.Checked = false; PlayerMethods.CarEyePlayer_StopManuRecording(ChannelId); LogAppend("视频录制已停止."); } else { do { if (ChannelId <= 0) { GuiHelper.MsgBox("该窗口当前处于非播放状态,无法录制..."); break; } GenRecordPath(); if (!Directory.Exists(mVideoPath)) { Directory.CreateDirectory(mVideoPath); } // 开始录像 if (PlayerMethods.CarEyePlayer_StartManuRecording(ChannelId) > 0) { LogAppend("开始录制视频..."); this.btnRecord.Checked = true; } else { LogAppend("视频录制启动失败..."); } } while (false); } this.btnRecord.Enabled = true; }
/// <summary> /// 截图 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnScreenShot_Click(object sender, EventArgs e) { if (ChannelId <= 0) { GuiHelper.MsgBox("该窗口当前处于非播放状态,无法抓拍..."); return; } GenScreenPath(); if (!Directory.Exists(mImagePath)) { Directory.CreateDirectory(mImagePath); } // 视频截图 if (PlayerMethods.CarEyePlayer_StartManuPicShot(ChannelId) > 0) { LogAppend("已成功抓取拍照!"); } else { LogAppend("抓取拍照失败..."); } }