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