IMediaPlayerSourceObserver.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System;
  2. namespace Agora.Rtc
  3. {
  4. ///
  5. /// <summary>
  6. /// Provides callbacks for media players.
  7. /// </summary>
  8. ///
  9. public abstract class IMediaPlayerSourceObserver
  10. {
  11. ///
  12. /// <summary>
  13. /// Reports the playback state change.
  14. /// When the state of the media player changes, the SDK triggers this callback to report the current playback state.
  15. /// </summary>
  16. ///
  17. /// <param name="state"> The playback state, see MEDIA_PLAYER_STATE .</param>
  18. ///
  19. /// <param name="ec"> The error code. See MEDIA_PLAYER_ERROR .</param>
  20. ///
  21. public virtual void OnPlayerSourceStateChanged(MEDIA_PLAYER_STATE state, MEDIA_PLAYER_ERROR ec) { }
  22. ///
  23. /// <summary>
  24. /// Reports current playback progress.
  25. /// When playing media files, the SDK triggers this callback every one second to report current playback progress.
  26. /// </summary>
  27. ///
  28. /// <param name="position_ms"> The playback position (ms) of media files.</param>
  29. ///
  30. public virtual void OnPositionChanged(Int64 position_ms) { }
  31. ///
  32. /// <summary>
  33. /// Reports the playback event.
  34. /// After calling the Seek method, the SDK triggers the callback to report the results of the seek operation.
  35. /// </summary>
  36. ///
  37. /// <param name="eventCode"> The playback event. See MEDIA_PLAYER_EVENT .</param>
  38. ///
  39. /// <param name="elapsedTime"> The time (ms) when the event occurs.</param>
  40. ///
  41. /// <param name="message"> Information about the event.</param>
  42. ///
  43. public virtual void OnPlayerEvent(MEDIA_PLAYER_EVENT eventCode, Int64 elapsedTime, string message) { }
  44. ///
  45. /// <summary>
  46. /// Occurs when the media metadata is received.
  47. /// The callback occurs when the player receives the media metadata and reports the detailed information of the media metadata.
  48. /// </summary>
  49. ///
  50. /// <param name="data"> The detailed data of the media metadata.</param>
  51. ///
  52. /// <param name="length"> The data length (bytes).</param>
  53. ///
  54. public virtual void OnMetaData(byte[] data, int length) { }
  55. ///
  56. /// <summary>
  57. /// Reports the playback duration that the buffered data can support.
  58. /// When playing online media resources, the SDK triggers this callback every two seconds to report the playback duration that the currently buffered data can support.When the playback duration supported by the buffered data is less than the threshold (0 by default), the SDK returns PLAYER_EVENT_BUFFER_LOW.When the playback duration supported by the buffered data is greater than the threshold (0 by default), the SDK returns PLAYER_EVENT_BUFFER_RECOVER.
  59. /// </summary>
  60. ///
  61. /// <param name="playCachedBuffer"> The playback duration (ms) that the buffered data can support.</param>
  62. ///
  63. public virtual void OnPlayBufferUpdated(Int64 playCachedBuffer) { }
  64. ///
  65. /// <summary>
  66. /// Reports the events of preloaded media resources.
  67. /// </summary>
  68. ///
  69. /// <param name="src"> The URL of the media resource.</param>
  70. ///
  71. /// <param name="@event"> Events that occur when media resources are preloaded. See PLAYER_PRELOAD_EVENT .</param>
  72. ///
  73. public virtual void OnPreloadEvent(string src, PLAYER_PRELOAD_EVENT @event) { }
  74. ///
  75. /// <summary>
  76. /// Occurs when the media file is played once.
  77. /// </summary>
  78. ///
  79. public virtual void OnCompleted() { }
  80. ///
  81. /// <summary>
  82. /// Occurs when the token is about to expire.
  83. /// If the ts is about to expire when you call the SwitchAgoraCDNLineByIndex method to switch the CDN route for playing the media resource, the SDK triggers this callback to remind you to renew the authentication information. You need to call the RenewAgoraCDNSrcToken method to pass in the updated authentication information to update the authentication information of the media resource URL. After updating the authentication information, you need to call SwitchAgoraCDNLineByIndex to complete the route switching.
  84. /// </summary>
  85. ///
  86. public virtual void OnAgoraCDNTokenWillExpire() { }
  87. ///
  88. /// <summary>
  89. /// Occurs when the video bitrate of the media resource changes.
  90. /// </summary>
  91. ///
  92. /// <param name="from"> Information about the video bitrate of the media resource being played. See SrcInfo .</param>
  93. ///
  94. /// <param name="to"> Information about the changed video bitrate of media resource being played. See SrcInfo .</param>
  95. ///
  96. public virtual void OnPlayerSrcInfoChanged(SrcInfo from, SrcInfo to) { }
  97. ///
  98. /// <summary>
  99. /// Occurs when information related to the media player changes.
  100. /// When the information about the media player changes, the SDK triggers this callback. You can use this callback for troubleshooting.
  101. /// </summary>
  102. ///
  103. /// <param name="info"> Information related to the media player. See PlayerUpdatedInfo .</param>
  104. ///
  105. public virtual void OnPlayerInfoUpdated(PlayerUpdatedInfo info) { }
  106. ///
  107. /// <summary>
  108. /// Reports the volume of the media player.
  109. /// The SDK triggers this callback every 200 milliseconds to report the current volume of the media player.
  110. /// </summary>
  111. ///
  112. /// <param name="volume"> The volume of the media player. The value ranges from 0 to 255.</param>
  113. ///
  114. public virtual void OnAudioVolumeIndication(int volume) { }
  115. }
  116. }