Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove deprecation hls options, properties, and events #1229

Merged
merged 7 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions docs/migration-2-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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.

## 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
```
11 changes: 0 additions & 11 deletions src/master-playlist-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
});
}

Expand Down Expand Up @@ -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'});
}
}

Expand Down Expand Up @@ -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_();
Expand Down Expand Up @@ -851,15 +843,13 @@ 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;
}
});

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;
}
});
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/media-groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions src/playback-watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions src/reload-source-on-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
});

/**
Expand Down Expand Up @@ -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();
};

Expand All @@ -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;
}

Expand Down
1 change: 0 additions & 1 deletion src/util/text-tracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
111 changes: 14 additions & 97 deletions src/videojs-http-streaming.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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.');
};

Expand Down Expand Up @@ -483,19 +483,19 @@ 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.');
};

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
Expand All @@ -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
Expand All @@ -519,42 +515,10 @@ class VhsHandler extends Component {

this.logger_ = logger('VhsHandler');

// tech.player() is deprecated but setup a reference to HLS for
// backwards-compatibility
// 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(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;
}
Expand All @@ -572,9 +536,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');
}

Expand Down Expand Up @@ -646,12 +610,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'});
}
}
}
Expand Down Expand Up @@ -1151,21 +1113,10 @@ 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;
}

// 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;
Expand Down Expand Up @@ -1215,29 +1166,19 @@ 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);
return tech.vhs;
},
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' : '';
}
Expand All @@ -1259,36 +1200,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;
Expand Down
Loading