peertube-videojs-typings.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import { PeerTubePlugin } from './peertube-plugin'
  2. import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
  3. import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin'
  4. import { PlayerMode } from './peertube-player-manager'
  5. import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
  6. import { VideoFile } from '@shared/models'
  7. import videojs from 'video.js'
  8. import { Config, Level } from 'hls.js'
  9. declare module 'video.js' {
  10. export interface VideoJsPlayer {
  11. srOptions_: HlsjsConfigHandlerOptions
  12. theaterEnabled: boolean
  13. // FIXME: add it to upstream typings
  14. posterImage: {
  15. show (): void
  16. hide (): void
  17. }
  18. handleTechSeeked_ (): void
  19. // Plugins
  20. peertube (): PeerTubePlugin
  21. webtorrent (): WebTorrentPlugin
  22. p2pMediaLoader (): P2pMediaLoaderPlugin
  23. contextmenuUI (options: any): any
  24. bezels (): void
  25. qualityLevels (): QualityLevels
  26. textTracks (): TextTrackList & {
  27. on: Function
  28. tracks_: { kind: string, mode: string, language: string }[]
  29. }
  30. audioTracks (): AudioTrackList
  31. dock (options: { title: string, description: string }): void
  32. }
  33. }
  34. export interface VideoJSTechHLS extends videojs.Tech {
  35. hlsProvider: any // FIXME: typings
  36. }
  37. export interface HlsjsConfigHandlerOptions {
  38. hlsjsConfig?: Config & { cueHandler: any }// FIXME: typings
  39. captionConfig?: any // FIXME: typings
  40. levelLabelHandler?: (level: Level) => string
  41. }
  42. type QualityLevelRepresentation = {
  43. id: number
  44. height: number
  45. label?: string
  46. width?: number
  47. bandwidth?: number
  48. bitrate?: number
  49. enabled?: Function
  50. _enabled: boolean
  51. }
  52. type QualityLevels = QualityLevelRepresentation[] & {
  53. selectedIndex: number
  54. selectedIndex_: number
  55. addQualityLevel (representation: QualityLevelRepresentation): void
  56. }
  57. type VideoJSCaption = {
  58. label: string
  59. language: string
  60. src: string
  61. }
  62. type UserWatching = {
  63. url: string,
  64. authorizationHeader: string
  65. }
  66. type PeerTubePluginOptions = {
  67. mode: PlayerMode
  68. autoplay: boolean
  69. videoViewUrl: string
  70. videoDuration: number
  71. userWatching?: UserWatching
  72. subtitle?: string
  73. videoCaptions: VideoJSCaption[]
  74. stopTime: number | string
  75. }
  76. type WebtorrentPluginOptions = {
  77. playerElement: HTMLVideoElement
  78. autoplay: boolean
  79. videoDuration: number
  80. videoFiles: VideoFile[]
  81. startTime: number | string
  82. }
  83. type P2PMediaLoaderPluginOptions = {
  84. redundancyUrlManager: RedundancyUrlManager
  85. type: string
  86. src: string
  87. startTime: number | string
  88. }
  89. type VideoJSPluginOptions = {
  90. peertube: PeerTubePluginOptions
  91. webtorrent?: WebtorrentPluginOptions
  92. p2pMediaLoader?: P2PMediaLoaderPluginOptions
  93. }
  94. type LoadedQualityData = {
  95. qualitySwitchCallback: Function,
  96. qualityData: {
  97. video: {
  98. id: number
  99. label: string
  100. selected: boolean
  101. }[]
  102. }
  103. }
  104. type ResolutionUpdateData = {
  105. auto: boolean,
  106. resolutionId: number
  107. id?: number
  108. }
  109. type AutoResolutionUpdateData = {
  110. possible: boolean
  111. }
  112. type PlayerNetworkInfo = {
  113. http: {
  114. downloadSpeed: number
  115. uploadSpeed: number
  116. downloaded: number
  117. uploaded: number
  118. }
  119. p2p: {
  120. downloadSpeed: number
  121. uploadSpeed: number
  122. downloaded: number
  123. uploaded: number
  124. numPeers: number
  125. }
  126. }
  127. export {
  128. PlayerNetworkInfo,
  129. ResolutionUpdateData,
  130. AutoResolutionUpdateData,
  131. VideoJSCaption,
  132. UserWatching,
  133. PeerTubePluginOptions,
  134. WebtorrentPluginOptions,
  135. P2PMediaLoaderPluginOptions,
  136. VideoJSPluginOptions,
  137. LoadedQualityData,
  138. QualityLevelRepresentation,
  139. QualityLevels
  140. }