Ejemplo n.º 1
0
 private void onVideoRemoved(VideoControlViewModel vm)
 {
     if (VideoRemoved != null)
     {
         VideoRemoved(vm);
     }
 }
Ejemplo n.º 2
0
 private void addOrRemoveVideoEvent(VideoControlViewModel vm, bool add)
 {
     if (add)
     {
         vm.Closed += Video_Closed;
     }
     else
     {
         vm.Closed -= Video_Closed;
     }
 }
Ejemplo n.º 3
0
        private void videoAdded(VideoControlViewModel model)
        {
            List <VideoControl> vcs = new List <VideoControl>();

            foreach (VideoControl vc in gridVideo.Children)
            {
                vcs.Add(vc);
            }
            gridVideo.Children.Clear();
            vcs.Add(new VideoControl()
            {
                DataContext = model
            });
            replaceVideo(vcs);
        }
Ejemplo n.º 4
0
        private void videoRemoved(VideoControlViewModel model)
        {
            List <VideoControl> vcs = new List <VideoControl>();

            foreach (VideoControl vc in gridVideo.Children)
            {
                vcs.Add(vc);
            }
            gridVideo.Children.Clear();
            int index = vcs.FindIndex(vc => vc.ViewModel == model);

            if (index >= 0)
            {
                vcs.RemoveAt(index);
            }
            replaceVideo(vcs);
        }
Ejemplo n.º 5
0
        public void AddToPlay(string videoId, int streamId, string videoName)
        {
            if (PlaySlider.BeginTime >= PlaySlider.EndTime)
            {
                DialogUtil.ShowWarning("无效查询时间段。");
                return;
            }
            if (Source == null)
            {
                DialogUtil.ShowWarning("无效的数据源。");
                return;
            }

            VideoControlViewModel vm = null;
            string dictKey           = null;

            if (Source.SrcType == SourceType.Local)
            {
                LocalDownloadInfoPacket param = new LocalDownloadInfoPacket(new VideoInfo(videoId, streamId, videoName), Source.LocalSourcePath);
                if (!isContained(param.Info))
                {
                    vm      = new VideoControlViewModel(param, PlaySlider.BeginTime, PlaySlider.EndTime, _replayProcess);
                    dictKey = buildKey(param.Info);
                }
            }
            else
            {
                DownloadInfoParam downloadInfo = new DownloadInfoParam(Source.Storage.Ip, Source.Storage.Port, PlaySlider.BeginTime, PlaySlider.EndTime, videoId, streamId, ConstSettings.CachePath, videoName);
                if (!isContained(downloadInfo))
                {
                    vm      = new VideoControlViewModel(downloadInfo, _replayProcess);
                    dictKey = buildKey(downloadInfo);
                }
            }
            if (vm != null && dictKey != null)
            {
                lock (_videoLockObj)
                {
                    _dictVideoVMS[dictKey] = vm;
                }
                addOrRemoveVideoEvent(vm, true);
                onVideoAdded(vm);
                vm.ProgressOffset = PlaySlider.Slider / (double)PlaySlider.SliderMaximum;
            }
        }
Ejemplo n.º 6
0
        public void Remove(IVideoInfo vInfo)
        {
            if (isContained(vInfo))
            {
                string key = buildKey(vInfo);
                VideoControlViewModel vm = _dictVideoVMS[key];
                addOrRemoveVideoEvent(vm, false);
                lock (_videoLockObj)
                {
                    vm.Close();
                    _dictVideoVMS.Remove(key);
                }
                if (_dictVideoVMS.Count == 0)
                {
                    Stop();
                }

                onVideoRemoved(vm);
            }
        }
Ejemplo n.º 7
0
        private void Video_Closed(object sender, EventArgs e)
        {
            VideoControlViewModel vm = sender as VideoControlViewModel;

            Remove(vm.VideoInfo);
        }