From b5a0d88ba3824262031185eb22b577e740be75ec Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Wed, 1 Dec 2021 18:05:48 -0500 Subject: [PATCH 1/7] remove hls- events --- src/master-playlist-controller.js | 11 ----------- src/media-groups.js | 1 - src/playback-watcher.js | 4 ---- src/reload-source-on-error.js | 3 --- src/util/text-tracks.js | 1 - src/videojs-http-streaming.js | 2 -- 6 files changed, 22 deletions(-) diff --git a/src/master-playlist-controller.js b/src/master-playlist-controller.js index 20fb0ab39..bf7eed181 100644 --- a/src/master-playlist-controller.js +++ b/src/master-playlist-controller.js @@ -655,11 +655,9 @@ export class MasterPlaylistController extends videojs.EventTarget { this.masterPlaylistLoader_.on('renditiondisabled', () => { this.tech_.trigger({type: 'usage', name: 'vhs-rendition-disabled'}); - this.tech_.trigger({type: 'usage', name: 'hls-rendition-disabled'}); }); this.masterPlaylistLoader_.on('renditionenabled', () => { this.tech_.trigger({type: 'usage', name: 'vhs-rendition-enabled'}); - this.tech_.trigger({type: 'usage', name: 'hls-rendition-enabled'}); }); } @@ -717,28 +715,23 @@ export class MasterPlaylistController extends videojs.EventTarget { if (defaultDemuxed) { this.tech_.trigger({type: 'usage', name: 'vhs-demuxed'}); - this.tech_.trigger({type: 'usage', name: 'hls-demuxed'}); } if (Object.keys(mediaGroups.SUBTITLES).length) { this.tech_.trigger({type: 'usage', name: 'vhs-webvtt'}); - this.tech_.trigger({type: 'usage', name: 'hls-webvtt'}); } if (Vhs.Playlist.isAes(media)) { this.tech_.trigger({type: 'usage', name: 'vhs-aes'}); - this.tech_.trigger({type: 'usage', name: 'hls-aes'}); } if (audioGroupKeys.length && Object.keys(mediaGroups.AUDIO[audioGroupKeys[0]]).length > 1) { this.tech_.trigger({type: 'usage', name: 'vhs-alternate-audio'}); - this.tech_.trigger({type: 'usage', name: 'hls-alternate-audio'}); } if (this.useCueTags_) { this.tech_.trigger({type: 'usage', name: 'vhs-playlist-cue-tags'}); - this.tech_.trigger({type: 'usage', name: 'hls-playlist-cue-tags'}); } } @@ -800,7 +793,6 @@ export class MasterPlaylistController extends videojs.EventTarget { this.mainSegmentLoader_.on('timestampoffset', () => { this.tech_.trigger({type: 'usage', name: 'vhs-timestamp-offset'}); - this.tech_.trigger({type: 'usage', name: 'hls-timestamp-offset'}); }); this.audioSegmentLoader_.on('syncinfoupdate', () => { this.onSyncInfoUpdate_(); @@ -851,7 +843,6 @@ export class MasterPlaylistController extends videojs.EventTarget { this.mainSegmentLoader_.on('fmp4', () => { if (!this.triggeredFmp4Usage) { this.tech_.trigger({type: 'usage', name: 'vhs-fmp4'}); - this.tech_.trigger({type: 'usage', name: 'hls-fmp4'}); this.triggeredFmp4Usage = true; } }); @@ -859,7 +850,6 @@ export class MasterPlaylistController extends videojs.EventTarget { this.audioSegmentLoader_.on('fmp4', () => { if (!this.triggeredFmp4Usage) { this.tech_.trigger({type: 'usage', name: 'vhs-fmp4'}); - this.tech_.trigger({type: 'usage', name: 'hls-fmp4'}); this.triggeredFmp4Usage = true; } }); @@ -1243,7 +1233,6 @@ export class MasterPlaylistController extends videojs.EventTarget { } this.tech_.trigger('blacklistplaylist'); this.tech_.trigger({type: 'usage', name: 'vhs-rendition-blacklisted'}); - this.tech_.trigger({type: 'usage', name: 'hls-rendition-blacklisted'}); // TODO: should we select a new playlist if this blacklist wasn't for the currentPlaylist? // Would be something like media().id !=== currentPlaylist.id and we would need something diff --git a/src/media-groups.js b/src/media-groups.js index c2da756a9..7b0ccd17a 100644 --- a/src/media-groups.js +++ b/src/media-groups.js @@ -912,7 +912,6 @@ export const setupMediaGroups = (settings) => { const onAudioTrackChanged = () => { mediaTypes.AUDIO.onTrackChanged(); tech.trigger({ type: 'usage', name: 'vhs-audio-change' }); - tech.trigger({ type: 'usage', name: 'hls-audio-change' }); }; tech.audioTracks().addEventListener('change', onAudioTrackChanged); diff --git a/src/playback-watcher.js b/src/playback-watcher.js index afeb604f9..98f3e41a6 100644 --- a/src/playback-watcher.js +++ b/src/playback-watcher.js @@ -428,7 +428,6 @@ export default class PlaybackWatcher { // unknown waiting corrections may be useful for monitoring QoS this.tech_.trigger({type: 'usage', name: 'vhs-unknown-waiting'}); - this.tech_.trigger({type: 'usage', name: 'hls-unknown-waiting'}); return; } } @@ -460,7 +459,6 @@ export default class PlaybackWatcher { // live window resyncs may be useful for monitoring QoS this.tech_.trigger({type: 'usage', name: 'vhs-live-resync'}); - this.tech_.trigger({type: 'usage', name: 'hls-live-resync'}); return true; } @@ -482,7 +480,6 @@ export default class PlaybackWatcher { // video underflow may be useful for monitoring QoS this.tech_.trigger({type: 'usage', name: 'vhs-video-underflow'}); - this.tech_.trigger({type: 'usage', name: 'hls-video-underflow'}); return true; } const nextRange = Ranges.findNextRange(buffered, currentTime); @@ -609,7 +606,6 @@ export default class PlaybackWatcher { this.tech_.setCurrentTime(nextRange.start(0) + Ranges.TIME_FUDGE_FACTOR); this.tech_.trigger({type: 'usage', name: 'vhs-gap-skip'}); - this.tech_.trigger({type: 'usage', name: 'hls-gap-skip'}); } gapFromVideoUnderflow_(buffered, currentTime) { diff --git a/src/reload-source-on-error.js b/src/reload-source-on-error.js index bb8b78e7a..38abd5aff 100644 --- a/src/reload-source-on-error.js +++ b/src/reload-source-on-error.js @@ -24,7 +24,6 @@ const initPlugin = function(player, options) { player.ready(() => { player.trigger({type: 'usage', name: 'vhs-error-reload-initialized'}); - player.trigger({type: 'usage', name: 'hls-error-reload-initialized'}); }); /** @@ -55,7 +54,6 @@ const initPlugin = function(player, options) { player.src(sourceObj); player.trigger({type: 'usage', name: 'vhs-error-reload'}); - player.trigger({type: 'usage', name: 'hls-error-reload'}); player.play(); }; @@ -70,7 +68,6 @@ const initPlugin = function(player, options) { // 'errorInterval' time has elapsed since the last source-reload if (Date.now() - lastCalled < localOptions.errorInterval * 1000) { player.trigger({type: 'usage', name: 'vhs-error-reload-canceled'}); - player.trigger({type: 'usage', name: 'hls-error-reload-canceled'}); return; } diff --git a/src/util/text-tracks.js b/src/util/text-tracks.js index cc95a3101..1f9562b25 100644 --- a/src/util/text-tracks.js +++ b/src/util/text-tracks.js @@ -15,7 +15,6 @@ import videojs from 'video.js'; export const createCaptionsTrackIfNotExists = function(inbandTextTracks, tech, captionStream) { if (!inbandTextTracks[captionStream]) { tech.trigger({type: 'usage', name: 'vhs-608'}); - tech.trigger({type: 'usage', name: 'hls-608'}); let instreamId = captionStream; diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index d379bb302..8dd001fd4 100644 --- a/src/videojs-http-streaming.js +++ b/src/videojs-http-streaming.js @@ -646,12 +646,10 @@ class VhsHandler extends Component { if (storedObject && storedObject.bandwidth) { this.options_.bandwidth = storedObject.bandwidth; this.tech_.trigger({type: 'usage', name: 'vhs-bandwidth-from-local-storage'}); - this.tech_.trigger({type: 'usage', name: 'hls-bandwidth-from-local-storage'}); } if (storedObject && storedObject.throughput) { this.options_.throughput = storedObject.throughput; this.tech_.trigger({type: 'usage', name: 'vhs-throughput-from-local-storage'}); - this.tech_.trigger({type: 'usage', name: 'hls-throughput-from-local-storage'}); } } } From 68b2dfab70a1aa54f403ed3f8508453b47255fe3 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Wed, 1 Dec 2021 18:09:16 -0500 Subject: [PATCH 2/7] start a migration guide --- docs/migration-2-3.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 docs/migration-2-3.md diff --git a/docs/migration-2-3.md b/docs/migration-2-3.md new file mode 100644 index 000000000..5e67adec5 --- /dev/null +++ b/docs/migration-2-3.md @@ -0,0 +1,19 @@ +# Migration Guide from 2.x to 3.x + +## All `hls-` events were removed +All `hls-` prefixed events were removed. If you were listening to any of those events, you should switch the prefix from `hls-` to `vhs-`. +For example, if you were listening to `hls-gap-skip`: +```js +player.tech().on('hls-gap-skip', () => { + console.log('a gap has been skipped'); +}); +``` +you should now listening to `vhs-gap-skip`: +```js +player.tech().on('vhs-gap-skip', () => { + console.log('a gap has been skipped'); +}); +``` + +See [VHS Usage Events](../#vhs-usage-events) for more information on these events. + From cec71806a4ad56da29d814aae871adffa15b437f Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Wed, 1 Dec 2021 18:20:04 -0500 Subject: [PATCH 3/7] remove player level properties --- docs/migration-2-3.md | 12 ++++++++++ src/videojs-http-streaming.js | 43 ++--------------------------------- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/docs/migration-2-3.md b/docs/migration-2-3.md index 5e67adec5..d3c79c46b 100644 --- a/docs/migration-2-3.md +++ b/docs/migration-2-3.md @@ -17,3 +17,15 @@ player.tech().on('vhs-gap-skip', () => { See [VHS Usage Events](../#vhs-usage-events) for more information on these events. +## player properties for accessing VHS +All player level properties to access VHS have been removed. + +If you were using any of the following: +* `player.vhs` +* `player.hls` +* `player.dash` + +You should switch that to accessing the `vhs` property on the tech like so: +```js +player.tech().vhs +``` diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index 8dd001fd4..0bf9bbe5f 100644 --- a/src/videojs-http-streaming.js +++ b/src/videojs-http-streaming.js @@ -519,42 +519,9 @@ class VhsHandler extends Component { this.logger_ = logger('VhsHandler'); - // tech.player() is deprecated but setup a reference to HLS for - // backwards-compatibility + // tech.player() but we need access to the player in a few cases if (tech.options_ && tech.options_.playerId) { - const _player = videojs(tech.options_.playerId); - - if (!_player.hasOwnProperty('hls')) { - Object.defineProperty(_player, 'hls', { - get: () => { - videojs.log.warn('player.hls is deprecated. Use player.tech().vhs instead.'); - tech.trigger({ type: 'usage', name: 'hls-player-access' }); - return this; - }, - configurable: true - }); - } - - if (!_player.hasOwnProperty('vhs')) { - Object.defineProperty(_player, 'vhs', { - get: () => { - videojs.log.warn('player.vhs is deprecated. Use player.tech().vhs instead.'); - tech.trigger({ type: 'usage', name: 'vhs-player-access' }); - return this; - }, - configurable: true - }); - } - - if (!_player.hasOwnProperty('dash')) { - Object.defineProperty(_player, 'dash', { - get: () => { - videojs.log.warn('player.dash is deprecated. Use player.tech().vhs instead.'); - return this; - }, - configurable: true - }); - } + const _player = videojs.getPlayer(tech.options_.playerId); this.player_ = _player; } @@ -1149,12 +1116,6 @@ class VhsHandler extends Component { this.qualityLevels_.dispose(); } - if (this.player_) { - delete this.player_.vhs; - delete this.player_.dash; - delete this.player_.hls; - } - if (this.tech_ && this.tech_.vhs) { delete this.tech_.vhs; } From 8c38ecbc88aba0cac8621b0bfd57e69bca5718b8 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Wed, 1 Dec 2021 18:27:34 -0500 Subject: [PATCH 4/7] update tests for hls- events --- test/master-playlist-controller.test.js | 41 +----------------- test/playback-watcher.test.js | 55 ------------------------- test/reload-source-on-error.test.js | 24 ----------- test/videojs-http-streaming.test.js | 54 ------------------------ 4 files changed, 1 insertion(+), 173 deletions(-) diff --git a/test/master-playlist-controller.test.js b/test/master-playlist-controller.test.js index aca68bbd2..e04d8eecb 100644 --- a/test/master-playlist-controller.test.js +++ b/test/master-playlist-controller.test.js @@ -2730,7 +2730,6 @@ QUnit.test('calls to update cues on media when no master', function(assert) { QUnit.test('respects useCueTags option', function(assert) { const origVhsOptions = videojs.options.vhs; let vhsPlaylistCueTagsEvents = 0; - let hlsPlaylistCueTagsEvents = 0; videojs.options.vhs = { useCueTags: true @@ -2743,9 +2742,6 @@ QUnit.test('respects useCueTags option', function(assert) { if (event.name === 'vhs-playlist-cue-tags') { vhsPlaylistCueTagsEvents++; } - if (event.name === 'hls-playlist-cue-tags') { - hlsPlaylistCueTagsEvents++; - } }); this.player.src({ src: 'manifest/media.m3u8', @@ -2759,7 +2755,6 @@ QUnit.test('respects useCueTags option', function(assert) { this.standardXHRResponse(this.requests.shift()); assert.equal(vhsPlaylistCueTagsEvents, 1, 'cue tags event has been triggered once'); - assert.equal(hlsPlaylistCueTagsEvents, 1, 'cue tags event has been triggered once'); assert.ok( this.masterPlaylistController.cueTagsTrack_, 'creates cueTagsTrack_ if useCueTags is truthy' @@ -2824,7 +2819,6 @@ QUnit.test('correctly sets alternate audio track kinds', function(assert) { QUnit.test('trigger events when video and audio is demuxed by default', function(assert) { let vhsDemuxedEvents = 0; - let hlsDemuxedEvents = 0; this.requests.length = 0; this.player.dispose(); @@ -2838,9 +2832,6 @@ QUnit.test('trigger events when video and audio is demuxed by default', function if (event.name === 'vhs-demuxed') { vhsDemuxedEvents++; } - if (event.name === 'hls-demuxed') { - hlsDemuxedEvents++; - } }); openMediaSource(this.player, this.clock); @@ -2850,12 +2841,10 @@ QUnit.test('trigger events when video and audio is demuxed by default', function this.standardXHRResponse(this.requests.shift()); assert.equal(vhsDemuxedEvents, 1, 'video and audio is demuxed by default'); - assert.equal(hlsDemuxedEvents, 1, 'video and audio is demuxed by default'); }); QUnit.test('trigger events when an AES is detected', function(assert) { let vhsAesEvents = 0; - let hlsAesEvents = 0; const isAesCopy = Vhs.Playlist.isAes; Vhs.Playlist.isAes = (media) => { @@ -2866,9 +2855,6 @@ QUnit.test('trigger events when an AES is detected', function(assert) { if (event.name === 'vhs-aes') { vhsAesEvents++; } - if (event.name === 'hls-aes') { - hlsAesEvents++; - } }); // master @@ -2878,7 +2864,6 @@ QUnit.test('trigger events when an AES is detected', function(assert) { this.masterPlaylistController.mediaSource.trigger('sourceopen'); assert.equal(vhsAesEvents, 1, 'an AES HLS stream is detected'); - assert.equal(hlsAesEvents, 1, 'an AES HLS stream is detected'); Vhs.Playlist.isAes = isAesCopy; }); @@ -2895,15 +2880,11 @@ QUnit.test('trigger event when a video fMP4 stream is detected', function(assert this.clock.tick(1); let vhsFmp4Events = 0; - let hlsFmp4Events = 0; this.player.tech_.on('usage', (event) => { if (event.name === 'vhs-fmp4') { vhsFmp4Events++; } - if (event.name === 'hls-fmp4') { - hlsFmp4Events++; - } }); const mpc = this.player.tech(true).vhs.masterPlaylistController_; @@ -2916,7 +2897,7 @@ QUnit.test('trigger event when a video fMP4 stream is detected', function(assert videoEl: this.player.tech_.el_, isVideoOnly: true }).then(() => { - assert.equal(hlsFmp4Events, 0, 'an fMP4 stream is not detected'); + assert.equal(vhsFmp4Events, 0, 'an fMP4 stream is not detected'); const initSegmentRequest = this.requests.shift(); const segmentRequest = this.requests.shift(); @@ -2932,21 +2913,16 @@ QUnit.test('trigger event when a video fMP4 stream is detected', function(assert }); }).then(() => { assert.equal(vhsFmp4Events, 1, 'an fMP4 stream is detected'); - assert.equal(hlsFmp4Events, 1, 'an fMP4 stream is detected'); }); }); QUnit.test('only triggers a single fmp4 usage event', function(assert) { let vhsFmp4Events = 0; - let hlsFmp4Events = 0; this.player.tech_.on('usage', (event) => { if (event.name === 'vhs-fmp4') { vhsFmp4Events++; } - if (event.name === 'hls-fmp4') { - hlsFmp4Events++; - } }); const mainSegmentLoader = this.player.tech(true).vhs.masterPlaylistController_.mainSegmentLoader_; @@ -2954,12 +2930,10 @@ QUnit.test('only triggers a single fmp4 usage event', function(assert) { mainSegmentLoader.trigger('fmp4'); assert.equal(vhsFmp4Events, 1, 'fired fMP4 usage event'); - assert.equal(hlsFmp4Events, 1, 'fired fMP4 usage event'); mainSegmentLoader.trigger('fmp4'); assert.equal(vhsFmp4Events, 1, 'did not fire usage event'); - assert.equal(hlsFmp4Events, 1, 'did not fire usage event'); const audioSegmentLoader = this.player.tech(true).vhs.masterPlaylistController_.audioSegmentLoader_; @@ -2967,7 +2941,6 @@ QUnit.test('only triggers a single fmp4 usage event', function(assert) { audioSegmentLoader.trigger('fmp4'); assert.equal(vhsFmp4Events, 1, 'did not fire usage event'); - assert.equal(hlsFmp4Events, 1, 'did not fire usage event'); }); QUnit.test('trigger event when an audio fMP4 stream is detected', function(assert) { @@ -2983,15 +2956,11 @@ QUnit.test('trigger event when an audio fMP4 stream is detected', function(asser this.clock.tick(1); let vhsFmp4Events = 0; - let hlsFmp4Events = 0; this.player.tech_.on('usage', (event) => { if (event.name === 'vhs-fmp4') { vhsFmp4Events++; } - if (event.name === 'hls-fmp4') { - hlsFmp4Events++; - } }); const mpc = this.player.tech(true).vhs.masterPlaylistController_; @@ -3005,7 +2974,6 @@ QUnit.test('trigger event when an audio fMP4 stream is detected', function(asser isAudioOnly: true }).then(() => { assert.equal(vhsFmp4Events, 0, 'an fMP4 stream is not detected'); - assert.equal(hlsFmp4Events, 0, 'an fMP4 stream is not detected'); const initSegmentRequest = this.requests.shift(); const segmentRequest = this.requests.shift(); @@ -3021,7 +2989,6 @@ QUnit.test('trigger event when an audio fMP4 stream is detected', function(asser }); }).then(() => { assert.equal(vhsFmp4Events, 1, 'an fMP4 stream is detected'); - assert.equal(hlsFmp4Events, 1, 'an fMP4 stream is detected'); }); }); @@ -3342,7 +3309,6 @@ QUnit.test( QUnit.test('adds subtitle tracks when a media playlist is loaded', function(assert) { let vhsWebvttEvents = 0; - let hlsWebvttEvents = 0; this.requests.length = 0; this.player.dispose(); @@ -3358,15 +3324,11 @@ QUnit.test('adds subtitle tracks when a media playlist is loaded', function(asse if (event.name === 'vhs-webvtt') { vhsWebvttEvents++; } - if (event.name === 'hls-webvtt') { - hlsWebvttEvents++; - } }); const masterPlaylistController = this.player.tech_.vhs.masterPlaylistController_; assert.equal(vhsWebvttEvents, 0, 'there is no webvtt detected'); - assert.equal(hlsWebvttEvents, 0, 'there is no webvtt detected'); assert.equal(this.player.textTracks().length, 1, 'one text track to start'); assert.equal( this.player.textTracks()[0].label, @@ -3398,7 +3360,6 @@ QUnit.test('adds subtitle tracks when a media playlist is loaded', function(asse assert.equal(textTracks[1].mode, 'disabled', 'track starts disabled'); assert.equal(textTracks[2].mode, 'disabled', 'track starts disabled'); assert.equal(vhsWebvttEvents, 1, 'there is webvtt detected in the rendition'); - assert.equal(hlsWebvttEvents, 1, 'there is webvtt detected in the rendition'); // change source to make sure tracks are cleaned up this.player.src({ diff --git a/test/playback-watcher.test.js b/test/playback-watcher.test.js index c5709aacf..0d85e9584 100644 --- a/test/playback-watcher.test.js +++ b/test/playback-watcher.test.js @@ -43,15 +43,11 @@ QUnit.module('PlaybackWatcher', { QUnit.test('skips over gap at beginning of stream if played before content is buffered', function(assert) { let vhsGapSkipEvents = 0; - let hlsGapSkipEvents = 0; this.player.tech_.on('usage', (event) => { if (event.name === 'vhs-gap-skip') { vhsGapSkipEvents++; } - if (event.name === 'hls-gap-skip') { - hlsGapSkipEvents++; - } }); // set an arbitrary source @@ -75,7 +71,6 @@ QUnit.test('skips over gap at beginning of stream if played before content is bu this.clock.tick(2000); assert.equal(vhsGapSkipEvents, 1, 'there is one skipped gap'); - assert.equal(hlsGapSkipEvents, 1, 'there is one skipped gap'); // check that player jumped the gap assert.equal( @@ -87,15 +82,11 @@ QUnit.test('skips over gap at beginning of stream if played before content is bu QUnit.test('multiple play events do not cause the gap-skipping logic to be called sooner than expected', function(assert) { let vhsGapSkipEvents = 0; - let hlsGapSkipEvents = 0; this.player.tech_.on('usage', (event) => { if (event.name === 'vhs-gap-skip') { vhsGapSkipEvents++; } - if (event.name === 'hls-gap-skip') { - hlsGapSkipEvents++; - } }); // set an arbitrary source @@ -119,7 +110,6 @@ QUnit.test('multiple play events do not cause the gap-skipping logic to be calle this.clock.tick(2000); assert.equal(vhsGapSkipEvents, 0, 'there is no skipped gap'); - assert.equal(hlsGapSkipEvents, 0, 'there is no skipped gap'); // check that player did not skip the gap assert.equal( @@ -134,7 +124,6 @@ QUnit.test('multiple play events do not cause the gap-skipping logic to be calle this.clock.tick(2000); assert.equal(vhsGapSkipEvents, 1, 'there is one skipped gap'); - assert.equal(hlsGapSkipEvents, 1, 'there is one skipped gap'); // check that player did skip the gap after another 250ms has gone by assert.equal( @@ -146,7 +135,6 @@ QUnit.test('multiple play events do not cause the gap-skipping logic to be calle QUnit.test('changing sources does not break ability to skip gap at beginning of stream on first play', function(assert) { let vhsGapSkipEvents = 0; - let hlsGapSkipEvents = 0; this.player.dispose(); @@ -165,9 +153,6 @@ QUnit.test('changing sources does not break ability to skip gap at beginning of if (event.name === 'vhs-gap-skip') { vhsGapSkipEvents++; } - if (event.name === 'hls-gap-skip') { - hlsGapSkipEvents++; - } }); // set an arbitrary source @@ -190,7 +175,6 @@ QUnit.test('changing sources does not break ability to skip gap at beginning of this.clock.tick(2000); assert.equal(vhsGapSkipEvents, 1, 'there is one skipped gap'); - assert.equal(hlsGapSkipEvents, 1, 'there is one skipped gap'); // check that player jumped the gap assert.equal( @@ -201,7 +185,6 @@ QUnit.test('changing sources does not break ability to skip gap at beginning of // Simulate the source changing while the player is in a `playing` state vhsGapSkipEvents = 0; - hlsGapSkipEvents = 0; this.player.currentTime(0); this.player.src({ @@ -217,7 +200,6 @@ QUnit.test('changing sources does not break ability to skip gap at beginning of this.clock.tick(2000); assert.equal(vhsGapSkipEvents, 1, 'there is one skipped gap'); - assert.equal(hlsGapSkipEvents, 1, 'there is one skipped gap'); // check that player jumped the gap assert.equal( @@ -229,7 +211,6 @@ QUnit.test('changing sources does not break ability to skip gap at beginning of QUnit.test('skips over gap in firefox with waiting event', function(assert) { let vhsGapSkipEvents = 0; - let hlsGapSkipEvents = 0; this.player.autoplay(true); @@ -237,9 +218,6 @@ QUnit.test('skips over gap in firefox with waiting event', function(assert) { if (event.name === 'vhs-gap-skip') { vhsGapSkipEvents++; } - if (event.name === 'hls-gap-skip') { - hlsGapSkipEvents++; - } }); // create a buffer with a gap between 10 & 20 seconds @@ -264,7 +242,6 @@ QUnit.test('skips over gap in firefox with waiting event', function(assert) { this.clock.tick(1); assert.equal(vhsGapSkipEvents, 0, 'there is no skipped gap'); - assert.equal(hlsGapSkipEvents, 0, 'there is no skipped gap'); // seek to 10 seconds and wait 12 seconds this.player.currentTime(10); this.player.tech_.trigger('waiting'); @@ -276,12 +253,10 @@ QUnit.test('skips over gap in firefox with waiting event', function(assert) { 20, 'Player seeked over gap after timer' ); assert.equal(vhsGapSkipEvents, 1, 'there is one skipped gap'); - assert.equal(hlsGapSkipEvents, 1, 'there is one skipped gap'); }); QUnit.test('skips over gap in chrome without waiting event', function(assert) { let vhsGapSkipEvents = 0; - let hlsGapSkipEvents = 0; this.player.autoplay(true); @@ -289,9 +264,6 @@ QUnit.test('skips over gap in chrome without waiting event', function(assert) { if (event.name === 'vhs-gap-skip') { vhsGapSkipEvents++; } - if (event.name === 'hls-gap-skip') { - hlsGapSkipEvents++; - } }); // create a buffer with a gap between 10 & 20 seconds @@ -316,7 +288,6 @@ QUnit.test('skips over gap in chrome without waiting event', function(assert) { this.clock.tick(1); assert.equal(vhsGapSkipEvents, 0, 'there is no skipped gap'); - assert.equal(hlsGapSkipEvents, 0, 'there is no skipped gap'); // seek to 10 seconds & simulate chrome waiting event this.player.currentTime(10); @@ -333,12 +304,10 @@ QUnit.test('skips over gap in chrome without waiting event', function(assert) { 20, 'Player seeked over gap after timer' ); assert.equal(vhsGapSkipEvents, 1, 'there is one skipped gap'); - assert.equal(hlsGapSkipEvents, 1, 'there is one skipped gap'); }); QUnit.test('skips over gap in Chrome due to muxed video underflow', function(assert) { let vhsVideoUnderflowEvents = 0; - let hlsVideoUnderflowEvents = 0; this.player.autoplay(true); @@ -346,9 +315,6 @@ QUnit.test('skips over gap in Chrome due to muxed video underflow', function(ass if (event.name === 'vhs-video-underflow') { vhsVideoUnderflowEvents++; } - if (event.name === 'hls-video-underflow') { - hlsVideoUnderflowEvents++; - } }); // set an arbitrary source @@ -367,7 +333,6 @@ QUnit.test('skips over gap in Chrome due to muxed video underflow', function(ass this.clock.tick(1); assert.equal(vhsVideoUnderflowEvents, 0, 'no video underflow event got triggered'); - assert.equal(hlsVideoUnderflowEvents, 0, 'no video underflow event got triggered'); const mpc = this.player.tech_.vhs.masterPlaylistController_; @@ -388,12 +353,10 @@ QUnit.test('skips over gap in Chrome due to muxed video underflow', function(ass assert.equal(seeks.length, 1, 'one seek'); assert.equal(seeks[0], 13, 'player seeked to current time'); assert.equal(vhsVideoUnderflowEvents, 1, 'triggered a video underflow event'); - assert.equal(hlsVideoUnderflowEvents, 1, 'triggered a video underflow event'); }); QUnit.test('skips over gap in Chrome due to demuxed video underflow', function(assert) { let vhsVideoUnderflowEvents = 0; - let hlsVideoUnderflowEvents = 0; this.player.autoplay(true); @@ -401,9 +364,6 @@ QUnit.test('skips over gap in Chrome due to demuxed video underflow', function(a if (event.name === 'vhs-video-underflow') { vhsVideoUnderflowEvents++; } - if (event.name === 'hls-video-underflow') { - hlsVideoUnderflowEvents++; - } }); // set an arbitrary source @@ -422,7 +382,6 @@ QUnit.test('skips over gap in Chrome due to demuxed video underflow', function(a this.clock.tick(1); assert.equal(vhsVideoUnderflowEvents, 0, 'no video underflow event got triggered'); - assert.equal(hlsVideoUnderflowEvents, 0, 'no video underflow event got triggered'); const mpc = this.player.tech_.vhs.masterPlaylistController_; @@ -447,7 +406,6 @@ QUnit.test('skips over gap in Chrome due to demuxed video underflow', function(a assert.equal(seeks.length, 1, 'one seek'); assert.equal(seeks[0], 18, 'player seeked to current time'); assert.equal(vhsVideoUnderflowEvents, 1, 'triggered a video underflow event'); - assert.equal(hlsVideoUnderflowEvents, 1, 'triggered a video underflow event'); }); QUnit.test( @@ -662,9 +620,7 @@ QUnit.test('fires notifications when activated', function(assert) { const seekable = [[]]; let currentTime = 0; let vhsLiveResyncEvents = 0; - let hlsLiveResyncEvents = 0; let vhsVideoUnderflowEvents = 0; - let hlsVideoUnderflowEvents = 0; this.player.src({ src: 'liveStart30sBefore.m3u8', @@ -703,31 +659,22 @@ QUnit.test('fires notifications when activated', function(assert) { if (event.name === 'vhs-live-resync') { vhsLiveResyncEvents++; } - if (event.name === 'hls-live-resync') { - hlsLiveResyncEvents++; - } if (event.name === 'vhs-video-underflow') { vhsVideoUnderflowEvents++; } - if (event.name === 'hls-video-underflow') { - hlsVideoUnderflowEvents++; - } }); currentTime = 19; seekable[0] = [20, 30]; playbackWatcher.waiting_(); assert.equal(vhsLiveResyncEvents, 1, 'triggered a liveresync event'); - assert.equal(hlsLiveResyncEvents, 1, 'triggered a liveresync event'); currentTime = 12; seekable[0] = [0, 100]; buffered = [[0, 9], [10, 20]]; playbackWatcher.waiting_(); assert.equal(vhsVideoUnderflowEvents, 1, 'triggered a videounderflow event'); - assert.equal(hlsVideoUnderflowEvents, 1, 'triggered a videounderflow event'); assert.equal(vhsLiveResyncEvents, 1, 'did not trigger an additional liveresync event'); - assert.equal(hlsLiveResyncEvents, 1, 'did not trigger an additional liveresync event'); }); QUnit.test('fixes bad seeks', function(assert) { @@ -1426,7 +1373,6 @@ loaderTypes.forEach(function(type) { expectedUsage[`vhs-${type}-download-exclusion`] = 1; expectedUsage['vhs-rendition-blacklisted'] = 1; - expectedUsage['hls-rendition-blacklisted'] = 1; // expectedUsage['vhs-rendition-change-exclude'] = 1; assert.deepEqual(this.usageEvents, expectedUsage, 'usage as expected'); @@ -1465,7 +1411,6 @@ loaderTypes.forEach(function(type) { expectedUsage[`vhs-${type}-download-exclusion`] = 1; expectedUsage['vhs-rendition-blacklisted'] = 1; - expectedUsage['hls-rendition-blacklisted'] = 1; if (!last) { expectedUsage['vhs-rendition-change-exclude'] = 1; } diff --git a/test/reload-source-on-error.test.js b/test/reload-source-on-error.test.js index f930b2308..ceb78303d 100644 --- a/test/reload-source-on-error.test.js +++ b/test/reload-source-on-error.test.js @@ -145,35 +145,23 @@ QUnit.test('by default, only allows a retry once every 30 seconds', function(ass let vhsErrorReloadInitializedEvents = 0; let vhsErrorReloadEvents = 0; let vhsErrorReloadCanceledEvents = 0; - let hlsErrorReloadInitializedEvents = 0; - let hlsErrorReloadEvents = 0; - let hlsErrorReloadCanceledEvents = 0; this.player.on('usage', (event) => { if (event.name === 'vhs-error-reload-initialized') { vhsErrorReloadInitializedEvents++; } - if (event.name === 'hls-error-reload-initialized') { - hlsErrorReloadInitializedEvents++; - } }); this.player.on('usage', (event) => { if (event.name === 'vhs-error-reload') { vhsErrorReloadEvents++; } - if (event.name === 'hls-error-reload') { - hlsErrorReloadEvents++; - } }); this.player.on('usage', (event) => { if (event.name === 'vhs-error-reload-canceled') { vhsErrorReloadCanceledEvents++; } - if (event.name === 'hls-error-reload-canceled') { - hlsErrorReloadCanceledEvents++; - } }); assert.equal(vhsErrorReloadInitializedEvents, 0, 'the plugin has not been initialized'); @@ -182,12 +170,6 @@ QUnit.test('by default, only allows a retry once every 30 seconds', function(ass vhsErrorReloadCanceledEvents, 0, 'reload canceled event has not been triggered' ); - assert.equal(hlsErrorReloadInitializedEvents, 0, 'the plugin has not been initialized'); - assert.equal(hlsErrorReloadEvents, 0, 'no source was set'); - assert.equal( - hlsErrorReloadCanceledEvents, 0, - 'reload canceled event has not been triggered' - ); this.player.reloadSourceOnError(); this.player.trigger('error', -2); @@ -195,8 +177,6 @@ QUnit.test('by default, only allows a retry once every 30 seconds', function(ass assert.equal(vhsErrorReloadInitializedEvents, 1, 'the plugin has been initialized'); assert.equal(vhsErrorReloadEvents, 1, 'src was set after an error caused the reload'); - assert.equal(hlsErrorReloadInitializedEvents, 1, 'the plugin has been initialized'); - assert.equal(hlsErrorReloadEvents, 1, 'src was set after an error caused the reload'); assert.equal(this.player.src.calledWith.length, 1, 'player.src was only called once'); // Advance 59 seconds @@ -215,10 +195,6 @@ QUnit.test('by default, only allows a retry once every 30 seconds', function(ass vhsErrorReloadCanceledEvents, 1, 'did not reload the source because not enough time has elapsed' ); - assert.equal( - hlsErrorReloadCanceledEvents, 1, - 'did not reload the source because not enough time has elapsed' - ); assert.equal(this.player.src.calledWith.length, 2, 'player.src was called twice'); }); diff --git a/test/videojs-http-streaming.test.js b/test/videojs-http-streaming.test.js index cc25c6587..8300c6c55 100644 --- a/test/videojs-http-streaming.test.js +++ b/test/videojs-http-streaming.test.js @@ -216,7 +216,6 @@ QUnit.test('deprecation warning is show when using player.hls', function(assert) const oldWarn = videojs.log.warn; let warning = ''; let vhsPlayerAccessEvents = 0; - let hlsPlayerAccessEvents = 0; this.player.src({ src: 'manifest/playlist.m3u8', @@ -229,20 +228,15 @@ QUnit.test('deprecation warning is show when using player.hls', function(assert) if (event.name === 'vhs-player-access') { vhsPlayerAccessEvents++; } - if (event.name === 'hls-player-access') { - hlsPlayerAccessEvents++; - } }); videojs.log.warn = (text) => { warning = text; }; assert.equal(vhsPlayerAccessEvents, 0, 'no vhs-player-access event was fired'); - assert.equal(hlsPlayerAccessEvents, 0, 'no hls-player-access event was fired'); const hls = this.player.hls; assert.equal(vhsPlayerAccessEvents, 0, 'no vhs-player-access event was fired'); - assert.equal(hlsPlayerAccessEvents, 1, 'an hls-player-access event was fired'); assert.equal( warning, 'player.hls is deprecated. Use player.tech().vhs instead.', @@ -256,7 +250,6 @@ QUnit.test('deprecation warning is show when using player.vhs', function(assert) const oldWarn = videojs.log.warn; let warning = ''; let vhsPlayerAccessEvents = 0; - let hlsPlayerAccessEvents = 0; this.player.src({ src: 'manifest/playlist.m3u8', @@ -269,20 +262,15 @@ QUnit.test('deprecation warning is show when using player.vhs', function(assert) if (event.name === 'vhs-player-access') { vhsPlayerAccessEvents++; } - if (event.name === 'hls-player-access') { - hlsPlayerAccessEvents++; - } }); videojs.log.warn = (text) => { warning = text; }; assert.equal(vhsPlayerAccessEvents, 0, 'no vhs-player-access event was fired'); - assert.equal(hlsPlayerAccessEvents, 0, 'no hls-player-access event was fired'); const vhs = this.player.vhs; assert.equal(vhsPlayerAccessEvents, 1, 'a vhs-player-access event was fired'); - assert.equal(hlsPlayerAccessEvents, 0, 'no hls-player-access event was fired'); assert.equal( warning, 'player.vhs is deprecated. Use player.tech().vhs instead.', @@ -2276,7 +2264,6 @@ QUnit.test('playlist 404 should blacklist media', function(assert) { let blacklistplaylist = 0; let retryplaylist = 0; let vhsRenditionBlacklistedEvents = 0; - let hlsRenditionBlacklistedEvents = 0; this.player.src({ src: 'manifest/master.m3u8', @@ -2292,9 +2279,6 @@ QUnit.test('playlist 404 should blacklist media', function(assert) { if (event.name === 'vhs-rendition-blacklisted') { vhsRenditionBlacklistedEvents++; } - if (event.name === 'hls-rendition-blacklisted') { - hlsRenditionBlacklistedEvents++; - } }); this.player.tech_.vhs.bandwidth = 1e10; @@ -2319,11 +2303,6 @@ QUnit.test('playlist 404 should blacklist media', function(assert) { 0, 'no vhs-rendition-blacklisted event was fired' ); - assert.equal( - hlsRenditionBlacklistedEvents, - 0, - 'no hls-rendition-blacklisted event was fired' - ); // media this.requests[1].respond(404); url = this.requests[1].url.slice(this.requests[1].url.lastIndexOf('/') + 1); @@ -2348,11 +2327,6 @@ QUnit.test('playlist 404 should blacklist media', function(assert) { 1, 'a vhs-rendition-blacklisted event was fired' ); - assert.equal( - hlsRenditionBlacklistedEvents, - 1, - 'an hls-rendition-blacklisted event was fired' - ); assert.equal(retryplaylist, 0, 'haven\'t retried any playlist'); // request for the final available media @@ -4204,7 +4178,6 @@ QUnit.test('cleans up the buffer when loading VOD segments', function(assert) { QUnit.test('when mediaGroup changes enabled track should not change', function(assert) { let vhsAudioChangeEvents = 0; - let hlsAudioChangeEvents = 0; this.player.src({ src: 'manifest/multipleAudioGroups.m3u8', @@ -4219,9 +4192,6 @@ QUnit.test('when mediaGroup changes enabled track should not change', function(a if (event.name === 'vhs-audio-change') { vhsAudioChangeEvents++; } - if (event.name === 'hls-audio-change') { - hlsAudioChangeEvents++; - } }); // master @@ -4233,7 +4203,6 @@ QUnit.test('when mediaGroup changes enabled track should not change', function(a let audioTracks = this.player.audioTracks(); assert.equal(vhsAudioChangeEvents, 0, 'no vhs-audio-change event was fired'); - assert.equal(hlsAudioChangeEvents, 0, 'no hls-audio-change event was fired'); assert.equal(audioTracks.length, 3, 'three audio tracks after load'); assert.equal(audioTracks[0].enabled, true, 'track one enabled after load'); @@ -4283,7 +4252,6 @@ QUnit.test('when mediaGroup changes enabled track should not change', function(a audioTracks = this.player.audioTracks(); assert.equal(vhsAudioChangeEvents, 1, 'a vhs-audio-change event was fired'); - assert.equal(hlsAudioChangeEvents, 1, 'an hls-audio-change event was fired'); assert.equal(audioTracks.length, 3, 'three audio tracks after reverting mediaGroup'); assert.notOk(audioTracks[0].enabled, 'the default track is still disabled'); assert.ok(audioTracks[1].enabled, 'track two is still enabled'); @@ -5154,8 +5122,6 @@ QUnit[testOrSkip]('retrieves bandwidth and throughput from localStorage', functi let vhsBandwidthUsageEvents = 0; let vhsThroughputUsageEvents = 0; - let hlsBandwidthUsageEvents = 0; - let hlsThroughputUsageEvents = 0; const usageListener = (event) => { if (event.name === 'vhs-bandwidth-from-local-storage') { vhsBandwidthUsageEvents++; @@ -5163,12 +5129,6 @@ QUnit[testOrSkip]('retrieves bandwidth and throughput from localStorage', functi if (event.name === 'vhs-throughput-from-local-storage') { vhsThroughputUsageEvents++; } - if (event.name === 'hls-bandwidth-from-local-storage') { - hlsBandwidthUsageEvents++; - } - if (event.name === 'hls-throughput-from-local-storage') { - hlsThroughputUsageEvents++; - } }; // values must be stored before player is created, otherwise defaults are provided @@ -5193,8 +5153,6 @@ QUnit[testOrSkip]('retrieves bandwidth and throughput from localStorage', functi assert.equal(vhsBandwidthUsageEvents, 0, 'no bandwidth usage event'); assert.equal(vhsThroughputUsageEvents, 0, 'no throughput usage event'); - assert.equal(hlsBandwidthUsageEvents, 0, 'no bandwidth usage event'); - assert.equal(hlsThroughputUsageEvents, 0, 'no throughput usage event'); const origVhsOptions = videojs.options.vhs; @@ -5214,8 +5172,6 @@ QUnit[testOrSkip]('retrieves bandwidth and throughput from localStorage', functi assert.equal(this.player.tech_.vhs.throughput, 44, 'retrieved stored throughput'); assert.equal(vhsBandwidthUsageEvents, 1, 'one bandwidth usage event'); assert.equal(vhsThroughputUsageEvents, 1, 'one throughput usage event'); - assert.equal(hlsBandwidthUsageEvents, 1, 'one bandwidth usage event'); - assert.equal(hlsThroughputUsageEvents, 1, 'one throughput usage event'); videojs.options.vhs = origVhsOptions; }); @@ -5228,8 +5184,6 @@ QUnit[testOrSkip]( let vhsBandwidthUsageEvents = 0; let vhsThroughputUsageEvents = 0; - let hlsBandwidthUsageEvents = 0; - let hlsThroughputUsageEvents = 0; const usageListener = (event) => { if (event.name === 'vhs-bandwidth-from-local-storage') { vhsBandwidthUsageEvents++; @@ -5237,12 +5191,6 @@ QUnit[testOrSkip]( if (event.name === 'vhs-throughput-from-local-storage') { vhsThroughputUsageEvents++; } - if (event.name === 'hls-bandwidth-from-local-storage') { - hlsBandwidthUsageEvents++; - } - if (event.name === 'hls-throughput-from-local-storage') { - hlsThroughputUsageEvents++; - } }; const origVhsOptions = videojs.options.vhs; @@ -5269,8 +5217,6 @@ QUnit[testOrSkip]( assert.equal(vhsBandwidthUsageEvents, 0, 'no bandwidth usage event'); assert.equal(vhsThroughputUsageEvents, 0, 'no throughput usage event'); - assert.equal(hlsBandwidthUsageEvents, 0, 'no bandwidth usage event'); - assert.equal(hlsThroughputUsageEvents, 0, 'no throughput usage event'); videojs.options.vhs = origVhsOptions; } From e25b4ea638b3840a9875e708253c02143552c253 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Wed, 1 Dec 2021 18:30:33 -0500 Subject: [PATCH 5/7] remove tests for deprecation of player properties --- test/videojs-http-streaming.test.js | 101 ---------------------------- 1 file changed, 101 deletions(-) diff --git a/test/videojs-http-streaming.test.js b/test/videojs-http-streaming.test.js index 8300c6c55..8f114beee 100644 --- a/test/videojs-http-streaming.test.js +++ b/test/videojs-http-streaming.test.js @@ -212,88 +212,6 @@ QUnit.test('canChangeType is exported', function(assert) { assert[assertion](this.player.tech(true).vhs.canChangeType(), 'canChangeType is correct'); }); -QUnit.test('deprecation warning is show when using player.hls', function(assert) { - const oldWarn = videojs.log.warn; - let warning = ''; - let vhsPlayerAccessEvents = 0; - - this.player.src({ - src: 'manifest/playlist.m3u8', - type: 'application/vnd.apple.mpegurl' - }); - - this.clock.tick(1); - - this.player.tech_.on('usage', (event) => { - if (event.name === 'vhs-player-access') { - vhsPlayerAccessEvents++; - } - }); - - videojs.log.warn = (text) => { - warning = text; - }; - assert.equal(vhsPlayerAccessEvents, 0, 'no vhs-player-access event was fired'); - const hls = this.player.hls; - - assert.equal(vhsPlayerAccessEvents, 0, 'no vhs-player-access event was fired'); - assert.equal( - warning, - 'player.hls is deprecated. Use player.tech().vhs instead.', - 'warning would have been shown' - ); - assert.ok(hls, 'an instance of hls is returned by player.hls'); - videojs.log.warn = oldWarn; -}); - -QUnit.test('deprecation warning is show when using player.vhs', function(assert) { - const oldWarn = videojs.log.warn; - let warning = ''; - let vhsPlayerAccessEvents = 0; - - this.player.src({ - src: 'manifest/playlist.m3u8', - type: 'application/vnd.apple.mpegurl' - }); - - this.clock.tick(1); - - this.player.tech_.on('usage', (event) => { - if (event.name === 'vhs-player-access') { - vhsPlayerAccessEvents++; - } - }); - - videojs.log.warn = (text) => { - warning = text; - }; - assert.equal(vhsPlayerAccessEvents, 0, 'no vhs-player-access event was fired'); - const vhs = this.player.vhs; - - assert.equal(vhsPlayerAccessEvents, 1, 'a vhs-player-access event was fired'); - assert.equal( - warning, - 'player.vhs is deprecated. Use player.tech().vhs instead.', - 'warning would have been shown' - ); - assert.ok(vhs, 'an instance of vhs is returned by player.vhs'); - videojs.log.warn = oldWarn; -}); - -QUnit.test('the VhsHandler instance is referenced by player.vhs', function(assert) { - this.player.src({ - src: 'manifest/playlist.m3u8', - type: 'application/vnd.apple.mpegurl' - }); - this.clock.tick(1); - - const vhs = this.player.vhs; - - assert.ok(vhs instanceof VhsHandler, 'player.vhs references an instance of VhsHandler'); - - assert.equal(this.env.log.warn.calls, 1, 'warning logged'); -}); - QUnit.test('tech error may pause loading', function(assert) { this.player.src({ src: 'manifest/playlist.m3u8', @@ -324,25 +242,6 @@ QUnit.test('tech error may pause loading', function(assert) { }); -QUnit.test('a deprecation notice is shown when using player.dash', function(assert) { - this.player.src({ - src: 'manifest/playlist.m3u8', - type: 'application/vnd.apple.mpegurl' - }); - this.clock.tick(1); - - assert.ok( - this.player.dash instanceof VhsHandler, - 'player.dash references an instance of VhsHandler' - ); - assert.equal(this.env.log.warn.calls, 1, 'warning logged'); - assert.equal( - this.env.log.warn.args[0][0], - 'player.dash is deprecated. Use player.tech().vhs instead.', - 'logged deprecation' - ); -}); - QUnit.test('VhsHandler is referenced by player.tech().vhs', function(assert) { this.player.src({ src: 'manifest/playlist.m3u8', From 16c583d10dab39a52ba0293805d610a1de1e26a0 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Fri, 3 Dec 2021 12:28:04 -0500 Subject: [PATCH 6/7] remove more props and options and deprecation tests --- src/videojs-http-streaming.js | 65 +++------------ test/videojs-http-streaming.test.js | 119 ---------------------------- 2 files changed, 11 insertions(+), 173 deletions(-) diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index 0bf9bbe5f..69254cddd 100644 --- a/src/videojs-http-streaming.js +++ b/src/videojs-http-streaming.js @@ -1,7 +1,7 @@ /** * @file videojs-http-streaming.js * - * The main file for the HLS project. + * The main file for the VHS project. * License: https://github.com/videojs/videojs-http-streaming/blob/master/LICENSE */ import document from 'global/document'; @@ -125,10 +125,10 @@ const handleVhsLoadedMetadata = function(qualityLevels, vhs) { handleVhsMediaChange(qualityLevels, vhs.playlists); }; -// HLS is a source handler, not a tech. Make sure attempts to use it +// VHS is a source handler, not a tech. Make sure attempts to use it // as one do not cause exceptions. Vhs.canPlaySource = function() { - return videojs.log.warn('HLS is no longer a tech. Please remove it from ' + + return videojs.log.warn('VHS is no longer a tech. Please remove it from ' + 'your player\'s techOrder.'); }; @@ -483,11 +483,11 @@ Vhs.supportsTypeNatively = (type) => { }; /** - * HLS is a source handler, not a tech. Make sure attempts to use it + * VHS is a source handler, not a tech. Make sure attempts to use it * as one do not cause exceptions. */ Vhs.isSupported = function() { - return videojs.log.warn('HLS is no longer a tech. Please remove it from ' + + return videojs.log.warn('VHS is no longer a tech. Please remove it from ' + 'your player\'s techOrder.'); }; @@ -495,7 +495,7 @@ const Component = videojs.getComponent('Component'); /** * The Vhs Handler object, where we orchestrate all of the parts - * of HLS to interact with video.js + * of VHS to interact with video.js * * @class VhsHandler * @extends videojs.Component @@ -505,11 +505,7 @@ const Component = videojs.getComponent('Component'); */ class VhsHandler extends Component { constructor(source, tech, options) { - super(tech, videojs.mergeOptions(options.hls, options.vhs)); - - if (options.hls && Object.keys(options.hls).length) { - videojs.log.warn('Using hls options is deprecated. Use vhs instead.'); - } + super(tech, options.vhs); // if a tech level `initialBandwidth` option was passed // use that over the VHS level `bandwidth` option @@ -539,9 +535,9 @@ class VhsHandler extends Component { tech.overrideNativeVideoTracks(true); } else if (this.options_.overrideNative && (tech.featuresNativeVideoTracks || tech.featuresNativeAudioTracks)) { - // overriding native HLS only works if audio tracks have been emulated + // overriding native VHS only works if audio tracks have been emulated // error early if we're misconfigured - throw new Error('Overriding native HLS requires emulated tracks. ' + + throw new Error('Overriding native VHS requires emulated tracks. ' + 'See https://git.io/vMpjB'); } @@ -1120,11 +1116,6 @@ class VhsHandler extends Component { delete this.tech_.vhs; } - // don't check this.tech_.hls as it will log a deprecated warning - if (this.tech_) { - delete this.tech_.hls; - } - if (this.mediaSourceUrl_ && window.URL.revokeObjectURL) { window.URL.revokeObjectURL(this.mediaSourceUrl_); this.mediaSourceUrl_ = null; @@ -1174,15 +1165,6 @@ const VhsSourceHandler = { const localOptions = videojs.mergeOptions(videojs.options, options); tech.vhs = new VhsHandler(source, tech, localOptions); - if (!videojs.hasOwnProperty('hls')) { - Object.defineProperty(tech, 'hls', { - get: () => { - videojs.log.warn('player.tech().hls is deprecated. Use player.tech().vhs instead.'); - return tech.vhs; - }, - configurable: true - }); - } tech.vhs.xhr = xhrFactory(); tech.vhs.src(source.src, source.type); @@ -1190,13 +1172,12 @@ const VhsSourceHandler = { }, canPlayType(type, options = {}) { const { - vhs: { overrideNative = !videojs.browser.IS_ANY_SAFARI } = {}, - hls: { overrideNative: legacyOverrideNative = false } = {} + vhs: { overrideNative = !videojs.browser.IS_ANY_SAFARI } = {} } = videojs.mergeOptions(videojs.options, options); const supportedType = simpleTypeFromSourceType(type); const canUseMsePlayback = supportedType && - (!Vhs.supportsTypeNatively(supportedType) || legacyOverrideNative || overrideNative); + (!Vhs.supportsTypeNatively(supportedType) || overrideNative); return canUseMsePlayback ? 'maybe' : ''; } @@ -1218,36 +1199,12 @@ if (supportsNativeMediaSources()) { } videojs.VhsHandler = VhsHandler; -Object.defineProperty(videojs, 'HlsHandler', { - get: () => { - videojs.log.warn('videojs.HlsHandler is deprecated. Use videojs.VhsHandler instead.'); - return VhsHandler; - }, - configurable: true -}); videojs.VhsSourceHandler = VhsSourceHandler; -Object.defineProperty(videojs, 'HlsSourceHandler', { - get: () => { - videojs.log.warn('videojs.HlsSourceHandler is deprecated. ' + - 'Use videojs.VhsSourceHandler instead.'); - return VhsSourceHandler; - }, - configurable: true -}); videojs.Vhs = Vhs; -Object.defineProperty(videojs, 'Hls', { - get: () => { - videojs.log.warn('videojs.Hls is deprecated. Use videojs.Vhs instead.'); - return Vhs; - }, - configurable: true -}); if (!videojs.use) { - videojs.registerComponent('Hls', Vhs); videojs.registerComponent('Vhs', Vhs); } videojs.options.vhs = videojs.options.vhs || {}; -videojs.options.hls = videojs.options.hls || {}; if (!videojs.getPlugin || !videojs.getPlugin('reloadSourceOnError')) { const registerPlugin = videojs.registerPlugin || videojs.plugin; diff --git a/test/videojs-http-streaming.test.js b/test/videojs-http-streaming.test.js index 8f114beee..6269022e3 100644 --- a/test/videojs-http-streaming.test.js +++ b/test/videojs-http-streaming.test.js @@ -263,125 +263,6 @@ QUnit.test('VhsHandler is referenced by player.tech().vhs', function(assert) { ); }); -QUnit.test('logs deprecation notice when using player.tech().hls', function(assert) { - this.player.src({ - src: 'manifest/playlist.m3u8', - type: 'application/vnd.apple.mpegurl' - }); - this.clock.tick(1); - - assert.ok( - this.player.tech().hls instanceof VhsHandler, - 'player.tech().hls references an instance of VhsHandler' - ); - assert.equal(this.env.log.warn.calls, 2, 'warning logged'); - assert.equal( - this.env.log.warn.args[0][0], - 'Using the tech directly can be dangerous. I hope you know what you\'re doing.\n' + - 'See https://github.com/videojs/video.js/issues/2617 for more info.\n', - 'logged warning' - ); - assert.equal( - this.env.log.warn.args[1][0], - 'player.tech().hls is deprecated. Use player.tech().vhs instead.', - 'logged deprecation' - ); -}); - -QUnit.test('logs deprecation notice when using hls for options', function(assert) { - this.player.dispose(); - this.player = createPlayer({ html5: { hls: { bandwidth: 0 } } }); - - this.player.src({ - src: 'http://example.com/media.m3u8', - type: 'application/vnd.apple.mpegurl' - }); - this.clock.tick(1); - openMediaSource(this.player, this.clock); - - assert.equal(this.player.tech_.vhs.bandwidth, 0, 'set bandwidth to 0'); - assert.equal(this.env.log.warn.calls, 1, 'warning logged'); - assert.equal( - this.env.log.warn.args[0][0], - 'Using hls options is deprecated. Use vhs instead.' - ); -}); - -QUnit.test('logs deprecation notice when using hls for global options', function(assert) { - const origHlsOptions = videojs.options.hls; - - this.player.dispose(); - videojs.options.hls = { - bandwidth: 0 - }; - this.player = createPlayer(); - - this.player.src({ - src: 'http://example.com/media.m3u8', - type: 'application/vnd.apple.mpegurl' - }); - this.clock.tick(1); - openMediaSource(this.player, this.clock); - - assert.equal(this.player.tech_.vhs.bandwidth, 0, 'set bandwidth to 0'); - assert.equal(this.env.log.warn.calls, 1, 'warning logged'); - assert.equal( - this.env.log.warn.args[0][0], - 'Using hls options is deprecated. Use vhs instead.' - ); - - videojs.options.hls = origHlsOptions; -}); - -QUnit.test('logs deprecation notice when using videojs.Hls', function(assert) { - assert.equal(videojs.Hls, Vhs, 'can get Vhs object from videojs.Hls'); - - assert.equal(this.env.log.warn.calls, 1, 'warning logged'); - assert.equal( - this.env.log.warn.args[0][0], - 'videojs.Hls is deprecated. Use videojs.Vhs instead.' - ); -}); - -QUnit.test('logs deprecation notice when using videojs.HlsHandler', function(assert) { - this.player.src({ - src: 'http://example.com/media.m3u8', - type: 'application/vnd.apple.mpegurl' - }); - this.clock.tick(1); - - assert.equal( - videojs.HlsHandler, - VhsHandler, - 'can get VhsHandler from videojs.HlsHandler' - ); - - assert.equal(this.env.log.warn.calls, 1, 'warning logged'); - assert.equal( - this.env.log.warn.args[0][0], - 'videojs.HlsHandler is deprecated. Use videojs.VhsHandler instead.' - ); -}); - -QUnit.test('logs deprecation notice when using videojs.HlsSourceHandler', function(assert) { - this.player.src({ - src: 'http://example.com/media.m3u8', - type: 'application/vnd.apple.mpegurl' - }); - this.clock.tick(1); - - assert.equal( - videojs.HlsSourceHandler, - VhsSourceHandler, - 'can get VhsSourceHandler from videojs.HlsSourceHandler' - ); - - assert.equal(this.env.log.warn.calls, 1, 'warning logged'); - assert.equal( - this.env.log.warn.args[0][0], - 'videojs.HlsSourceHandler is deprecated. Use videojs.VhsSourceHandler instead.' - ); -}); QUnit.test('starts playing if autoplay is specified', function(assert) { this.player.autoplay(true); this.player.src({ From 8497a69574efce4b70eb439d97fec087f2a143bc Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Wed, 15 Dec 2021 16:28:35 -0500 Subject: [PATCH 7/7] update comment --- src/videojs-http-streaming.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index 69254cddd..a07289491 100644 --- a/src/videojs-http-streaming.js +++ b/src/videojs-http-streaming.js @@ -515,7 +515,8 @@ class VhsHandler extends Component { this.logger_ = logger('VhsHandler'); - // tech.player() but we need access to the player in a few cases + // we need access to the player in some cases, + // so, get it from Video.js via the `playerId` if (tech.options_ && tech.options_.playerId) { const _player = videojs.getPlayer(tech.options_.playerId);