TextTrack.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. //-----------------------------------------------------------------------------
  5. // Copyright 2015-2021 RenderHeads Ltd. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. namespace RenderHeads.Media.AVProVideo
  8. {
  9. public class TextCue
  10. {
  11. private TextCue() { }
  12. internal TextCue(string text)
  13. {
  14. Text = text;
  15. }
  16. public string Text { get; private set; }
  17. }
  18. public partial class BaseMediaPlayer : ITextTracks
  19. {
  20. protected TextCue _currentTextCue = null;
  21. public TextCue GetCurrentTextCue() { return _currentTextCue; } // Returns null when there is no active text
  22. protected bool UpdateTextCue(bool force = false)
  23. {
  24. bool result = false;
  25. // Has it changed since the last 'tick'
  26. if (force || InternalIsChangedTextCue())
  27. {
  28. _currentTextCue = null;
  29. string text = InternalGetCurrentTextCue();
  30. if (!string.IsNullOrEmpty(text))
  31. {
  32. _currentTextCue = new TextCue(text);
  33. }
  34. result = true;
  35. }
  36. return result;
  37. }
  38. internal abstract bool InternalIsChangedTextCue();
  39. internal abstract string InternalGetCurrentTextCue();
  40. }
  41. }