You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
4.5 KiB

3 years ago
using ECMonitor.UC.Videos;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace ECMonitor.Manager
{
public class VideoPlayManager
{
private int _videoIndex = 0;
private List<IUCPlayer> UCVideoList = new List<IUCPlayer>();
/// <summary>
/// 获取显示模块
/// </summary>
/// <param name="cameraIp"></param>
/// <returns></returns>
public UserControl GetUserControl(string cameraIp)
{
return UCVideoList.Find(c => c.GetCameraIp() == cameraIp).GetControl();
}
public IUCPlayer GetUCVideo(string cameraIp)
{
return UCVideoList.Find(c => c.GetCameraIp() == cameraIp);
}
internal void Add(IUCPlayer videoShow)
{
videoShow.SetIndex(UCVideoList.Count);
UCVideoList.Add(videoShow);
}
internal void Remove(IUCPlayer videoShow)
{
UCVideoList.Remove(videoShow);
int icont = UCVideoList.Count;
for(int i = 0; i < icont; i++)
{
UCVideoList[i].SetIndex(i);
}
}
internal List<IUCPlayer> GetUCVideoList()
{
return UCVideoList;
}
internal void SetALLUnSelected()
{
foreach (IUCPlayer videoPlay in UCVideoList)
{
videoPlay.SetSelected(false);
}
}
public IUCPlayer CreateVideo(IEventAggregator ea,double _videoWidth, double _videoHeight, int videoType=0,bool showCloseButton=true)
{
switch (videoType)
{
case 0://Rtsp
UCFFmpegPlayer rtspVideo = new UCFFmpegPlayer(ea,_videoWidth, _videoHeight, _videoIndex++, showCloseButton,true);
rtspVideo._videoType = videoType;
UCVideoList.Add(rtspVideo);
return rtspVideo;
//case 1://海康直连
// return null
// break;
default:
UCFFmpegPlayer defaultVideo = new UCFFmpegPlayer(ea,_videoWidth, _videoHeight, _videoIndex++, showCloseButton);
defaultVideo._videoType = videoType;
UCVideoList.Add(defaultVideo);
return defaultVideo;
}
}
/// <summary>
/// 创建视频预警线规划
/// </summary>
/// <param name="ea"></param>
/// <param name="_videoWidth"></param>
/// <param name="_videoHeight"></param>
/// <param name="videoType"></param>
/// <returns></returns>
public IUCPlayer CreateWarnCreateLinePlayer(IEventAggregator ea, double _videoWidth, double _videoHeight, int videoType = 0 )
{
UCFFmpegPlayer rtspVideo = new UCFFmpegPlayer(ea, _videoWidth, _videoHeight, _videoIndex++, false, false);
rtspVideo._videoType = videoType;
UCVideoList.Add(rtspVideo);
return rtspVideo;
}
public IUCPlayer CreateWaringVideo(IEventAggregator ea, double _videoWidth, double _videoHeight, int videoType = 0, bool showCloseButton = false)
{
UCAIWarningPlayer rtspVideo = new UCAIWarningPlayer(ea, _videoWidth, _videoHeight, _videoIndex++, showCloseButton);
rtspVideo._videoType = videoType;
UCVideoList.Add(rtspVideo);
return rtspVideo;
}
public IUCPlayer CreateVideoAI(double _videoWidth, double _videoHeight, int videoType = 0, bool showCloseButton = true)
{
switch (videoType)
{
case 0://Rtsp
UCFFmpegAIPlayer rtspVideo = new UCFFmpegAIPlayer(_videoWidth, _videoHeight, _videoIndex++, showCloseButton);
rtspVideo.VideoType = videoType;
UCVideoList.Add(rtspVideo);
return rtspVideo;
//case 1://海康直连
// return null
// break;
default:
rtspVideo = new UCFFmpegAIPlayer(_videoWidth, _videoHeight, _videoIndex++, showCloseButton);
rtspVideo.VideoType = videoType;
UCVideoList.Add(rtspVideo);
return rtspVideo;
}
}
}
}