Browse Source

feat: expose canChangeType on the VHS property (#911)

pull/915/head
Gary Katsevman 5 years ago
committed by GitHub
parent
commit
a4ab2859e9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      src/source-updater.js
  2. 5
      src/videojs-http-streaming.js
  3. 18
      test/videojs-http-streaming.test.js

13
src/source-updater.js

@ -428,12 +428,23 @@ export default class SourceUpdater extends videojs.EventTarget {
* @return {boolean}
* if changeType can be called.
*/
canChangeType() {
static canChangeType() {
return window.SourceBuffer &&
window.SourceBuffer.prototype &&
typeof window.SourceBuffer.prototype.changeType === 'function';
}
/**
* Whether or not the changeType function is supported
* on our SourceBuffers.
*
* @return {boolean}
* if changeType can be called.
*/
canChangeType() {
return this.constructor.canChangeType();
}
/**
* Call the changeType function on a source buffer, given the code and type.
*

5
src/videojs-http-streaming.js

@ -21,6 +21,7 @@ import { MasterPlaylistController } from './master-playlist-controller';
import Config from './config';
import renditionSelectionMixin from './rendition-mixin';
import PlaybackWatcher from './playback-watcher';
import SourceUpdater from './source-updater';
import reloadSourceOnError from './reload-source-on-error';
import {
lastBandwidthSelector,
@ -902,6 +903,10 @@ class VhsHandler extends Component {
return this.constructor.version();
}
canChangeType() {
return SourceUpdater.canChangeType();
}
/**
* Begin playing the video.
*/

18
test/videojs-http-streaming.test.js

@ -192,6 +192,24 @@ QUnit.test('version is exported', function(assert) {
});
QUnit.test('canChangeType is exported', function(assert) {
this.player.src({
src: 'manifest/playlist.m3u8',
type: 'application/vnd.apple.mpegurl'
});
this.clock.tick(1);
assert.ok(this.player.tech(true).vhs.canChangeType, 'canChangeType function');
const canChangeType = window.SourceBuffer &&
window.SourceBuffer.prototype &&
typeof window.SourceBuffer.prototype.changeType === 'function';
const assertion = canChangeType ? 'ok' : 'notOk';
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 = '';

Loading…
Cancel
Save