Source: externs/shaka/ads.js

  1. /*! @license
  2. * Shaka Player
  3. * Copyright 2016 Google LLC
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @externs
  8. */
  9. /**
  10. * @typedef {{
  11. * loadTimes: !Array.<number>,
  12. * averageLoadTime: number,
  13. * started: number,
  14. * playedCompletely: number,
  15. * skipped: number,
  16. * errors: number
  17. * }}
  18. *
  19. * @description
  20. * Contains statistics and information about the current state of the player.
  21. *
  22. * @property {number} loadTimes
  23. * The set of amounts of time it took to get the final manifest.
  24. * @property {number} averageLoadTime
  25. * The average time it took to get the final manifest.
  26. * @property {number} started
  27. * The number of ads started.
  28. * @property {number} playedCompletely
  29. * The number of ads played completely.
  30. * @property {number} skipped
  31. * The number of ads skipped.
  32. * @property {number} errors
  33. * The number of ads with errors.
  34. * @exportDoc
  35. */
  36. shaka.extern.AdsStats;
  37. /**
  38. * @typedef {{
  39. * start: number,
  40. * end: ?number
  41. * }}
  42. *
  43. * @description
  44. * Contains the times of a range of an Ad.
  45. *
  46. * @property {number} start
  47. * The start time of the range, in milliseconds.
  48. * @property {number} end
  49. * The end time of the range, in milliseconds.
  50. * @exportDoc
  51. */
  52. shaka.extern.AdCuePoint;
  53. /**
  54. * @typedef {{
  55. * id: ?string,
  56. * startTime: number,
  57. * endTime: ?number,
  58. * uri: string,
  59. * isSkippable: boolean,
  60. * skipOffset: ?number,
  61. * canJump: boolean,
  62. * resumeOffset: ?number,
  63. * playoutLimit: ?number,
  64. * once: boolean,
  65. * pre: boolean,
  66. * post: boolean,
  67. * timelineRange: boolean
  68. * }}
  69. *
  70. * @description
  71. * Contains the ad interstitial info.
  72. *
  73. * @property {?string} id
  74. * The id of the interstitial.
  75. * @property {number} startTime
  76. * The start time of the interstitial.
  77. * @property {?number} endTime
  78. * The end time of the interstitial.
  79. * @property {string} uri
  80. * The uri of the interstitial, can be any type that
  81. * ShakaPlayer supports (either in MSE or src=)
  82. * @property {boolean} isSkippable
  83. * Indicate if the interstitial is skippable.
  84. * @property {?number} skipOffset
  85. * Time value that identifies when skip controls are made available to the
  86. * end user.
  87. * @property {boolean} canJump
  88. * Indicate if the interstitial is jumpable.
  89. * @property {?number} resumeOffset
  90. * Indicates where the primary playback will resume after the interstitial
  91. * plays. It is expressed as a time lag from when interstitial playback was
  92. * scheduled on the primary player's timeline. For live ad replacement it
  93. * must be null.
  94. * @property {?number} playoutLimit
  95. * Indicate a limit for the playout time of the entire interstitial.
  96. * @property {boolean} once
  97. * Indicates that the interstitial should only be played once.
  98. * @property {boolean} pre
  99. * Indicates that an action is to be triggered before playback of the
  100. * primary asset begins, regardless of where playback begins in the primary
  101. * asset.
  102. * @property {boolean} post
  103. * Indicates that an action is to be triggered after the primary asset has
  104. * been played to its end without error.
  105. * @property {boolean} timelineRange
  106. * Indicates whether the interstitial should be presented in a timeline UI
  107. * as a single point or as a range.
  108. */
  109. shaka.extern.AdInterstitial;
  110. /**
  111. * An object that's responsible for all the ad-related logic
  112. * in the player.
  113. *
  114. * @interface
  115. * @exportDoc
  116. */
  117. shaka.extern.IAdManager = class extends EventTarget {
  118. /**
  119. * @param {string} locale
  120. */
  121. setLocale(locale) {}
  122. /**
  123. * Called by the Player to provide an updated configuration any time it
  124. * changes.
  125. * Must be called at least once before init*().
  126. *
  127. * @param {shaka.extern.AdsConfiguration} config
  128. */
  129. configure(config) {}
  130. release() {}
  131. onAssetUnload() {}
  132. /**
  133. * @param {?HTMLElement} adContainer
  134. * @param {!shaka.Player} basePlayer
  135. * @param {!HTMLMediaElement} baseVideo
  136. */
  137. initInterstitial(adContainer, basePlayer, baseVideo) {}
  138. /**
  139. * @param {!HTMLElement} adContainer
  140. * @param {!HTMLMediaElement} video
  141. * @param {?google.ima.AdsRenderingSettings} adsRenderingSettings
  142. */
  143. initClientSide(adContainer, video, adsRenderingSettings) {}
  144. /**
  145. * @param {!google.ima.AdsRequest} imaRequest
  146. */
  147. requestClientSideAds(imaRequest) {}
  148. /**
  149. * @param {!google.ima.AdsRenderingSettings} adsRenderingSettings
  150. */
  151. updateClientSideAdsRenderingSettings(adsRenderingSettings) {}
  152. /**
  153. * @param {!HTMLElement} adContainer
  154. * @param {!shaka.net.NetworkingEngine} networkingEngine
  155. * @param {!HTMLMediaElement} video
  156. */
  157. initMediaTailor(adContainer, networkingEngine, video) {}
  158. /**
  159. * @param {string} url
  160. * @param {Object} adsParams
  161. * @param {string=} backupUrl
  162. * @return {!Promise.<string>}
  163. */
  164. requestMediaTailorStream(url, adsParams, backupUrl) {}
  165. /**
  166. * @param {string} url
  167. */
  168. addMediaTailorTrackingUrl(url) {}
  169. /**
  170. * @param {!HTMLElement} adContainer
  171. * @param {!HTMLMediaElement} video
  172. */
  173. initServerSide(adContainer, video) {}
  174. /**
  175. * @param {!google.ima.dai.api.StreamRequest} imaRequest
  176. * @param {string=} backupUrl
  177. * @return {!Promise.<string>}
  178. */
  179. requestServerSideStream(imaRequest, backupUrl) {}
  180. /**
  181. * @param {Object} adTagParameters
  182. */
  183. replaceServerSideAdTagParameters(adTagParameters) {}
  184. /**
  185. * @return {!Array.<!shaka.extern.AdCuePoint>}
  186. */
  187. getServerSideCuePoints() {}
  188. /**
  189. * @return {!Array.<!shaka.extern.AdCuePoint>}
  190. */
  191. getCuePoints() {}
  192. /**
  193. * Get statistics for the current playback session. If the player is not
  194. * playing content, this will return an empty stats object.
  195. */
  196. getStats() {}
  197. /**
  198. * @param {shaka.extern.TimelineRegionInfo} region
  199. */
  200. onDashTimedMetadata(region) {}
  201. /**
  202. * Fired when the manifest is updated.
  203. *
  204. * @param {boolean} isLive
  205. */
  206. onManifestUpdated(isLive) {}
  207. /**
  208. * @param {shaka.extern.ID3Metadata} metadata
  209. * @param {number} timestampOffset
  210. */
  211. onHlsTimedMetadata(metadata, timestampOffset) {}
  212. /**
  213. * @param {shaka.extern.MetadataFrame} value
  214. */
  215. onCueMetadataChange(value) {}
  216. /**
  217. * @param {!shaka.Player} basePlayer
  218. * @param {!HTMLMediaElement} baseVideo
  219. * @param {shaka.extern.HLSInterstitial} interstitial
  220. */
  221. onHLSInterstitialMetadata(basePlayer, baseVideo, interstitial) {}
  222. /**
  223. * @param {!shaka.Player} basePlayer
  224. * @param {!HTMLMediaElement} baseVideo
  225. * @param {shaka.extern.TimelineRegionInfo} region
  226. */
  227. onDASHInterstitialMetadata(basePlayer, baseVideo, region) {}
  228. /**
  229. * @param {shaka.extern.AdInterstitial} interstitial
  230. */
  231. addCustomInterstitial(interstitial) {}
  232. /**
  233. * @param {string} url
  234. * @return {!Promise}
  235. */
  236. addAdUrlInterstitial(url) {}
  237. };
  238. /**
  239. * A factory for creating the ad manager.
  240. *
  241. * @typedef {function():!shaka.extern.IAdManager}
  242. * @exportDoc
  243. */
  244. shaka.extern.IAdManager.Factory;
  245. /**
  246. * Interface for Ad objects.
  247. *
  248. * @extends {shaka.util.IReleasable}
  249. * @interface
  250. * @exportDoc
  251. */
  252. shaka.extern.IAd = class {
  253. /**
  254. * @return {boolean}
  255. */
  256. needsSkipUI() {}
  257. /**
  258. * @return {number}
  259. */
  260. getDuration() {}
  261. /**
  262. * Gets the minimum suggested duration. Defaults to being equivalent to
  263. * getDuration() for server-side ads.
  264. * @see http://bit.ly/3q3U6hI
  265. * @return {number}
  266. */
  267. getMinSuggestedDuration() {}
  268. /**
  269. * @return {number}
  270. */
  271. getRemainingTime() {}
  272. /**
  273. * @return {number}
  274. */
  275. getTimeUntilSkippable() {}
  276. /**
  277. * @return {boolean}
  278. */
  279. isPaused() {}
  280. /**
  281. * @return {boolean}
  282. */
  283. isSkippable() {}
  284. /**
  285. * @return {boolean}
  286. */
  287. canSkipNow() {}
  288. skip() {}
  289. play() {}
  290. pause() {}
  291. /**
  292. * @return {number}
  293. */
  294. getVolume() {}
  295. /**
  296. * @param {number} volume
  297. */
  298. setVolume(volume) {}
  299. /**
  300. * @return {boolean}
  301. */
  302. isMuted() {}
  303. /**
  304. * @param {boolean} muted
  305. */
  306. setMuted(muted) {}
  307. /**
  308. * @return {boolean}
  309. */
  310. isLinear() {}
  311. /**
  312. * @param {number} width
  313. * @param {number} height
  314. */
  315. resize(width, height) {}
  316. /**
  317. * @return {number}
  318. */
  319. getSequenceLength() {}
  320. /**
  321. * @return {number}
  322. */
  323. getPositionInSequence() {}
  324. /**
  325. * @return {string}
  326. */
  327. getTitle() {}
  328. /**
  329. * @return {string}
  330. */
  331. getDescription() {}
  332. /**
  333. * @return {number}
  334. */
  335. getVastMediaBitrate() {}
  336. /**
  337. * @return {number}
  338. */
  339. getVastMediaHeight() {}
  340. /**
  341. * @return {number}
  342. */
  343. getVastMediaWidth() {}
  344. /**
  345. * @return {string}
  346. */
  347. getAdId() {}
  348. /**
  349. * @return {string}
  350. */
  351. getCreativeAdId() {}
  352. /**
  353. * @return {string}
  354. */
  355. getAdvertiserName() {}
  356. /**
  357. * @return {?string}
  358. */
  359. getMediaUrl() {}
  360. /**
  361. * @return {number}
  362. */
  363. getTimeOffset() {}
  364. /**
  365. * @return {number}
  366. */
  367. getPodIndex() {}
  368. };