private static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (e.Property.Name != "HostVideo") { return; } VideoPlayer that = d as VideoPlayer; /*Clear resource at first*/ that._bitmap = null; if (e.NewValue != null) { VideoVideoModel hostVideo = e.NewValue as VideoVideoModel; that._bitmap = new WriteableBitmap( hostVideo.Width, hostVideo.Height, 96.0, 96.0, PixelFormats.Bgr24, null); that._lastFrameTag = int.MinValue; that.screen.Source = that._bitmap; } }
private void ClearData() { Video.Dispose(); Video = null; _metadata = null; _activeIdSet.Clear(); _thumbnails.Clear(); ActiveIds = null; VideoUrl = null; MetadataUrl = null; ThumbnailUrls = null; }
private void LoadData(object sender, DoWorkEventArgs e) { VideoVideoModel video = new VideoVideoModel(_videoUrl, _videoFilters); Task task = video.LoadAsync(); _metadata = Metadata.Parse(_metadataUrl); string[] thumbnailUrls = _thumbnailUrls.Split(new string[] { "; " }, StringSplitOptions.None); if (thumbnailUrls.Length != 0) { string folder = Path.GetDirectoryName(thumbnailUrls[0]); for (int i = 1; i < thumbnailUrls.Length; i++) { thumbnailUrls[i] = Path.Combine(folder, thumbnailUrls[i]); } } List <ThumbnailViewModel> thumbnails = new List <ThumbnailViewModel>(); foreach (string url in thumbnailUrls) { if (!File.Exists(url)) { continue; } string fileName = Path.GetFileNameWithoutExtension(url); int id = int.Parse(fileName.Substring(fileName.Length - 6, 6)); ThumbnailViewModel thumabnail = new ThumbnailViewModel(id, _metadata.GetObjectTimestamp(id), url); thumabnail.CheckChanged += (s, _) => { UpdateActiveIds(); Video.StopBy((s as ThumbnailViewModel).FrameTimestamp, false); }; thumabnail.Clicked += (s, _) => { Video.StopBy((s as ThumbnailViewModel).FrameTimestamp, true); }; thumbnails.Add(thumabnail); _activeIdSet.Add(id); } ActiveIds = string.Join(", ", _activeIdSet); e.Result = thumbnails; task.Wait(); Video = video; }