1
0
mirror of https://github.com/videojs/video.js.git synced 2025-03-29 22:07:10 +02:00

@gkatsev fixed removeRemoteTextTracks not working with return value from addRemoteTextTracks. closes #3253

This commit is contained in:
Gary Katsevman 2016-04-19 15:46:33 -04:00
parent ff83aa6573
commit d3b368ccce
3 changed files with 28 additions and 1 deletions

View File

@ -5,6 +5,7 @@ CHANGELOG
* @benjipott updated IS_CHROME to not be true on MS Edge ([view](https://github.com/videojs/video.js/pull/3232))
* @mister-ben blacklisted Chrome for Android for playback rate support ([view](https://github.com/videojs/video.js/pull/3246))
* @gkatsev made the first emulated text track enabled by default ([view](https://github.com/videojs/video.js/pull/3248))
* @gkatsev fixed removeRemoteTextTracks not working with return value from addRemoteTextTracks ([view](https://github.com/videojs/video.js/pull/3253))
--------------------

View File

@ -2579,7 +2579,9 @@ class Player extends Component {
* @param {Object} track Remote text track to remove
* @method removeRemoteTextTrack
*/
removeRemoteTextTrack(track) {
// destructure the input into an object with a track argument, defaulting to arguments[0]
// default the whole argument to an empty object if nothing was passed in
removeRemoteTextTrack({track = arguments[0]} = {}) { // jshint ignore:line
this.tech_ && this.tech_['removeRemoteTextTrack'](track);
}

View File

@ -529,3 +529,27 @@ test('default captions take precedence over default descriptions', function() {
equal(tracks[1].kind, 'captions', 'the captions track is second');
equal(tracks[1].mode, 'showing', 'the captions track is showing');
});
test('removeRemoteTextTrack should be able to take both a track and the response from addRemoteTextTrack', function() {
let player = TestHelpers.makePlayer();
let track = {
kind: 'kind',
src: 'src',
language: 'language',
label: 'label',
default: 'default'
};
let htmlTrackElement = player.addRemoteTextTrack(track);
equal(player.remoteTextTrackEls().length, 1, 'html track element exist');
player.removeRemoteTextTrack(htmlTrackElement);
equal(player.remoteTextTrackEls().length, 0, 'the track element was removed correctly');
htmlTrackElement = player.addRemoteTextTrack(track);
equal(player.remoteTextTrackEls().length, 1, 'html track element exist');
player.removeRemoteTextTrack(htmlTrackElement.track);
equal(player.remoteTextTrackEls().length, 0, 'the track element was removed correctly');
});