Esempio n. 1
0
        private void LoadSampleContent()
        {
            FileName = @"D:\samples\testUnit.wmv";

            foreach (AsfHeaderItem asfItem in AsfInfo.GetHeaderObjects(FileName))
            {
                _asfObjects.Add(asfItem);
            }
        }
Esempio n. 2
0
        private void LoadFile(string fileName)
        {
            FileErrorDetails.Clear();
            _asfObjects.Clear();
            TimeToImageConverter.EmptyCache();

            var asfItems = AsfInfo.GetHeaderObjects(fileName);

            if (asfItems == null) //invalid file
            {
                FileErrorDetails.Add(new FileErrorInfo()
                {
                    ErrorType = "Invalid ASF file", ErrorDetails = "No Header Object found"
                });
                Dispatcher.DelayInvoke(TimeSpan.FromMilliseconds(500),
                                       new Action(() =>
                {
                    ErrorDetailsVisible = true;
                    IsBusy = false;
                    RaisePropertyChanged("IsBusy");
                    RaisePropertyChanged("ErrorDetailsVisible");
                }));
            }
            else
            {
                foreach (AsfHeaderItem asfItem in asfItems)
                {
                    _asfObjects.Add(asfItem);
                }

                double fileLength = AsfHeaderItem.Configuration.Duration;
                HasVideoStream = AsfHeaderItem.Configuration.ImageWidth > 0;

                _previewImagesLoadedCount = 0;
                _previewImages.Clear();
                _loadingImages = new List <PreviewImage>();

                if (HasVideoStream)
                {
                    for (int i = 0; i < _thumbCount; i++)
                    {
                        double       startOffset = ((double)i / _thumbCount) * fileLength;
                        PreviewImage pi          = new PreviewImage()
                        {
                            FileName         = fileName,
                            TimeOffset       = startOffset,
                            DisplayTime      = (uint)(startOffset * 1000),
                            PresentationTime = (uint)(startOffset * 1000) + AsfHeaderItem.Configuration.AsfPreroll
                        };

                        Action a = new Action(pi.GenerateSource);
                        _loadingImages.Add(pi);
                        a.BeginInvoke(new AsyncCallback(PreviewImageLoaded), a);
                    }
                }

                RaisePropertyChanged("Title");
                Dispatcher.DelayInvoke(TimeSpan.FromMilliseconds(500),
                                       new Action(() =>
                {
                    IsBusy         = false;
                    IsFileLoaded   = true;
                    PreviewVisible = HasVideoStream;
                    RaisePropertyChanged("IsBusy");
                    RaisePropertyChanged("PreviewVisible");
                    RaisePropertyChanged("HasVideoStream");
                }));
            }
        }