public async Task OnTorrentLoaded(object sender, TorrentStateChangedEventArgs e)
        {
            _parser = new EbmlParser(_dataAccessor, ElementFactories);
            await GetDoc();

            PlayerStatus = MatroskaPlayerStatus.LoadingMovieDetails;
        }
        private async Task ParseDocument()
        {
            if (_parser is null)
            {
                throw new InvalidOperationException("Can't parse document if parser has not been set yet");
            }
            await _documentParserSemaphore.WaitAsync();

            try
            {
                if (PlayerStatus == MatroskaPlayerStatus.Playable)
                {
                    return;
                }

                var cues = await _document !.Body !.TryParse <Cues>(_parser);
                if (cues != null)
                {
                    await cues.Decode(_parser);

                    if (cues.Decoded)
                    {
                        Console.WriteLine(cues);
                        PlayerStatus = MatroskaPlayerStatus.Playable;
                    }
                }
                else
                {
                    var seek = await _document.Body.TryParse <SeekHead>(_parser);

                    if (seek != null)
                    {
                        await seek.Decode(_parser);

                        if (seek.Decoded)
                        {
                            Console.WriteLine(seek);
                        }
                    }
                }
            }
            catch (FileNotLoadedException) { }
            catch (InvalidIdException) { }
            finally
            {
                _documentParserSemaphore.Release(1);
            }
        }
        private async Task TryIndexDocument(int index)
        {
            if (_parser is null)
            {
                throw new InvalidOperationException("Can't parse document if parser has not been set yet");
            }

            lock (_indexLock)
            {
                if (_isIndexing || !_hashedPieces.Contains(index))
                {
                    return;
                }
                _isIndexing = true;
            }
            Console.WriteLine("Entering");

            try
            {
                if (PlayerStatus == MatroskaPlayerStatus.Playable)
                {
                    return;
                }
                Console.WriteLine($"Flushing {index}");
                await _manager.Engine.DiskManager.FlushAsync(_manager.Torrent, index).ConfigureAwait(false);

                Cues?cues = null;
                try
                {
                    cues = await _document !.Body !.TryGetChild <Cues>(_parser);
                }
                catch (DecodeException exception)
                {
                    Console.WriteLine(exception.Message);
                    Console.WriteLine(_document);
                }
                if (cues != null)
                {
                    await cues.Decode(_parser);

                    if (cues.Decoded)
                    {
                        PlayerStatus = MatroskaPlayerStatus.Playable;
                        Console.WriteLine("Ready to start");
                    }
                }
                else
                {
                    if (await _document.Body.TryGetChild <SeekHead>(_parser) is {} seekMaster)
                    {
                        await seekMaster.Decode(_parser);

                        if (seekMaster.Decoded)
                        {
                            foreach (Seek seek in seekMaster.Values)
                            {
                                if (seek.SeekId == (ulong)MatroskaIds.CuesId.Size)
                                {
                                    var element = await _parser.ParseElementAt((long)seek.SeekPosition !);

                                    Console.WriteLine(element);
                                }
                            }
                        }
                    }
                }
            }
            catch (FileNotLoadedException) { Console.WriteLine("Failed to load"); }
            catch (InvalidIdException) { Console.WriteLine("Invalid ID"); }
            finally
            {
                Console.WriteLine("Exiting");
                _isIndexing = false;
                await TryIndexDocument(index + 1);
            }
        }