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. * groupId: ?string,
  57. * startTime: number,
  58. * endTime: ?number,
  59. * uri: string,
  60. * mimeType: ?string,
  61. * isSkippable: boolean,
  62. * skipOffset: ?number,
  63. * skipFor: ?number,
  64. * canJump: boolean,
  65. * resumeOffset: ?number,
  66. * playoutLimit: ?number,
  67. * once: boolean,
  68. * pre: boolean,
  69. * post: boolean,
  70. * timelineRange: boolean,
  71. * loop: boolean,
  72. * overlay: ?shaka.extern.AdInterstitialOverlay
  73. * }}
  74. *
  75. * @description
  76. * Contains the ad interstitial info.
  77. *
  78. * @property {?string} id
  79. * The id of the interstitial.
  80. * @property {?string} groupId
  81. * The group id of the interstitial.
  82. * @property {number} startTime
  83. * The start time of the interstitial.
  84. * @property {?number} endTime
  85. * The end time of the interstitial.
  86. * @property {string} uri
  87. * The uri of the interstitial, can be any type that
  88. * ShakaPlayer supports (either in MSE or src=)
  89. * @property {?string} mimeType
  90. * The mimeType of the interstitial if known.
  91. * @property {boolean} isSkippable
  92. * Indicate if the interstitial is skippable.
  93. * @property {?number} skipOffset
  94. * Time value that identifies when skip controls are made available to the
  95. * end user.
  96. * @property {?number} skipFor
  97. * The amount of time in seconds a skip button should be displayed for.
  98. * Note that this value should be >= 0.
  99. * @property {boolean} canJump
  100. * Indicate if the interstitial is jumpable.
  101. * @property {?number} resumeOffset
  102. * Indicates where the primary playback will resume after the interstitial
  103. * plays. It is expressed as a time lag from when interstitial playback was
  104. * scheduled on the primary player's timeline. For live ad replacement it
  105. * must be null.
  106. * @property {?number} playoutLimit
  107. * Indicate a limit for the playout time of the entire interstitial.
  108. * @property {boolean} once
  109. * Indicates that the interstitial should only be played once.
  110. * @property {boolean} pre
  111. * Indicates that an action is to be triggered before playback of the
  112. * primary asset begins, regardless of where playback begins in the primary
  113. * asset.
  114. * @property {boolean} post
  115. * Indicates that an action is to be triggered after the primary asset has
  116. * been played to its end without error.
  117. * @property {boolean} timelineRange
  118. * Indicates whether the interstitial should be presented in a timeline UI
  119. * as a single point or as a range.
  120. * @property {boolean} loop
  121. * Indicates that the interstitials should play in loop.
  122. * Only applies if the interstitials is an overlay.
  123. * Only supported when using multiple video elements for interstitials.
  124. * @property {?shaka.extern.AdInterstitialOverlay} overlay
  125. * Indicates the characteristics of the overlay
  126. * Only supported when using multiple video elements for interstitials.
  127. * @exportDoc
  128. */
  129. shaka.extern.AdInterstitial;
  130. /**
  131. * @typedef {{
  132. * viewport: {x: number, y: number},
  133. * topLeft: {x: number, y: number},
  134. * size: {x: number, y: number}
  135. * }}
  136. *
  137. * @description
  138. * Contains the ad interstitial overlay info.
  139. *
  140. * @property {{x: number, y: number}} viewport
  141. * The viewport in pixels.
  142. * @property {{x: number, y: number}} topLeft
  143. * The topLeft in pixels.
  144. * @property {{x: number, y: number}} size
  145. * The size in pixels.
  146. * @exportDoc
  147. */
  148. shaka.extern.AdInterstitialOverlay;
  149. /**
  150. * An object that's responsible for all the ad-related logic
  151. * in the player.
  152. *
  153. * @interface
  154. * @exportDoc
  155. */
  156. shaka.extern.IAdManager = class extends EventTarget {
  157. /**
  158. * @param {string} locale
  159. */
  160. setLocale(locale) {}
  161. /**
  162. * Called by the Player to provide an updated configuration any time it
  163. * changes.
  164. * Must be called at least once before init*().
  165. *
  166. * @param {shaka.extern.AdsConfiguration} config
  167. */
  168. configure(config) {}
  169. release() {}
  170. onAssetUnload() {}
  171. /**
  172. * @param {?HTMLElement} adContainer
  173. * @param {!shaka.Player} basePlayer
  174. * @param {!HTMLMediaElement} baseVideo
  175. */
  176. initInterstitial(adContainer, basePlayer, baseVideo) {}
  177. /**
  178. * @param {!HTMLElement} adContainer
  179. * @param {!HTMLMediaElement} video
  180. * @param {?google.ima.AdsRenderingSettings} adsRenderingSettings
  181. */
  182. initClientSide(adContainer, video, adsRenderingSettings) {}
  183. /**
  184. * @param {!google.ima.AdsRequest} imaRequest
  185. */
  186. requestClientSideAds(imaRequest) {}
  187. /**
  188. * @param {!google.ima.AdsRenderingSettings} adsRenderingSettings
  189. */
  190. updateClientSideAdsRenderingSettings(adsRenderingSettings) {}
  191. /**
  192. * @param {!HTMLElement} adContainer
  193. * @param {!shaka.net.NetworkingEngine} networkingEngine
  194. * @param {!HTMLMediaElement} video
  195. */
  196. initMediaTailor(adContainer, networkingEngine, video) {}
  197. /**
  198. * @param {string} url
  199. * @param {Object} adsParams
  200. * @param {string=} backupUrl
  201. * @return {!Promise<string>}
  202. */
  203. requestMediaTailorStream(url, adsParams, backupUrl) {}
  204. /**
  205. * @param {string} url
  206. */
  207. addMediaTailorTrackingUrl(url) {}
  208. /**
  209. * @param {!HTMLElement} adContainer
  210. * @param {!HTMLMediaElement} video
  211. */
  212. initServerSide(adContainer, video) {}
  213. /**
  214. * @param {!google.ima.dai.api.StreamRequest} imaRequest
  215. * @param {string=} backupUrl
  216. * @return {!Promise<string>}
  217. */
  218. requestServerSideStream(imaRequest, backupUrl) {}
  219. /**
  220. * @param {Object} adTagParameters
  221. */
  222. replaceServerSideAdTagParameters(adTagParameters) {}
  223. /**
  224. * @return {!Array<!shaka.extern.AdCuePoint>}
  225. */
  226. getServerSideCuePoints() {}
  227. /**
  228. * @return {!Array<!shaka.extern.AdCuePoint>}
  229. */
  230. getCuePoints() {}
  231. /**
  232. * Get statistics for the current playback session. If the player is not
  233. * playing content, this will return an empty stats object.
  234. */
  235. getStats() {}
  236. /**
  237. * @param {shaka.extern.TimelineRegionInfo} region
  238. */
  239. onDashTimedMetadata(region) {}
  240. /**
  241. * Fired when the manifest is updated.
  242. *
  243. * @param {boolean} isLive
  244. */
  245. onManifestUpdated(isLive) {}
  246. /**
  247. * @param {shaka.extern.ID3Metadata} metadata
  248. * @param {number} timestampOffset
  249. */
  250. onHlsTimedMetadata(metadata, timestampOffset) {}
  251. /**
  252. * @param {shaka.extern.MetadataFrame} value
  253. */
  254. onCueMetadataChange(value) {}
  255. /**
  256. * @param {!shaka.Player} basePlayer
  257. * @param {!HTMLMediaElement} baseVideo
  258. * @param {shaka.extern.HLSInterstitial} interstitial
  259. */
  260. onHLSInterstitialMetadata(basePlayer, baseVideo, interstitial) {}
  261. /**
  262. * @param {!shaka.Player} basePlayer
  263. * @param {!HTMLMediaElement} baseVideo
  264. * @param {shaka.extern.TimelineRegionInfo} region
  265. */
  266. onDASHInterstitialMetadata(basePlayer, baseVideo, region) {}
  267. /**
  268. * @param {shaka.extern.AdInterstitial} interstitial
  269. */
  270. addCustomInterstitial(interstitial) {}
  271. /**
  272. * @param {string} url
  273. * @return {!Promise}
  274. */
  275. addAdUrlInterstitial(url) {}
  276. /**
  277. * @return {shaka.Player}
  278. */
  279. getInterstitialPlayer() {}
  280. };
  281. /**
  282. * A factory for creating the ad manager.
  283. *
  284. * @typedef {function():!shaka.extern.IAdManager}
  285. * @exportDoc
  286. */
  287. shaka.extern.IAdManager.Factory;
  288. /**
  289. * Interface for Ad objects.
  290. *
  291. * @extends {shaka.util.IReleasable}
  292. * @interface
  293. * @exportDoc
  294. */
  295. shaka.extern.IAd = class {
  296. /**
  297. * @return {boolean}
  298. */
  299. needsSkipUI() {}
  300. /**
  301. * @return {boolean}
  302. */
  303. isClientRendering() {}
  304. /**
  305. * @return {boolean}
  306. */
  307. hasCustomClick() {}
  308. /**
  309. * @return {boolean}
  310. */
  311. isUsingAnotherMediaElement() {}
  312. /**
  313. * @return {number}
  314. */
  315. getDuration() {}
  316. /**
  317. * Gets the minimum suggested duration. Defaults to being equivalent to
  318. * getDuration() for server-side ads.
  319. * @see http://bit.ly/3q3U6hI
  320. * @return {number}
  321. */
  322. getMinSuggestedDuration() {}
  323. /**
  324. * @return {number}
  325. */
  326. getRemainingTime() {}
  327. /**
  328. * @return {number}
  329. */
  330. getTimeUntilSkippable() {}
  331. /**
  332. * @return {boolean}
  333. */
  334. isPaused() {}
  335. /**
  336. * @return {boolean}
  337. */
  338. isSkippable() {}
  339. /**
  340. * @return {boolean}
  341. */
  342. canSkipNow() {}
  343. skip() {}
  344. play() {}
  345. pause() {}
  346. /**
  347. * @return {number}
  348. */
  349. getVolume() {}
  350. /**
  351. * @param {number} volume
  352. */
  353. setVolume(volume) {}
  354. /**
  355. * @return {boolean}
  356. */
  357. isMuted() {}
  358. /**
  359. * @param {boolean} muted
  360. */
  361. setMuted(muted) {}
  362. /**
  363. * @return {boolean}
  364. */
  365. isLinear() {}
  366. /**
  367. * @param {number} width
  368. * @param {number} height
  369. */
  370. resize(width, height) {}
  371. /**
  372. * @return {number}
  373. */
  374. getSequenceLength() {}
  375. /**
  376. * @return {number}
  377. */
  378. getPositionInSequence() {}
  379. /**
  380. * @return {string}
  381. */
  382. getTitle() {}
  383. /**
  384. * @return {string}
  385. */
  386. getDescription() {}
  387. /**
  388. * @return {number}
  389. */
  390. getVastMediaBitrate() {}
  391. /**
  392. * @return {number}
  393. */
  394. getVastMediaHeight() {}
  395. /**
  396. * @return {number}
  397. */
  398. getVastMediaWidth() {}
  399. /**
  400. * @return {string}
  401. */
  402. getAdId() {}
  403. /**
  404. * @return {string}
  405. */
  406. getCreativeAdId() {}
  407. /**
  408. * @return {string}
  409. */
  410. getAdvertiserName() {}
  411. /**
  412. * @return {?string}
  413. */
  414. getMediaUrl() {}
  415. /**
  416. * @return {number}
  417. */
  418. getTimeOffset() {}
  419. /**
  420. * @return {number}
  421. */
  422. getPodIndex() {}
  423. };