private void PlayerBtn_Click(object sender, EventArgs e) { var isPlay = (sender as Button).Text == "播放"; if (isPlay) { string RTSPStreamURI = this.StreamURI.Text;// "rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov"; channelID = PlayerSdk.EasyPlayer_OpenStream(RTSPStreamURI, this.panel1.Handle, RENDER_FORMAT, isTCP ? 1 : 0, "", "", callBack, IntPtr.Zero, isHardEncode); if (channelID > 0) { PlayerSdk.EasyPlayer_SetFrameCache(channelID, 3); this.PlayerBtn.Text = "停止"; this.DecodeType.Enabled = false; } } else { int ret = PlayerSdk.EasyPlayer_CloseStream(channelID); if (ret == 0) { this.PlayerBtn.Text = "播放"; this.DecodeType.Enabled = true; channelID = -1; this.panel1.Refresh(); } } }
public void closeRtsp(bool isLeave) { logger.Info("将要关闭窗口[" + key + "]上的流"); try { VideoPlayModel v = messageModel.videoData; if (isLeave) { if (v.isCamera && !messageModel.watchSubordinateLiveMessageBean.isThisPlatform) { mainForm.tcpServerService.notifyHangupVideoChild(v.liveMemberNo, v.isCamera, messageModel.watchSubordinateLiveMessageBean); } else if (v.streamType == "RTSP") { mainForm.tcpServerService.notifyHangupVideo(v); } } //关闭视频 int ret = PlayerSdk.EasyPlayer_CloseStream(channelId); logger.Info("关闭视频是否成功:" + ret); if (ret == 0) { //关闭音频 int audioStatus = PlayerSdk.EasyPlayer_PlaySound(channelId); logger.Info("关闭音频是否成功:" + audioStatus); channelId = 0; videoPlayStatus = false; audioPlayedStatus = false; //关闭后隐藏 onePlayerPanel.Visible = false; titlePanel.Visible = false; comBtnPanel.Visible = false; ptzPanel.Visible = false; //清空保存的播放参数 this.messageModel = null; this.key = ""; //全屏播放窗口关闭后,还原窗口 if (mainForm.checkFullScreenWinByKey(key)) { mainForm.changeFullScreen(null); } } } catch (Exception e) { logger.Error("", e); } }
public async Task StopPlaying() { int ret = PlayerSdk.EasyPlayer_CloseStream(settings.channelID); if (ret == 0) { settings.channelID = -1; } p_Player.BackColor = Color.Black; p_Player.Refresh(); }