private void SetupPlayer()
        {
            if (_decoder != null)
            {
                _decoder.Stop();
                _decoder.ClearBuffer();
                _decoder.Dispose();
                _decoder = null;
            }

            string file = "";

            Dispatcher.Invoke(() => file = txtFileName.Text);

            _decoder = new VideoDecoder();
            _decoder.Open(file);
            _decoder.PlayerOutputWidth  = _decoder.VideoInfo.Width;
            _decoder.PlayerOutputHeight = _decoder.VideoInfo.Height;

            Dispatcher.Invoke(() =>
            {
                sliderTime.Minimum = 0;
                sliderTime.Maximum = _decoder.VideoInfo.TotalFrames - 1;
            });

            if (iterator == null)
            {
                iterator = new FrameIterator(_decoder.VideoInfo.TotalFrames,
                                             templateView.TemplatePaths.Keys.Count,
                                             AppSettings.Default.BurstSize
                                             );

                var startFrame = (int)Math.Round(AppSettings.Default.StartTime * _decoder.VideoInfo.FPS);
                var endFrame   = (int)Math.Round(AppSettings.Default.EndTime * _decoder.VideoInfo.FPS);

                if (AppSettings.Default.UseRandom)
                {
                    iterator.InitRandomSequence(
                        AppSettings.Default.MaxFrames,
                        Math.Max(0, startFrame),
                        Math.Min(_decoder.VideoInfo.TotalFrames, endFrame) - 1,
                        AppSettings.Default.UseSeed ? AppSettings.Default.Seed : (int?)null
                        );
                }
                else
                {
                    iterator.InitLinearSequence(
                        AppSettings.Default.EveryNth,
                        Math.Max(0, startFrame),
                        Math.Min(_decoder.VideoInfo.TotalFrames - 1, endFrame)
                        );
                }
            }

            _decoder.SeekTo(iterator.BurstBeginFrameIndex);
            _decoder.Start();
            _decoder.FrameDecoder.FrameBufferCapacity  = 1;
            _decoder.FrameDecoder.MinimumWorkingFrames = 1;
        }