Skip to content

Commit b0101a6

Browse files
gkatsevmisteroneill
authored andcommitted
feat: Enable sourceset by default (#7879)
Can still be disabled with enableSourceset: false
1 parent d4559b1 commit b0101a6

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/js/player.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5115,6 +5115,9 @@ Player.prototype.options_ = {
51155115

51165116
html5: {},
51175117

5118+
// enable sourceset by default
5119+
enableSourceset: true,
5120+
51185121
// default inactivity timeout
51195122
inactivityTimeout: 2000,
51205123

test/unit/sourceset.test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,49 @@ const setupAfterEach = function(totalSourcesets) {
115115
const testTypes = ['video el', 'change video el', 'audio el', 'change audio el', 'video-js', 'change video-js el'];
116116

117117
QUnit[qunitFn]('sourceset', function(hooks) {
118+
QUnit.module('sourceset option', (subhooks) => testTypes.forEach((testName) => {
119+
QUnit.module(testName, {
120+
beforeEach() {
121+
122+
setupEnv(this, testName);
123+
},
124+
afterEach: setupAfterEach(1)
125+
});
126+
127+
QUnit.test('sourceset enabled by default', function(assert) {
128+
const done = assert.async();
129+
130+
this.mediaEl.setAttribute('data-setup', JSON.stringify({sources: [testSrc]}));
131+
this.player = videojs(this.mediaEl, {});
132+
133+
this.player.one('sourceset', (e) => {
134+
validateSource(this.player, [testSrc], e);
135+
done();
136+
});
137+
});
138+
139+
QUnit.test('sourceset not triggered if turned off', function(assert) {
140+
const done = assert.async();
141+
142+
this.player = videojs(this.mediaEl, {
143+
enableSourceset: false
144+
});
145+
146+
this.totalSourcesets = 0;
147+
148+
this.player.one('sourceset', (e) => {
149+
this.totalSourcesets = 1;
150+
});
151+
152+
this.player.on('loadstart', () => {
153+
done();
154+
});
155+
156+
this.player.src(testSrc);
157+
158+
});
159+
}));
160+
118161
QUnit.module('source before player', (subhooks) => testTypes.forEach((testName) => {
119162
QUnit.module(testName, {
120163
beforeEach() {

0 commit comments

Comments
 (0)