Beispiel #1
0
        private Task <string> CreateSubtitleFile(string mediaItemFilePath)
        {
            return(Task.Run(() =>
            {
                if (_mediaElement is MediaElementMediaFoundation &&
                    _optionsService.ShowVideoSubtitles)
                {
                    return SubtitleFileGenerator.Generate(mediaItemFilePath, _mediaItemId);
                }

                return null;
            }));
        }
Beispiel #2
0
        private void CreateSubtitleProvider(string mediaItemFilePath, TimeSpan videoHeadPosition)
        {
            if (_subTitleProvider != null)
            {
                _subTitleProvider.SubtitleEvent -= HandleSubtitleEvent;
                _subTitleProvider = null;
            }

            if (_mediaClassification == MediaClassification.Video &&
                _mediaElement is MediaElementMediaFoundation)
            {
                // accommodate any latency introduced by creation of srt file
                var sw      = Stopwatch.StartNew();
                var srtFile = SubtitleFileGenerator.Generate(mediaItemFilePath);
                videoHeadPosition += sw.Elapsed;

                _subTitleProvider = new SubtitleProvider(srtFile, videoHeadPosition);
                _subTitleProvider.SubtitleEvent += HandleSubtitleEvent;
            }
        }