예제 #1
0
        /// <summary>
        /// Renders the specified media block.
        /// </summary>
        /// <param name="mediaBlock">The media block.</param>
        /// <param name="clockPosition">The clock position.</param>
        public void Render(MediaBlock mediaBlock, TimeSpan clockPosition)
        {
            lock (SyncLock)
            {
                var subtitleBlock = mediaBlock as SubtitleBlock;
                if (subtitleBlock == null)
                {
                    return;
                }

                // Save the start and end times. We will need
                // them in order to make the subtitles disappear
                StartTime = subtitleBlock.StartTime;
                EndTime   = subtitleBlock.EndTime;

                // Raise the subtitles event and keep track of the text.
                BlockText = MediaElement.RaiseRenderingSubtitlesEvent(subtitleBlock, clockPosition)
                    ? string.Empty
                    : string.Join("\r\n", subtitleBlock.Text);

                // Call the selective update method
                Update(clockPosition);
            }
        }
예제 #2
0
        /// <inheritdoc />
        public void Render(MediaBlock mediaBlock, TimeSpan clockPosition)
        {
            lock (SyncLock)
            {
                if (mediaBlock is SubtitleBlock == false)
                {
                    return;
                }

                // Get a reference to the subtitle block
                var subtitleBlock = (SubtitleBlock)mediaBlock;

                // Raise the subtitles event and keep track of the text.
                var cancelRender = MediaElement.RaiseRenderingSubtitlesEvent(subtitleBlock, clockPosition);

                if (cancelRender)
                {
                    BlockText = string.Empty;
                    StartTime = null;
                    EndTime   = null;
                }
                else
                {
                    // Save the block text lines to display
                    BlockText = string.Join("\r\n", subtitleBlock.Text);

                    // Save the start and end times. We will need
                    // them in order to make the subtitles disappear
                    StartTime = subtitleBlock.StartTime;
                    EndTime   = subtitleBlock.EndTime;
                }

                // Call the selective update method
                Update(clockPosition);
            }
        }