Skip to content

Commit 9504a93

Browse files
squarebracketgkatsev
authored andcommitted
fix: make sure source options are passed through (videojs#5241)
The changes to source caching in videojs#5156 introduced a regression where the source options were no longer available to plugins. This PR makes sure the cached source object retains any source options passed along.
1 parent 002d701 commit 9504a93

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/js/player.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ class Player extends Component {
12411241
}
12421242

12431243
// update `currentSource` cache always
1244-
this.cache_.source = {src, type};
1244+
this.cache_.source = mergeOptions({}, srcObj, {src, type});
12451245

12461246
const matchingSources = this.cache_.sources.filter((s) => s.src && s.src === src);
12471247
const sourceElSources = [];

test/unit/player.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,3 +1904,17 @@ QUnit.test('disposing a tech that dit NOT set a poster, should keep the poster',
19041904

19051905
player.dispose();
19061906
});
1907+
1908+
QUnit.test('source options are retained', function(assert) {
1909+
const player = TestHelpers.makePlayer();
1910+
1911+
const source = {
1912+
src: 'https://some.url',
1913+
type: 'someType',
1914+
sourceOption: 'someOption'
1915+
};
1916+
1917+
player.src(source);
1918+
1919+
assert.equal(player.currentSource().sourceOption, 'someOption', 'source option retained');
1920+
});

0 commit comments

Comments
 (0)