diff --git a/docs/tutorials/index.json b/docs/tutorials/index.json index de50bf8976..766e43cdae 100644 --- a/docs/tutorials/index.json +++ b/docs/tutorials/index.json @@ -20,12 +20,6 @@ { "application-level-redirects": { "title": "Application-Level Redirects" } }, { "blob-url": { "title": "Blob URL" } }, { "faq": { "title": "Frequently Asked Questions" } }, - { "upgrade": { - "title": "Upgrade Guide", - "children": { - "upgrade-v2-5": { "title": "Upgrade Guide, v2.5 => v3" }, - "upgrade-v3": { "title": "Upgrade Guide, v3" }, - "upgrade-manifest": { "title": "Shaka Player Manifest Upgrade Guide" } - } - } } + { "upgrade": { "title": "Upgrade Guide" } }, + { "upgrade-manifest": { "title": "ManifestParser Upgrade Guide" } } ] diff --git a/docs/tutorials/upgrade-v2-5.md b/docs/tutorials/upgrade-v2-5.md deleted file mode 100644 index f4aba774b6..0000000000 --- a/docs/tutorials/upgrade-v2-5.md +++ /dev/null @@ -1,441 +0,0 @@ -# Shaka Upgrade Guide, v2.5 => v3.0 - -This is a detailed guide for upgrading from Shaka Player v2.5 to v3.0. -Feel free to skim or to search for the class and method names you are using in -your application. - - -#### What's New in v3.0? - -Shaka v3.0 introduces several improvements over v2.5, including: - - Ad-insertion APIs (integrated with the Google IMA SDK) - - Ad-related UI elements - - Offline storage operations can be aborted - - Support for concurrent operations in a single shaka.offline.Storage instance - - Config field `manifest.dash.defaultPresentationDelay` has been moved to - `manifest.defaultPresentationDelay` and now applies to both DASH & HLS - - New config field `streaming.inaccurateManifestTolerance` to control - assumptions about manifest accuracy - - New fields in getStats() - - Stable Track objects across DASH Periods - - New loop button available in UI overflow menu (`'loop'`, hidden by default) - - New playback rate submenu in UI overflow menu (`'playback_rate'`, shown by - default) - - -#### Player Factory parameter change - -The optional `Factory` parameter in `Player.load()` and `Storage.store()` has -been changed to a MIME type string. The `Factory` parameter was deprecated in -v2.5 and removed in v3.0. Applications MUST update to use MIME types instead of -explicit factories. Any registered factory can be referenced by its registered -MIME type. - -```js -// v2.4: -player.load('foo.mpd', /* startTime= */ 0, - /* factory= */ shaka.dash.DashParser); - -// v3.0: -player.load('foo.mpd', /* startTime= */ 0, - /* mimeType= */ 'application/dash+xml'); -``` - -See {@link shaka.Player#load} for details. - - -#### Manifest URI API change - -The method `Player.getManifestUri()` has been renamed to `Player.getAssetUri()`. -The older method was deprecated in v2.5 and was removed in v3.0. Applications -MUST update to the new method, whose name more accurately reflects our support -for non-manifest content. - -```js -// v2.4: -const uri = player.getManifestUri(); - -// v3.0: -const uri = player.getAssetUri(); -``` - - -#### UI API change - -In v2.5.1, the method `shaka.ui.Overlay.getPlayer()` was deprecated and moved -to `ui.getControls().getPlayer()`. In v3.0, the old location was removed. -Applications that use this method MUST update to the new location. - -```js -// v2.5: -const player = ui.getPlayer(); - -// v3.0: -const player = ui.getControls().getPlayer(); -``` - - -#### Embedded text (CEA 608/708) API change - -The CEA-specific methods `Player.selectEmbeddedTextTrack()` and -`Player.usingEmbeddedTextTrack()` were deprecated in v2.5 and were removed in -v3.0. CEA captions now show up in the standard text track APIs: -`getTextTracks()`, `selectTextTrack()`, `getTextLanguages()`, -`getTextLanguagesAndRoles()`, and `selectTextLanguage()`. Applications MUST -update to using the track APIs. If you have content with VTT or TTML subtitles, -you should already be using these APIs. - -```js -// v2.4: -player.selectEmbeddedTextTrack(); - -// v3.0: -const tracks = player.getTextTracks(); -const desiredTrack = someProcessToChooseOne(tracks); -player.selectTextTrack(desiredTrack); -``` - - -#### Utility method changes - -In v3.0, the method `shaka.util.Uint8ArrayUtils.equal` has been moved to -`shaka.util.BufferUtils.equal`. The new method supports both `ArrayBuffer` and -subclasses of `ArrayBufferView` like `Uint8Array`. - -Backward compatibility will be provided until v4.0. Applications SHOULD update -to use the new location. - -```js -// v2.5: -if (shaka.util.Uint8ArrayUtils.equal(array1, array2) { ... - -// v3.0: -if (shaka.util.BufferUtils.equal(array1, array2) { ... -``` - - -#### Configurable factory changes - -All configuration fields and plugin registration interfaces that accept -factories have been changed in v3.0. These factories SHOULD now be functions -that return an object and MAY be arrow functions. This makes our configuration -and plugin registration interfaces consistent and improves usability in some -cases. - -Backward compatibility is provided until v4.0. If we detect that a factory -needs to be called with `new`, we will do so and log a deprecation warning. -Applications SHOULD update their factories. - -This change affects the following types: - - - {@link shaka.extern.AbrManager.Factory} - - {@link shaka.extern.ManifestParser.Factory} - - {@link shaka.extern.TextDisplayer.Factory} - - {@link shaka.extern.TextParserPlugin} - -```js -// v2.5: -class MyAbrManager { - // ... -} -player.configure('abrFactory', MyAbrManager); - -class MyManifestParser { - // ... -} -shaka.media.ManifestParser.registerParserByMime('text/foo', MyManifestParser); - -// v3.0: -player.configure('abrFactory', () => new MyAbrManager()); -shaka.media.ManifestParser.registerParserByMime( - 'text/foo', () => new MyManifestParser()); -``` - - -#### FairPlay configuration changes - -The init data format in our Safari EME polyfill has been updated to match the -init data format of Safari's unprefixed EME implementation. This means init -data will arrive in the "skd" format, which is different from what was provided -by the polyfill in v2.5. This format is a buffer containing a UTF-8 string, -which is a URL that begins with `skd://`. Init data processing done by the -`drm.initDataTransform` callback MUST be updated. - -The signature of the configurable callback `drm.initDataTransform` has changed. -Applications using this for FairPlay content MUST update their callbacks. A -new parameter has been added to the callback signature. - -```js -// v2.5: -function initDataTransform(/** Uint8Array */ initData, - /** shaka.extern.DrmInfo */ drmInfo) {} - -// v3.0: -function initDataTransform(/** Uint8Array */ initData, - /** string */ initDataType, - /** shaka.extern.DrmInfo */ drmInfo) {} -``` - -The new default for `drm.initDataTransform` should work for most content. -Please try the default first (without configuring your own callback). If init -data transformation is still needed, please use the utilities provided in -{@link shaka.util.FairPlayUtils}, {@link shaka.util.StringUtils} to make this -processing easier. You can refer to {@tutorial fairplay} as well. - - -#### Misc configuration changes - -The configurable callback `manifest.dash.customScheme` has been removed in v3.0 -and is no longer supported. - -The config field `manifest.dash.defaultPresentationDelay` has been moved to -`manifest.defaultPresentationDelay`. Backward compatibility is provided until -v4.0. Applications using this field SHOULD update to use the new location. - -The `manifest.defaultPresentationDelay` field now affects both DASH and HLS -content. The default value is `0`, which is interpreted differently for DASH -and HLS: - - - In DASH, `0` means a default of `1.5 * minBufferTime`. - - In HLS, `0` means a default of `3 * segment duration`. - -The config field `manifest.dash.initialSegmentLimit` has been added to control -memory usage during DASH `` parsing. - -The config field `streaming.inaccurateManifestTolerance` (in seconds) has been -added to control off-by-one behavior in streaming. Compared with v2.5.x -behavior, the default for this field should reduce the frequency with which we -have to fetch an additional segment before a seek target. For less accurate -manifests, the tolerance can be increased. For completely accurate manifests, -applications may set this to `0`. - -See {@link shaka.extern.ManifestConfiguration} and -{@link shaka.extern.StreamingConfiguration} for details. - - -#### Offline API changes - -In v3.0, the offline storage method `Storage.getStoreInProgress()` is now -deprecated and always returns `false`. There is no longer any restriction on -concurrent operations. This method will be removed in v4.0. Applications -SHOULD stop using it. - -The method `Storage.store()` now returns an instance of `IAbortableOperation` -instead of `Promise`. This allows applications to call `op.abort()` to stop an -operation in progress. The operation `Promise` can now be found on -`op.promise`. Backward compatibility is provided until v4.0; these operations -will work like `Promise`s in v3.0. (Applications MAY `await` them or call -`.then()` on them.) In v4.0, these returned operations will no longer be -`Promise`-like, so applications SHOULD update at this time to use `op.promise`. - -```js -// v2.5: -try { - const result = await storage.store(); -} catch (error) { - // Store failed! -} - -// v3.0: -const op = storage.store(); -cancelButton.onclick = async () => { - await op.abort(); -}; - -try { - const result = await op.promise; -} catch (error) { - if (error.code == shaka.util.Error.Code.OPERATION_ABORTED) { - // Store aborted by the user! - } else { - // Store failed! - } -} -``` - -In v3.0, `shaka.offline.Storage.configure()` now takes a complete `Player` -configuration object instead of a separate one. The fields that were previously -part of the `Storage` config (`trackSelectionCallback`, `progressCallback`, and -`usePersistentLicense`) have been moved inside the `offline` field. The old -field locations were deprecated in v2.5 and removed in v3.0. Applications MUST -update to use the new field locations. - -```js -// v2.4: -storage.configure({ - trackSelectionCallback: myTrackSelectionCallback, -}); - -// v3.0: -const storage = new shaka.offline.Storage(); -storage.configure({ - offline: { - trackSelectionCallback: myTrackSelectionCallback, - }, -}); - -// OR use shared Player configuration: -const storage = new shaka.offline.Storage(player); -player.configure({ - offline: { - trackSelectionCallback: myTrackSelectionCallback, - }, -}); - -// OR use shared Player configuration and two-argument configure(): -const storage = new shaka.offline.Storage(player); -player.configure('offline.trackSelectionCallback', myTrackSelectionCallback); -``` - -See {@link shaka.offline.Storage} for details. - - -#### NetworkingEngine API changes - -The fields `Request.body` and `Response.data` can now be either `ArrayBuffer` or -an `ArrayBufferView` (e.g. `Uint8Array`). This means your request and response -filters no longer have to convert a `Uint8Array` to `ArrayBuffer` to assign to -`Request.body` or `Response.data`. However, this also means such filters MUST -not assume one type or the other if they read those fields. - -Applications SHOULD use these provided utilities to simplify common conversions: - - - {@link shaka.util.BufferUtils} - - {@link shaka.util.StringUtils} - - {@link shaka.util.Uint8ArrayUtils} - - -#### Track API changes - -The track APIs on `Player` have changed. Tracks now represent the entire -presentation across DASH Periods, and will no longer change at Period -boundaries. The `originalId` field is now a combination of the original IDs of -the DASH Representations that make up the track. - - -#### Stats changes - -The stats returned by `Player.getStats()` have changed. - -The `streamBandwidth` field now accounts for the current playback rate when -reporting the bandwidth requirements of a stream. For example, if the content -is playing at 2x, the bandwidth requirement to play it is also doubled. - -The following new fields have been added: - - - `manifestTimeSeconds` - - `drmTimeSeconds` - - `liveLatency` - -See {@link shaka.extern.Stats stats} for details. - - -#### New UI elements - -The following new UI elements have been added: - - - Ad-related elements (shown automatically during an ad, not currently - configurable) - - Overflow menu toggle for looping video (`'loop'`, not shown by default) - - Overflow menu item and submenu for playback rate (`'playback_rate'`, shown - by default) - -See {@tutorial ui-customization}. - - -#### AbrManager plugin changes - -In v3.0, we added a method to the `shaka.extern.AbrManager` interface called -`playbackRateChanged(rate)`. This allows implementations to consider the -current playback rate in their ABR decisions. - -Backward compatibility will be provided until v4.0. Applications with custom -`AbrManager` plugins SHOULD update to add this method to their implementations. - -See {@link shaka.extern.AbrManager} for details. - - -#### TextDisplayer plugin changes - -The `Cue` objects consumed by `TextDisplayer` have changed in v3.0. - - - `Cue.size` now defaults to `0`, which should be interpreted as "auto" (fit - to text). - -All application-specific TextDisplayer plugins MUST be updated. -v3.0 does not have backward compatibility for this! - -In addition, the following new fields have been added and MAY be used by -`TextDisplayer` plugins: - - - `Cue.backgroundImage` - - `Cue.border` - - `Cue.cellResolution` - - `Cue.letterSpacing` - - `Cue.linePadding` - - `Cue.opacity` - -See {@link shaka.extern.Cue} for details. - - -#### UI element plugin changes - -The interface {@link shaka.extern.IUIElement} now has a synchronous `release()` -method instead of an asynchronous `destroy()` method. Backward compatibility -will be provided until v4.0. Applications with UI element plugins SHOULD -update their plugins to replace `destroy()` with `release()`. - -```js -// v2.5: -class MyUIElement { - async destroy() { - // Release resources asynchronously. - } -} - -// v3.0: -class MyUIElement { - release() { - // Release resources synchronously. - } -} -``` - - -#### Built-in network scheme plugin changes - -Some of the built-in network scheme plugins have changed their API. Instead of -registering the class itself, they now register a static `parse()` method on -the class. Any applications with scheme plugins that delegate to these -built-in plugins MUST update to call the new methods. - -This affects the following classes: - - - {@link shaka.net.DataUriPlugin} - - {@link shaka.net.HttpFetchPlugin} - - {@link shaka.net.HttpXHRPlugin} - -```js -// v2.5: -function MySchemePlugin(uri, request, requestType, progressUpdated) { - return shaka.net.DataUriPlugin( - uri, request, requestType, progressUpdated); -} -shaka.net.NetworkingEngine.registerScheme('data', MySchemePlugin); - -// v3.0: -function MySchemePlugin(uri, request, requestType, progressUpdated) { - return shaka.net.DataUriPlugin.parse( - uri, request, requestType, progressUpdated); -} -``` - - -#### Manifest parser plugin API changes - -v3.0 introduced many changes to the {@link shaka.extern.Manifest} structure. -Any application with a custom {@link shaka.extern.ManifestParser} or which uses -{@link shaka.Player#getManifest} MUST be upgraded for compatibility with v3.0. - -If your application meets either of these criteria, please refer to -{@tutorial upgrade-manifest} for detailed instructions on upgrading. diff --git a/docs/tutorials/upgrade-v3.md b/docs/tutorials/upgrade-v3.md deleted file mode 100644 index 94c1ba1434..0000000000 --- a/docs/tutorials/upgrade-v3.md +++ /dev/null @@ -1,38 +0,0 @@ -# Shaka Upgrade Guide, v3 - -This is a detailed guide for upgrading from any older version of Shaka Player v3 -to the current version. - -Shaka Player has been keeping strictly with semantic versioning since v3.0.0, so -upgrades from any older v3 to the current v3 release should be backward -compatible. Any minor exceptions or nuances will be noted here. - - -#### What's New? - -v3.1: - - Ads APIs and UI leveraging Google IMA SDK (included separately by app) - - Low-latency HLS support - - Built-in CEA 608/708 decoder (mux.js no longer needed for this) - - Thumbnail track support - - UI overflow menu items now available as control panel buttons - - Network stall detection - - HDR & spatial audio metadata - - PlayReady support in HLS - - WebVTT styling and embedded tag support - - SubViewer (SBV), SubStation Alpha (SSA), LyRiCs (LRC), and SubRip (SRT) - subtitle format support - - Forced subtitles - - Side-loaded subtitles in src= playback mode - - Custom seekbar UI plugin - - AirPlay support in UI - - -#### New Requirements - -v3.1: - - TextDecoder/TextEncoder platform support or polyfill required - - Affects Xbox One - - We suggest [https://github.com/anonyco/FastestSmallestTextEncoderDecoder](fastestsmallesttextencoderdecoder/EncoderDecoderTogether.min.js) - - IE11 support dropped (announced before v3.0) - diff --git a/docs/tutorials/upgrade.md b/docs/tutorials/upgrade.md index 145afcb1fa..7e9b6bc3a6 100644 --- a/docs/tutorials/upgrade.md +++ b/docs/tutorials/upgrade.md @@ -1,17 +1,87 @@ # Shaka Player Upgrade Guide -If you are upgrading from **v1 - v2.2**, please see -{@link https://v2-4-7-dot-shaka-player-demo.appspot.com/docs/api/tutorial-upgrade.html -the upgrade guides from the v2.4 releases}, then return to this guide. +If you are upgrading from **v1 or v2**, these releases are no longer supported, +and upgrade guides are no longer maintained. You can use these old upgrades +guides to upgrade in stages: -If you are upgrading from **v2.3 - v2.4**, please see -{@link https://v2-5-10-dot-shaka-player-demo.appspot.com/docs/api/tutorial-upgrade.html -the upgrade guides from the v2.5 releases}, then return to this guide. + - {@link https://v2-4-7-dot-shaka-player-demo.appspot.com/docs/api/tutorial-upgrade.html Upgrade to v2.4} + - {@link https://v2-5-23-dot-shaka-player-demo.appspot.com/docs/api/tutorial-upgrade-v2-4.html Upgrade v2.4 => v2.5} + - {@link https://v3-0-15-dot-shaka-player-demo.appspot.com/docs/api/tutorial-upgrade-v2-5.html Upgrade v2.5 => v3.0} -From these older release branches, you will have to use our upgrade guides in -phases. This is necessary to keep our guides maintainable. Thanks for your -understanding! +Since v3.0, Shaka Player has been following semantic versioning. (The +IE11 deprecation announced before v3.0 happened in v3.1, which technically +breaks semantic versioning guarantees. It is the only intentional exception.) -If you are upgrading from **v2.5**, please see {@tutorial upgrade-v2-5}. +Upgrading from any v3 release to a newer v3 release should be backward +compatible. The same is true of all major version numbers (v4 => v4, etc). -If you are upgrading from another **v3** release, please see {@tutorial upgrade-v3}. +Here is a summary of breaking changes that might require upgrades to your +application: + + +## v3.1 + + - New dependencies: + - TextDecoder/TextEncoder platform support or polyfill required (affects + Xbox One, but not evergreen browsers); we suggest the polyfill + [https://github.com/anonyco/FastestSmallestTextEncoderDecoder](fastestsmallesttextencoderdecoder/EncoderDecoderTogether.min.js) + + - Support removed: + - IE11 support removed + + +## v4.0 + + - Support removed: + - Older TVs and set-top boxes that do not support MediaSource sequence mode + can no longer play HLS content (since we now use sequence mode for that) + - Support for iOS 12 and Safari 12 has been removed + + - Configuration changes: + - `manifest.dash.defaultPresentationDelay` has been replaced by + `manifest.defaultPresentationDelay` (deprecated in v3.0.0) + - Configuration of factories should be plain factory functions, not + constructors; these will not be invoked with `new` (deprecated in v3.1.0) + - `drm.initDataTransform` has been removed (no longer needed since the + minimum supported version of iOS is now 13) + + - Player API changes: + - `shaka.Player.prototype.addTextTrack()` has been replaced by + `addTextTrackAsync()`, which returns a `Promise` (deprecated in v3.1.0) + + - UI API changes: + - `shaka.ui.TrackLabelFormat` has been renamed to + `shaka.ui.Overlay.TrackLabelFormat` (deprecated in v3.1.0) + - `shaka.ui.FailReasonCode` has been renamed to + `shaka.ui.Overlay.FailReasonCode` (deprecated in v3.1.0) + + - Offline API changes: + - `shaka.offline.Storage.prototype.store()` returns `AbortableOperation` + instead of `Promise`; callers should change `.then()` to + `.promise.then()` and `await rv` to `await rv.promise` (deprecated in + v3.0.0) + - `shaka.offline.Storage.prototype.getStoreInProgress()` has been removed; + concurrent operations are supported since v3, so callers don't need to + check this (deprecated in v3.0.0) + + - Utility API changes: + - `shaka.util.Uint8ArrayUtils.equal` has been replaced by + `shaka.util.BufferUtils.equal`, which can handle multiple types of + buffers (deprecated in v3.0.0) + + - Manifest API changes: + - `shaka.media.SegmentIndex.prototype.destroy()` has been replaced by + `release()`, which is synchronous (deprecated in v3.0.0) + - `shaka.media.SegmentIterator.prototype.seek()`, which mutates the + iterator, has been replaced by + `shaka.media.SegmentIndex.getIteratorForTime()` (deprecated in v3.1.0) + - `shaka.media.SegmentIndex.prototype.merge()` has become private; use + `mergeAndEvict()` instead (deprecated in v3.2.0) + + - Plugin changes: + - `AbrManager` plugins must implement the `playbackRateChanged()` method + (deprecated in v3.0.0) + - `shaka.extern.Cue.prototype.spacer` has been replaced by the more + clearly-named `lineBreak` (deprecated in v3.1.0) + - `IUIElement` plugins must have a `release()` method (not `destroy()`) + (deprecated in v3.0.0) diff --git a/externs/shaka/text.js b/externs/shaka/text.js index d50d2c2b33..140b967cce 100644 --- a/externs/shaka/text.js +++ b/externs/shaka/text.js @@ -380,17 +380,6 @@ shaka.extern.Cue = class { * @exportDoc */ this.lineBreak; - - /** - * @deprecated - * "spacer" is deprecated and will be removed in v4. Use "lineBreak" - * instead. - * Whether or not the cue only acts as a line break between two nested cues. - * Should only appear in nested cues. - * @type {boolean} - * @exportDoc - */ - this.spacer; } }; diff --git a/lib/cast/cast_utils.js b/lib/cast/cast_utils.js index d50a1f9c7c..615f78111a 100644 --- a/lib/cast/cast_utils.js +++ b/lib/cast/cast_utils.js @@ -373,7 +373,6 @@ shaka.cast.CastUtils.PlayerInitAfterLoadState = [ */ shaka.cast.CastUtils.PlayerVoidMethods = [ 'addChaptersTrack', - 'addTextTrack', 'addTextTrackAsync', 'cancelTrickPlay', 'configure', diff --git a/lib/media/segment_index.js b/lib/media/segment_index.js index defd379cc8..6d03f3f768 100644 --- a/lib/media/segment_index.js +++ b/lib/media/segment_index.js @@ -9,7 +9,6 @@ goog.provide('shaka.media.SegmentIndex'); goog.provide('shaka.media.SegmentIterator'); goog.require('goog.asserts'); -goog.require('shaka.Deprecate'); goog.require('shaka.media.SegmentReference'); goog.require('shaka.util.IReleasable'); goog.require('shaka.util.Timer'); @@ -52,23 +51,6 @@ shaka.media.SegmentIndex = class { } - /** - * SegmentIndex used to be an IDestroyable. Now it is an IReleasable. - * This method is provided for backward compatibility. - * - * @deprecated - * @return {!Promise} - * @export - */ - destroy() { - shaka.Deprecate.deprecateFeature(4, - 'shaka.media.SegmentIndex', - 'Please use release() instead of destroy().'); - this.release(); - return Promise.resolve(); - } - - /** * @override * @export @@ -202,9 +184,6 @@ shaka.media.SegmentIndex = class { * @param {!Array.} references The list of * SegmentReferences, which must be sorted first by their start times * (ascending) and second by their end times (ascending). - * @deprecated Not used directly by our own parsers, so will become private in - * v4. Use mergeAndEvict() instead. - * @export */ merge(references) { if (goog.DEBUG) { @@ -525,30 +504,6 @@ shaka.media.SegmentIterator = class { this.currentPartialPosition_ = partialSegmentIndex; } - /** - * Move the iterator to a given timestamp in the underlying SegmentIndex. - * - * @param {number} time - * @return {shaka.media.SegmentReference} - * @deprecated Use SegmentIndex.getIteratorForTime instead - * @export - */ - seek(time) { - shaka.Deprecate.deprecateFeature( - 4, 'shaka.media.SegmentIterator', - 'Please use SegmentIndex.getIteratorForTime instead of seek().'); - - const iter = this.segmentIndex_.getIteratorForTime(time); - if (iter) { - this.currentPosition_ = iter.currentPosition_; - this.currentPartialPosition_ = iter.currentPartialPosition_; - } else { - this.currentPosition_ = Number.MAX_VALUE; - this.currentPartialPosition_ = 0; - } - return this.next().value; - } - /** * @return {shaka.media.SegmentReference} * @export diff --git a/lib/offline/storage.js b/lib/offline/storage.js index 7c815ce85a..04eb8eca93 100644 --- a/lib/offline/storage.js +++ b/lib/offline/storage.js @@ -7,7 +7,6 @@ goog.provide('shaka.offline.Storage'); goog.require('goog.asserts'); -goog.require('shaka.Deprecate'); goog.require('shaka.Player'); goog.require('shaka.log'); goog.require('shaka.media.DrmEngine'); @@ -25,7 +24,6 @@ goog.require('shaka.util.ArrayUtils'); goog.require('shaka.util.ConfigUtils'); goog.require('shaka.util.Destroyer'); goog.require('shaka.util.Error'); -goog.require('shaka.util.Functional'); goog.require('shaka.util.IDestroyable'); goog.require('shaka.util.Iterables'); goog.require('shaka.util.MimeUtils'); @@ -195,20 +193,8 @@ shaka.offline.Storage = class { if (arguments.length == 2 && typeof(config) == 'string') { config = shaka.util.ConfigUtils.convertToConfigObject(config, value); } - goog.asserts.assert(typeof(config) == 'object', 'Should be an object!'); - // Deprecate 'manifest.dash.defaultPresentationDelay' configuration. - if (config['manifest'] && config['manifest']['dash'] && - 'defaultPresentationDelay' in config['manifest']['dash']) { - shaka.Deprecate.deprecateFeature(4, - 'manifest.dash.defaultPresentationDelay configuration', - 'Please Use manifest.defaultPresentationDelay instead.'); - config['manifest']['defaultPresentationDelay'] = - config['manifest']['dash']['defaultPresentationDelay']; - delete config['manifest']['dash']['defaultPresentationDelay']; - } - goog.asserts.assert( this.config_, 'Cannot reconfigure stroage after calling destroy.'); return shaka.util.PlayerConfiguration.mergeConfigObjects( @@ -292,7 +278,7 @@ shaka.offline.Storage = class { config.manifest.retryParameters, mimeType || null); - return shaka.util.Functional.callFactory(factory); + return factory(); }; /** @type {!shaka.offline.DownloadManager} */ @@ -309,33 +295,9 @@ shaka.offline.Storage = class { shaka.util.ArrayUtils.remove(this.openDownloadManagers_, downloader); }); - // Provide a temporary shim for "then" for backward compatibility. - /** @type {!Object} */ (abortableStoreOp)['then'] = (onSuccess) => { - shaka.Deprecate.deprecateFeature(4, - 'shaka.offline.Storage.store.then', - 'Storage operations now return a shaka.util.AbortableOperation, ' + - 'rather than a promise. Please update to conform to this new API; ' + - 'you can use the |chain| method instead.'); - return abortableStoreOp.promise.then(onSuccess); - }; - return this.startAbortableOperation_(abortableStoreOp); } - /** - * Returns true if an asset is currently downloading. - * - * @return {boolean} - * @deprecated - * @export - */ - getStoreInProgress() { - shaka.Deprecate.deprecateFeature(4, - 'shaka.offline.Storage.getStoreInProgress', - 'Multiple concurrent downloads are now supported.'); - return false; - } - /** * See |shaka.offline.Storage.store| for details. * diff --git a/lib/player.js b/lib/player.js index 398191fc61..a10c3ab038 100644 --- a/lib/player.js +++ b/lib/player.js @@ -43,7 +43,6 @@ goog.require('shaka.util.Error'); goog.require('shaka.util.EventManager'); goog.require('shaka.util.FakeEvent'); goog.require('shaka.util.FakeEventTarget'); -goog.require('shaka.util.Functional'); goog.require('shaka.util.IDestroyable'); goog.require('shaka.util.LanguageUtils'); goog.require('shaka.util.ManifestParserUtils'); @@ -576,8 +575,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget { this.adManager_ = null; if (shaka.Player.adManagerFactory_) { - this.adManager_ = - shaka.util.Functional.callFactory(shaka.Player.adManagerFactory_); + this.adManager_ = shaka.Player.adManagerFactory_(); } // If the browser comes back online after being offline, then try to play @@ -1560,8 +1558,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget { // text displayer and streaming engine are always in sync, wait until they // are both initialized before setting the initial value. const textDisplayerFactory = this.config_.textDisplayFactory; - const textDisplayer = - shaka.util.Functional.callFactory(textDisplayerFactory); + const textDisplayer = textDisplayerFactory(); this.lastTextFactory_ = textDisplayerFactory; const mediaSourceEngine = this.createMediaSourceEngine( @@ -1634,7 +1631,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget { this.config_.manifest.retryParameters, has.mimeType); goog.asserts.assert(this.parserFactory_, 'Must have manifest parser'); - this.parser_ = shaka.util.Functional.callFactory(this.parserFactory_); + this.parser_ = this.parserFactory_(); const manifestConfig = shaka.util.ObjectUtils.cloneObject(this.config_.manifest); @@ -1920,13 +1917,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget { const abrFactory = this.config_.abrFactory; if (!this.abrManager_ || this.abrManagerFactory_ != abrFactory) { this.abrManagerFactory_ = abrFactory; - this.abrManager_ = shaka.util.Functional.callFactory(abrFactory); - if (typeof this.abrManager_.playbackRateChanged != 'function') { - shaka.Deprecate.deprecateFeature(4, - 'AbrManager', - 'Please use an AbrManager with playbackRateChanged function.'); - this.abrManager_.playbackRateChanged = (rate) => {}; - } + this.abrManager_ = abrFactory(); this.abrManager_.configure(this.config_.abr); } @@ -2945,17 +2936,6 @@ shaka.Player = class extends shaka.util.FakeEventTarget { goog.asserts.assert(typeof(config) == 'object', 'Should be an object!'); - // Deprecate 'manifest.dash.defaultPresentationDelay' configuration. - if (config['manifest'] && config['manifest']['dash'] && - 'defaultPresentationDelay' in config['manifest']['dash']) { - shaka.Deprecate.deprecateFeature(4, - 'manifest.dash.defaultPresentationDelay configuration', - 'Please Use manifest.defaultPresentationDelay instead.'); - config['manifest']['defaultPresentationDelay'] = - config['manifest']['dash']['defaultPresentationDelay']; - delete config['manifest']['dash']['defaultPresentationDelay']; - } - // If lowLatencyMode is enabled, and inaccurateManifestTolerance and // rebufferingGoal are not specified, set inaccurateManifestTolerance to 0 // and rebufferingGoal to 0.01 by default for low latency streaming. @@ -3028,8 +3008,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget { const textDisplayerFactory = this.config_.textDisplayFactory; if (this.lastTextFactory_ != textDisplayerFactory) { - const displayer = - shaka.util.Functional.callFactory(textDisplayerFactory); + const displayer = textDisplayerFactory(); this.mediaSourceEngine_.setTextDisplayer(displayer); this.lastTextFactory_ = textDisplayerFactory; @@ -4414,158 +4393,6 @@ shaka.Player = class extends shaka.util.FakeEventTarget { return this.stats_.getBlob(); } - /** - * Adds the given text track to the loaded manifest. load() must - * resolve before calling. The presentation must have a duration. - * - * This returns the created track, which can immediately be selected by the - * application. The track will not be automatically selected. - * - * @param {string} uri - * @param {string} language - * @param {string} kind - * @param {string=} mimeType - * @param {string=} codec - * @param {string=} label - * @param {boolean=} forced - * @return {shaka.extern.Track} - * @export - */ - addTextTrack(uri, language, kind, mimeType, codec, label, forced = false) { - shaka.Deprecate.deprecateFeature(4, - 'addTextTrack', - 'Please use an addTextTrackAsync.'); - if (this.loadMode_ != shaka.Player.LoadMode.MEDIA_SOURCE && - this.loadMode_ != shaka.Player.LoadMode.SRC_EQUALS) { - shaka.log.error( - 'Must call load() and wait for it to resolve before adding text ' + - 'tracks.'); - throw new shaka.util.Error( - shaka.util.Error.Severity.RECOVERABLE, - shaka.util.Error.Category.PLAYER, - shaka.util.Error.Code.CONTENT_NOT_LOADED); - } - - if (!mimeType) { - // Try using the uri extension. - const extension = shaka.media.ManifestParser.getExtension(uri); - mimeType = shaka.Player.TEXT_EXTENSIONS_TO_MIME_TYPES_[extension]; - - if (!mimeType) { - shaka.log.error( - 'The mimeType has not been provided and it could not be deduced ' + - 'from its extension.'); - throw new shaka.util.Error( - shaka.util.Error.Severity.RECOVERABLE, - shaka.util.Error.Category.TEXT, - shaka.util.Error.Code.TEXT_COULD_NOT_GUESS_MIME_TYPE, - extension); - } - } - - if (this.loadMode_ == shaka.Player.LoadMode.SRC_EQUALS) { - if (mimeType != 'text/vtt') { - shaka.log.error('Only WebVTT is supported when using src='); - throw new shaka.util.Error( - shaka.util.Error.Severity.RECOVERABLE, - shaka.util.Error.Category.TEXT, - shaka.util.Error.Code.TEXT_ONLY_WEBVTT_SRC_EQUALS, - mimeType); - } - if (forced) { - // See: https://github.com/whatwg/html/issues/4472 - kind = 'forced'; - } - const trackElement = - /** @type {!HTMLTrackElement} */(document.createElement('track')); - trackElement.src = this.cmcdManager_.appendTextTrackData(uri); - trackElement.label = label || ''; - trackElement.kind = kind; - trackElement.srclang = language; - // Because we're pulling in the text track file via Javascript, the - // same-origin policy applies. If you'd like to have a player served - // from one domain, but the text track served from another, you'll - // need to enable CORS in order to do so. In addition to enabling CORS - // on the server serving the text tracks, you will need to add the - // crossorigin attribute to the video element itself. - if (!this.video_.getAttribute('crossorigin')) { - this.video_.setAttribute('crossorigin', 'anonymous'); - } - this.video_.appendChild(trackElement); - const textTracks = this.getTextTracks(); - const srcTrack = textTracks.find((t) => { - return t.language == language && - t.label == (label || '') && - t.kind == kind; - }); - if (srcTrack) { - this.onTracksChanged_(); - return srcTrack; - } - // This should not happen, but there are browser implementations that may - // not support the Track element. - shaka.log.error('Cannot add this text when loaded with src='); - throw new shaka.util.Error( - shaka.util.Error.Severity.RECOVERABLE, - shaka.util.Error.Category.TEXT, - shaka.util.Error.Code.CANNOT_ADD_EXTERNAL_TEXT_TO_SRC_EQUALS); - } - - const ContentType = shaka.util.ManifestParserUtils.ContentType; - - const duration = this.manifest_.presentationTimeline.getDuration(); - if (duration == Infinity) { - throw new shaka.util.Error( - shaka.util.Error.Severity.RECOVERABLE, - shaka.util.Error.Category.MANIFEST, - shaka.util.Error.Code.CANNOT_ADD_EXTERNAL_TEXT_TO_LIVE_STREAM); - } - - /** @type {shaka.extern.Stream} */ - const stream = { - id: this.nextExternalStreamId_++, - originalId: null, - createSegmentIndex: () => Promise.resolve(), - segmentIndex: shaka.media.SegmentIndex.forSingleSegment( - /* startTime= */ 0, - /* duration= */ duration, - /* uris= */ [uri]), - mimeType: mimeType || '', - codecs: codec || '', - kind: kind, - encrypted: false, - drmInfos: [], - keyIds: new Set(), - language: language, - label: label || null, - type: ContentType.TEXT, - primary: false, - trickModeVideo: null, - emsgSchemeIdUris: null, - roles: [], - forced: !!forced, - channelsCount: null, - audioSamplingRate: null, - spatialAudio: false, - closedCaptions: null, - }; - - const fullMimeType = shaka.util.MimeUtils.getFullType( - stream.mimeType, stream.codecs); - const supported = shaka.text.TextEngine.isTypeSupported(fullMimeType); - if (!supported) { - throw new shaka.util.Error( - shaka.util.Error.Severity.CRITICAL, - shaka.util.Error.Category.TEXT, - shaka.util.Error.Code.MISSING_TEXT_PLUGIN, - mimeType); - } - - this.manifest_.textStreams.push(stream); - this.onTracksChanged_(); - return shaka.util.StreamUtils.textStreamToTrack(stream); - } - /** * Adds the given text track to the loaded manifest. load() must * resolve before calling. The presentation must have a duration. diff --git a/lib/text/cue.js b/lib/text/cue.js index 1339b830a5..77dcb1ca3b 100644 --- a/lib/text/cue.js +++ b/lib/text/cue.js @@ -234,12 +234,6 @@ shaka.text.Cue = class { */ this.lineBreak = false; - /** - * @override - * @exportInterface - */ - this.spacer = false; - /** * @override * @exportInterface diff --git a/lib/text/simple_text_displayer.js b/lib/text/simple_text_displayer.js index 405d034d7e..63604c8fdc 100644 --- a/lib/text/simple_text_displayer.js +++ b/lib/text/simple_text_displayer.js @@ -12,7 +12,6 @@ goog.provide('shaka.text.SimpleTextDisplayer'); goog.require('goog.asserts'); -goog.require('shaka.Deprecate'); goog.require('shaka.log'); goog.require('shaka.text.Cue'); @@ -108,12 +107,7 @@ shaka.text.SimpleTextDisplayer = class { return `${acc}`; }, ''); - if (cue.lineBreak || cue.spacer) { - if (cue.spacer) { - shaka.Deprecate.deprecateFeature(4, - 'shaka.extern.Cue', - 'Please use lineBreak instead of spacer.'); - } + if (cue.lineBreak) { // This is a vertical lineBreak, so insert a newline. return '\n'; } else if (cue.nestedCues.length) { diff --git a/lib/text/text_engine.js b/lib/text/text_engine.js index c968542572..0deebeea5e 100644 --- a/lib/text/text_engine.js +++ b/lib/text/text_engine.js @@ -10,7 +10,6 @@ goog.require('goog.asserts'); goog.require('shaka.log'); goog.require('shaka.text.Cue'); goog.require('shaka.util.BufferUtils'); -goog.require('shaka.util.Functional'); goog.require('shaka.util.IDestroyable'); goog.require('shaka.util.MimeUtils'); goog.requireType('shaka.cea.ICaptionDecoder'); @@ -146,7 +145,7 @@ shaka.text.TextEngine = class { const factory = shaka.text.TextEngine.parserMap_[mimeType]; goog.asserts.assert( factory, 'Text type negotiation should have happened already'); - this.parser_ = shaka.util.Functional.callFactory(factory); + this.parser_ = factory(); if (this.parser_.setSequenceMode) { this.parser_.setSequenceMode(sequenceMode); } else { diff --git a/lib/text/ui_text_displayer.js b/lib/text/ui_text_displayer.js index b54782c8fa..9652d59f6a 100644 --- a/lib/text/ui_text_displayer.js +++ b/lib/text/ui_text_displayer.js @@ -8,7 +8,6 @@ goog.provide('shaka.text.UITextDisplayer'); goog.require('goog.asserts'); -goog.require('shaka.Deprecate'); goog.require('shaka.text.Cue'); goog.require('shaka.text.CueRegion'); goog.require('shaka.util.Dom'); @@ -343,12 +342,7 @@ shaka.text.UITextDisplayer = class { createCue_(cue, parents) { const isNested = parents.length > 1; let type = isNested ? 'span' : 'div'; - if (cue.lineBreak || cue.spacer) { - if (cue.spacer) { - shaka.Deprecate.deprecateFeature(4, - 'shaka.extern.Cue', - 'Please use lineBreak instead of spacer.'); - } + if (cue.lineBreak) { type = 'br'; } diff --git a/lib/text/web_vtt_generator.js b/lib/text/web_vtt_generator.js index 634541349d..aeb222483c 100644 --- a/lib/text/web_vtt_generator.js +++ b/lib/text/web_vtt_generator.js @@ -6,7 +6,6 @@ goog.provide('shaka.text.WebVttGenerator'); -goog.require('shaka.Deprecate'); goog.require('shaka.text.Cue'); @@ -49,12 +48,7 @@ shaka.text.WebVttGenerator = class { return `${acc}`; }, ''); - if (cue.lineBreak || cue.spacer) { - if (cue.spacer) { - shaka.Deprecate.deprecateFeature(4, - 'shaka.text.Cue', - 'Please use lineBreak instead of spacer.'); - } + if (cue.lineBreak) { // This is a vertical lineBreak, so insert a newline. return '\n'; } else if (cue.nestedCues.length) { diff --git a/lib/util/functional.js b/lib/util/functional.js index 6613b1256f..694d99d49c 100644 --- a/lib/util/functional.js +++ b/lib/util/functional.js @@ -6,9 +6,6 @@ goog.provide('shaka.util.Functional'); -goog.require('shaka.Deprecate'); - - /** * @summary A set of functional utility functions. */ @@ -70,43 +67,4 @@ shaka.util.Functional = class { static isNotNull(value) { return value != null; } - - /** - * Calls a factory function while allowing it to be a constructor for - * reverse-compatibility. - * - * @param {function():!T} factory - * @return {!T} - * @template T - */ - static callFactory(factory) { - // See https://stackoverflow.com/q/10428603/1208502 - // eslint-disable-next-line no-restricted-syntax - const obj = Object.create(factory.prototype || Object.prototype); - // If this is a constructor, call it with our newly created object to - // initialize it; if this isn't a constructor, the "this" shouldn't be used - // since it should be "undefined". - let ret; - try { - ret = factory.call(obj); // eslint-disable-line no-restricted-syntax - - // If it didn't return anything, assume it is a constructor and return our - // "this" value instead. - if (!ret) { - shaka.Deprecate.deprecateFeature(4, - 'Factories requiring new', - 'Factories should be plain functions'); - ret = obj; - } - } catch (e) { - // This was an ES6 class, so it threw a TypeError because we didn't use - // "new". Fall back to actually using "new". - shaka.Deprecate.deprecateFeature(4, - 'Factories requiring new', - 'Factories should be plain functions'); - const FactoryAsClass = /** @type {function(new: T)} */(factory); - ret = new FactoryAsClass(); - } - return ret; - } }; diff --git a/lib/util/uint8array_utils.js b/lib/util/uint8array_utils.js index b0b8c02061..87c3761022 100644 --- a/lib/util/uint8array_utils.js +++ b/lib/util/uint8array_utils.js @@ -6,7 +6,6 @@ goog.provide('shaka.util.Uint8ArrayUtils'); -goog.require('shaka.Deprecate'); goog.require('shaka.util.BufferUtils'); goog.require('shaka.util.StringUtils'); @@ -17,21 +16,6 @@ goog.require('shaka.util.StringUtils'); * @export */ shaka.util.Uint8ArrayUtils = class { - /** - * Compare two Uint8Arrays for equality. - * @param {Uint8Array} arr1 - * @param {Uint8Array} arr2 - * @return {boolean} - * @deprecated - * @export - */ - static equal(arr1, arr2) { - shaka.Deprecate.deprecateFeature(4, - 'shaka.util.Uint8ArrayUtils.equal', - 'Please use shaka.util.BufferUtils.equal instead.'); - return shaka.util.BufferUtils.equal(arr1, arr2); - } - /** * Convert a buffer to a base64 string. The output will be standard * alphabet as opposed to base64url safe alphabet. diff --git a/test/dash/dash_parser_segment_template_unit.js b/test/dash/dash_parser_segment_template_unit.js index b0ff89ea1e..f68265bdb3 100644 --- a/test/dash/dash_parser_segment_template_unit.js +++ b/test/dash/dash_parser_segment_template_unit.js @@ -106,9 +106,8 @@ describe('DashParser SegmentTemplate', () => { 's2.mp4', 50, 60, baseUri); expectedRef2.timestampOffset = -10; - const iterator = stream.segmentIndex[Symbol.iterator](); - const ref1 = iterator.seek(45); - const ref2 = iterator.seek(55); + const ref1 = stream.segmentIndex.getIteratorForTime(45).next().value; + const ref2 = stream.segmentIndex.getIteratorForTime(55).next().value; expect(ref1).toEqual(expectedRef1); expect(ref2).toEqual(expectedRef2); }); @@ -445,7 +444,7 @@ describe('DashParser SegmentTemplate', () => { await variants[2].video.createSegmentIndex(); const getRefAt = (stream, time) => { - return stream.segmentIndex[Symbol.iterator]().seek(time); + return stream.segmentIndex.getIteratorForTime(time).next().value; }; expect(getRefAt(variants[0].video, 0)).toEqual( diff --git a/test/media/segment_index_unit.js b/test/media/segment_index_unit.js index 4f858fddd0..79fa98d83f 100644 --- a/test/media/segment_index_unit.js +++ b/test/media/segment_index_unit.js @@ -693,22 +693,6 @@ describe('SegmentIndex', /** @suppress {accessControls} */ () => { expect(iterator.current()).toBe(null); }); - describe('seek', () => { - it('returns the matching segment', () => { - const index = new shaka.media.SegmentIndex(inputRefs); - const iterator = index[Symbol.iterator](); - expect(iterator.seek(10)).toBe(inputRefs[1]); - expect(iterator.current()).toBe(inputRefs[1]); - }); - - it('returns the matching segment with partial segments', () => { - const index = new shaka.media.SegmentIndex(inputRefsWithPartial); - const iterator = index[Symbol.iterator](); - expect(iterator.seek(8)).toBe(inputRefsWithPartial[0]); - expect(iterator.seek(10)).toBe(partialRefs1[0]); - }); - }); - describe('next', () => { it('starts with the first segment', () => { const index = new shaka.media.SegmentIndex(inputRefs); @@ -725,20 +709,20 @@ describe('SegmentIndex', /** @suppress {accessControls} */ () => { expect(iterator.next().value).toBe(null); }); - it('iterates forward after a seek', () => { + it('iterates from getIteratorForTime', () => { const index = new shaka.media.SegmentIndex(inputRefs); - const iterator = index[Symbol.iterator](); - expect(iterator.seek(10)).toBe(inputRefs[1]); + const iterator = index.getIteratorForTime(10); + expect(iterator.next().value).toBe(inputRefs[1]); expect(iterator.current()).toBe(inputRefs[1]); expect(iterator.next().value).toBe(inputRefs[2]); expect(iterator.current()).toBe(inputRefs[2]); expect(iterator.next().value).toBe(null); }); - it('iterates forward after a seek with partial segments', () => { + it('iterates from getIteratorForTime with partial segments', () => { const index = new shaka.media.SegmentIndex(inputRefsWithPartial); - const iterator = index[Symbol.iterator](); - expect(iterator.seek(10)).toBe(partialRefs1[0]); + const iterator = index.getIteratorForTime(10); + expect(iterator.next().value).toBe(partialRefs1[0]); expect(iterator.current()).toBe(partialRefs1[0]); expect(iterator.next().value).toBe(partialRefs1[1]); expect(iterator.current()).toBe(partialRefs1[1]); diff --git a/test/offline/manifest_convert_unit.js b/test/offline/manifest_convert_unit.js index a25c58cf6f..aad5f1cdc5 100644 --- a/test/offline/manifest_convert_unit.js +++ b/test/offline/manifest_convert_unit.js @@ -537,8 +537,6 @@ describe('ManifestConverter', () => { // Assume that we don't have to call createSegmentIndex. - const iterator = stream.segmentIndex[Symbol.iterator](); - streamDb.segments.forEach((segmentDb, i) => { const uri = shaka.offline.OfflineUri.segment( 'mechanism', 'cell', segmentDb.dataKey); @@ -548,10 +546,14 @@ describe('ManifestConverter', () => { null; /** @type {shaka.media.SegmentReference} */ - const segment = iterator.seek(segmentDb.startTime); + const segment = + stream.segmentIndex + .getIteratorForTime(segmentDb.startTime).next().value; /** @type {shaka.media.SegmentReference} */ - const sameSegment = iterator.seek(segmentDb.endTime - 0.1); + const sameSegment = + stream.segmentIndex + .getIteratorForTime(segmentDb.endTime - 0.1).next().value; expect(segment).toBe(sameSegment); expect(segment.startTime).toBe(segmentDb.startTime); diff --git a/test/util/functional_unit.js b/test/util/functional_unit.js deleted file mode 100644 index 48cadad510..0000000000 --- a/test/util/functional_unit.js +++ /dev/null @@ -1,82 +0,0 @@ -/*! @license - * Shaka Player - * Copyright 2016 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ - -goog.require('shaka.util.Functional'); - -describe('Functional', () => { - const Functional = shaka.util.Functional; - - function supportsEs6Classes() { - // The callFactory tests should only be run on platforms that support ES6 - // classes. We need to use classes directly to ensure that callFactory is - // working correctly. - try { - eval('class Foo {}'); - return true; - } catch (e) { // eslint-disable-line no-restricted-syntax - return false; - } - } - - filterDescribe('callFactory', supportsEs6Classes, () => { - // All of the following factories/functions/classes create objects with a - // field called "val" with a value of 1. This is a type def to satisfy the - // compiler. - /** @typedef {{val: number}} */ - let DummyObjType; - - // Wait to create these in beforeAll(). That way, the calls will not happen - // on platforms that don't support ES6. The filter doesn't remove the body - // of the "describe" block, only the bodies of before/after and it. - /** @type {function():DummyObjType} */ - let FactoryFunction; - /** @type {function():DummyObjType} */ - let FactoryArrowFunction; - /** @type {function():DummyObjType} */ - let Es5ConstructorFunction; - /** @type {function():DummyObjType} */ - let Es6Class; - - beforeAll(() => { - // Normally, our tests are transpiled by Babel to allow them to run on all - // browsers. However, that would convert all of these into plain - // functions, which would defeat the purpose. Therefore, we're using eval - // to make sure these get defined in exactly this way. Furthermore, to - // make sure these are returned to names that are in scope of this test - // suite in strict mode (used by Babel), each eval must use an assignment - // syntax to a dummy variable, then return it. - FactoryFunction = /** @type {function():DummyObjType} */(eval( - 'const f = function() { return { val: 1 }; }; f;')); - FactoryArrowFunction = /** @type {function():DummyObjType} */(eval( - 'const f = () => { return { val: 1 }; }; f;')); - Es5ConstructorFunction = /** @type {function():DummyObjType} */(eval( - 'const f = function() { this.val = 1; }; f;')); - Es6Class = /** @type {function():DummyObjType} */(eval( - 'const f = class { constructor() { this.val = 1; } }; f;')); - }); - - it('supports true factory functions', () => { - const obj = Functional.callFactory(FactoryFunction); - expect(obj.val).toBe(1); - }); - - it('supports true factory arrow functions', () => { - const obj = Functional.callFactory(FactoryArrowFunction); - expect(obj.val).toBe(1); - }); - - it('supports ES5 constructor functions', () => { - const obj = Functional.callFactory(Es5ConstructorFunction); - expect(obj.val).toBe(1); - }); - - // Regression test for https://github.com/shaka-project/shaka-player/issues/2958 - it('supports ES6 classes', () => { - const obj = Functional.callFactory(Es6Class); - expect(obj.val).toBe(1); - }); - }); -}); diff --git a/ui/controls.js b/ui/controls.js index 6fe8d393ed..2a2def7a6e 100644 --- a/ui/controls.js +++ b/ui/controls.js @@ -9,7 +9,6 @@ goog.provide('shaka.ui.Controls'); goog.provide('shaka.ui.ControlsPanel'); goog.require('goog.asserts'); -goog.require('shaka.Deprecate'); goog.require('shaka.ads.AdManager'); goog.require('shaka.cast.CastProxy'); goog.require('shaka.log'); @@ -868,22 +867,6 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget { const factory = shaka.ui.ControlsPanel.elementNamesToFactories_.get(name); const element = factory.create(this.controlsButtonPanel_, this); - - if (typeof element.release != 'function') { - shaka.Deprecate.deprecateFeature(4, - 'shaka.extern.IUIElement', - 'Please update UI elements to have a release() method.'); - - // This cast works around compiler strictness about the IUIElement - // type being "@struct" (as ES6 classes are by default). - const moddableElement = /** @type {Object} */(element); - moddableElement['release'] = () => { - if (moddableElement['destroy']) { - moddableElement['destroy'](); - } - }; - } - this.elements_.push(element); } else { shaka.log.alwaysWarn('Unrecognized control panel element requested:', diff --git a/ui/ui.js b/ui/ui.js index fcf5a5976f..76b3b0419a 100644 --- a/ui/ui.js +++ b/ui/ui.js @@ -448,14 +448,6 @@ shaka.ui.Overlay.TrackLabelFormat = { 'LABEL': 3, }; -/* - * "shaka.ui.TrackLabelFormat" is deprecated and will be removed in v4. - * - * @deprecated - * @enum {number} - */ -shaka.ui.TrackLabelFormat = shaka.ui.Overlay.TrackLabelFormat; - /** * Describes the possible reasons that the UI might fail to load. * @@ -468,15 +460,6 @@ shaka.ui.Overlay.FailReasonCode = { }; -/** - * "shaka.ui.FailReasonCode" is deprecated and will be removed in v4. - * - * @deprecated - * @enum {number} - */ -shaka.ui.FailReasonCode = shaka.ui.Overlay.FailReasonCode; - - if (document.readyState == 'complete') { // Don't fire this event synchronously. In a compiled bundle, the "shaka" // namespace might not be exported to the window until after this point.