/// <summary> /// 附加信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddScreenFontTSMenuItem_Click(object sender, EventArgs e) { int ret = -1; var rect = new Rect { X = 10, Y = 10, Width = panel1.Width, Height = panel1.Height }; var panelSize = this.panel1.ClientSize; EasyPlayer_RTMP.NetSDK.PlayerSdk.EASY_PALYER_OSD fontInfo = new EasyPlayer_RTMP.NetSDK.PlayerSdk.EASY_PALYER_OSD { alpha = 255, size = 35, color = (uint)ToArgb(Color.Red), shadowcolor = (uint)ToArgb(Color.Black), stOSD = "这是EasyPlayer-RTMP-Win播放器 \r\n的字幕叠加接口的效果!!!\r\n以\"\\r\\n\"为换行结束符号\r\n注意:每行的长度不能超过128个字节\r\n总的OSD长度不能超过1024个字节", rect = new EasyPlayer_RTMP.NetSDK.PlayerSdk.tagRECT { left = (int)rect.X, top = (int)rect.Y, right = (int)rect.Width, bottom = (int)rect.Height } }; var checkState = (sender as ToolStripMenuItem).CheckState; if (checkState == CheckState.Unchecked) { ret = PlayerSdk.EasyPlayer_ShowOSD(channelID, fontInfo); (sender as ToolStripMenuItem).CheckState = CheckState.Checked; } if (checkState == CheckState.Checked) { ret = PlayerSdk.EasyPlayer_ShowOSD(channelID, fontInfo, false); (sender as ToolStripMenuItem).CheckState = CheckState.Unchecked; } }
private void PlayerForm_FormClosing(object sender, FormClosingEventArgs e) { if (isInit) { PlayerSdk.EasyPlayer_Release(); } }
//重置音频窗口的图标 public void changeVolumeStatus(bool volumeStatus) { try { if (this.audioPlayedStatus != volumeStatus) { logger.Info("修改窗口[" + _index + "]上的音频状态为:" + volumeStatus); } this.audioPlayedStatus = volumeStatus; if (volumeStatus) { //PlayerSdk.EasyPlayer_StopSound(); //Thread.Sleep(500); logger.Info("播放音频:" + channelId); int ret = PlayerSdk.EasyPlayer_PlaySound(channelId); logger.Info("播放音频状态:" + ret); volumeSwitch.BackgroundImage = Properties.Resources.redioOpen; } else { PlayerSdk.EasyPlayer_StopSound(); volumeSwitch.BackgroundImage = Properties.Resources.redioClose; } } catch (Exception e) { logger.Error("", e); } }
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(); } } }
/// <summary> /// 截图. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void Snop_MenuItem_Click(object sender, EventArgs e) { if (channelID <= 0) { return; } int ret = PlayerSdk.EasyPlayer_PicShot(channelID); }
/// <summary> /// 视频缓冲区设置. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void CacheFream_ValueChanged(object sender, EventArgs e) { if (channelID <= 0) { return; } var cache = (sender as TrackBar).Value; int ret = PlayerSdk.EasyPlayer_SetFrameCache(channelID, cache); }
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(); }
private void UserControl1_Load(object sender, EventArgs e) { //HwndSource hs = (HwndSource)PresentationSource.FromDependencyObject(asd); //IntPtr ip = hs.Handle; PlayerSdk.EPInit(); int channelID = PlayerSdk.EasyPlayer_OpenStream("rtsp://*****:*****@172.16.21.80:554/h264/ch1/main/av_stream", panel1.Handle, PlayerSdk.RENDER_FORMAT.DISPLAY_FORMAT_RGB24_GDI, 1, "admin", "itc123456", PlayerSdk.EPcallBack, IntPtr.Zero, false); if (channelID > 0) { PlayerSdk.EasyPlayer_SetFrameCache(channelID, 3); } }
private void PlayerForm_Load(object sender, System.EventArgs e) { if (PlayerSdk.EasyPlayer_Init() == 0) { isInit = true; } callBack = new PlayerSdk.MediaSourceCallBack(MediaCallback); this.DecodeType.SelectedItem = "GDI"; isTCP = rtpoverType.CheckState == CheckState.Checked; isHardEncode = HardDecode.CheckState == CheckState.Checked; this.RightToLeft = RightToLeft.Inherit; }
/// <summary> /// 局部渲染 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RenderRect_MenuItem_Click(object sender, EventArgs e) { if (channelID <= 0) { return; } var panelSize = this.panel1.ClientSize; int ret = PlayerSdk.EasyPlayer_SetRenderRect(channelID, new Rect { X = 0, Y = 0, Width = panelSize.Width / 2, Height = panelSize.Height / 2 }); (sender as ToolStripMenuItem).CheckState = CheckState.Checked; }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { PlayerSdk.EPInit(); //IntPtr hwnd = ((HwndSource)PresentationSource.FromVisual(VideoPictureBox)).Handle; HwndSource hs1 = (HwndSource)PresentationSource.FromDependencyObject(gg1); HwndSource hs2 = (HwndSource)PresentationSource.FromDependencyObject(gg2); IntPtr ip = hs2.Handle; //IntPtr ip1 = hs1.Handle; int channelID = PlayerSdk.EasyPlayer_OpenStream("rtsp://172.16.21.209:554/1", VideoPictureBox.Handle, PlayerSdk.RENDER_FORMAT.DISPLAY_FORMAT_RGB24_GDI, 1, "", "", PlayerSdk.EPcallBack, IntPtr.Zero, false); if (channelID > 0) { PlayerSdk.EasyPlayer_SetFrameCache(channelID, 3); } }
/// <summary> /// 比例显示(仅限于软解码). /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void FullWindos_MenuItem_Click(object sender, EventArgs e) { if (channelID > 0) { var checkState = (sender as ToolStripMenuItem).CheckState; if (checkState == CheckState.Unchecked) { int ret = PlayerSdk.EasyPlayer_SetShownToScale(channelID, 1); (sender as ToolStripMenuItem).CheckState = CheckState.Checked; } if (checkState == CheckState.Checked) { int ret = PlayerSdk.EasyPlayer_SetShownToScale(channelID, 0); (sender as ToolStripMenuItem).CheckState = CheckState.Unchecked; } } }
private void PlayerForm_Load(object sender, System.EventArgs e) { //获取进程名 string str = this.GetType().Assembly.Location; this.Text = str; int LimitDayOut = PlayerSdk.EasyPlayer_Init(); if (LimitDayOut >= 0) { isInit = true; } callBack = new PlayerSdk.MediaSourceCallBack(MediaCallback); this.DecodeType.SelectedItem = "GDI"; isTCP = rtpoverType.CheckState == CheckState.Checked; isHardEncode = HardDecode.CheckState == CheckState.Checked; this.RightToLeft = RightToLeft.Inherit; }
/// <summary> /// 播放音频 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PlaySound_MenuItem_Click(object sender, EventArgs e) { if (channelID <= 0) { return; } var checkState = (sender as ToolStripMenuItem).CheckState; if (checkState == CheckState.Unchecked) { int ret = PlayerSdk.EasyPlayer_PlaySound(channelID); (sender as ToolStripMenuItem).CheckState = CheckState.Checked; } if (checkState == CheckState.Checked) { int ret = PlayerSdk.EasyPlayer_StopSound(); (sender as ToolStripMenuItem).CheckState = CheckState.Unchecked; } }
/// <summary> /// OSD信息显示. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void OSDShow_MenuItem_Click(object sender, EventArgs e) { if (channelID <= 0) { return; } var checkState = (sender as ToolStripMenuItem).CheckState; if (checkState == CheckState.Unchecked) { int ret = PlayerSdk.EasyPlayer_ShowStatisticalInfo(channelID, 1); (sender as ToolStripMenuItem).CheckState = CheckState.Checked; } if (checkState == CheckState.Checked) { int ret = PlayerSdk.EasyPlayer_ShowStatisticalInfo(channelID, 0); (sender as ToolStripMenuItem).CheckState = CheckState.Unchecked; } }
/// <summary> /// 视频录制. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void Recode_MenuItem_Click(object sender, EventArgs e) { if (channelID <= 0) { return; } var checkState = (sender as ToolStripMenuItem).CheckState; if (checkState == CheckState.Unchecked) { int ret = PlayerSdk.EasyPlayer_StartManuRecording(channelID); (sender as ToolStripMenuItem).CheckState = CheckState.Checked; } if (checkState == CheckState.Checked) { int ret = PlayerSdk.EasyPlayer_StopManuRecording(channelID); (sender as ToolStripMenuItem).CheckState = CheckState.Unchecked; } }
/// <summary> /// 关键帧播放 /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void KeyFreamDecode_MenuItem_Click(object sender, EventArgs e) { if (channelID <= 0) { return; } var checkState = (sender as ToolStripMenuItem).CheckState; if (checkState == CheckState.Unchecked) { int ret = PlayerSdk.EasyPlayer_SetDecodeType(channelID, 1); (sender as ToolStripMenuItem).CheckState = CheckState.Checked; } if (checkState == CheckState.Checked) { int ret = PlayerSdk.EasyPlayer_SetShownToScale(channelID, 0); (sender as ToolStripMenuItem).CheckState = CheckState.Unchecked; } }
public int showOSD(OSD messageOsd) { PlayerSdk.EASY_PALYER_OSD osd = messageOsd2Osd(messageOsd); return(PlayerSdk.EasyPlayer_ShowOSD(channelId, 1, osd)); }
/// <summary> /// 开始播放rtsp /// </summary> public void startPlay() { try { //todo 要去掉 //Thread.Sleep(100); logger.Info("将要播放编号[" + messageModel.memberNo + "]的图像,rtsp地址是:" + messageModel.videoData.rtspUrl); if (!"start".Equals(messageModel.videoMessageType)) { return; } string rtspPath = messageModel.videoData.rtspUrl; if (null == rtspPath || "".Equals(rtspPath)) { logger.Info("将要播放编号[" + messageModel.memberNo + "]的图像,但是没有rtsp地址"); return; } channelId = PlayerSdk.EasyPlayer_OpenStream(rtspPath, rtspPanel.Handle, PlayerSdk.RENDER_FORMAT.DISPLAY_FORMAT_RGB24_GDI, 1, "", "", mainForm.callBack, IntPtr.Zero, mainForm.isHardEncode); logger.Info("播放的图像的channelID:" + channelId); if (channelId > 0) { videoPlayStatus = true; PlayerSdk.EasyPlayer_SetFrameCache(channelId, 3); int ret; bool covered = null == messageModel.videoData.covered ? true : (bool)messageModel.videoData.covered; if (covered) { ret = PlayerSdk.EasyPlayer_SetShownToScale(channelId, 0); } else { ret = PlayerSdk.EasyPlayer_SetShownToScale(channelId, 1); } logger.Info("关闭其它窗口音频"); mainForm.resetAllVolumeStatus(); logger.Info("打开当前窗口音频图标"); changeVolumeStatus(true); //int retStartAudio = PlayerSdk.EasyPlayer_PlaySound(channelId);//播放音频 //logger.Info("播放音频状态:" + retStartAudio); //if (retStartAudio == 0) //{ // //关闭其它窗口音频 // logger.Info("关闭其它窗口音频"); // mainForm.resetAllVolumeStatus(); // logger.Info("打开当前窗口音频图标"); // changeVolumeStatus(true); //} } else //拉流失败 { logger.Info("拉流失败"); channelId = 0; mainForm.tcpServerService.notifyErrMsg(messageModel.memberNo, "播放错误!"); } } catch (Exception e) { logger.Error("", e); } }
public async Task <bool> Play(bool showErrors, bool doPing = true, string customAdr = "") { try { if (MainForm.m.lite && settings.isMainPlayer) { settings.channelID = 1; return(false); } if (InvokeRequired) { Invoke((MethodInvoker) delegate { Play(showErrors, doPing); }); return(false); } string fullAdr = customAdr; if (fullAdr == "") { fullAdr = settings.GetCombined(); } Uri combinedUrl = ConfirmAdr(showErrors, fullAdr, doPing); if (combinedUrl == null) { return(false); } Console.WriteLine("playing " + combinedUrl.ToString()); if (IsPlaying()) { StopPlaying(); } settings.channelID = PlayerSdk.EasyPlayer_OpenStream(combinedUrl.ToString(), p_Player.Handle, PlayerSdk.RENDER_FORMAT.DISPLAY_FORMAT_RGB24_GDI, 1, "", "", null, IntPtr.Zero, false); if (IsPlaying()) { PlayerSdk.EasyPlayer_SetFrameCache(settings.channelID, 3); } else { if (showErrors) { MessageBox.Show("Failed to attach to channel!"); } Console.WriteLine("FAILED TO ATTACH"); StopPlaying(); } } catch (Exception e) { if (showErrors) { Tools.ShowPopup("Failed to init player stream!\nShow more?", "Error Occurred!", e.ToString()); } Console.WriteLine("PLAY " + e.ToString()); StopPlaying(); return(false); } return(IsPlaying()); }