mirror of
https://github.com/videojs/video.js.git
synced 2024-11-28 08:58:46 +02:00
@gkatsev fixes track tests and ignored empty properties in tracks converter. closes #2744
This commit is contained in:
parent
589cab7fa7
commit
ab88bcdde3
@ -7,6 +7,7 @@ CHANGELOG
|
||||
* @forbesjo updated karma to use all installed browsers for unit tests ([view](https://github.com/videojs/video.js/pull/2708))
|
||||
* @forbesjo removed android/ios tests to increase build stability ([view](https://github.com/videojs/video.js/pull/2739))
|
||||
* @nickygerritsen added canPlayType method to player ([view](https://github.com/videojs/video.js/pull/2709))
|
||||
* @gkatsev fixes track tests and ignored empty properties in tracks converter ([view](https://github.com/videojs/video.js/pull/2744))
|
||||
|
||||
--------------------
|
||||
|
||||
|
@ -13,13 +13,15 @@
|
||||
* @private
|
||||
*/
|
||||
let trackToJson_ = function(track) {
|
||||
return {
|
||||
kind: track.kind,
|
||||
label: track.label,
|
||||
language: track.language,
|
||||
id: track.id,
|
||||
inBandMetadataTrackDispatchType: track.inBandMetadataTrackDispatchType,
|
||||
mode: track.mode,
|
||||
let ret = ['kind', 'label', 'language', 'id',
|
||||
'inBandMetadataTrackDispatchType',
|
||||
'mode', 'src'].reduce((acc, prop, i) => {
|
||||
if (track[prop]) {
|
||||
acc[prop] = track[prop];
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {
|
||||
cues: track.cues && Array.prototype.map.call(track.cues, function(cue) {
|
||||
return {
|
||||
startTime: cue.startTime,
|
||||
@ -27,9 +29,10 @@ let trackToJson_ = function(track) {
|
||||
text: cue.text,
|
||||
id: cue.id
|
||||
};
|
||||
}),
|
||||
src: track.src
|
||||
};
|
||||
})
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -46,7 +49,9 @@ let textTracksToJson = function(tech) {
|
||||
let trackObjs = Array.prototype.map.call(trackEls, (t) => t.track);
|
||||
let tracks = Array.prototype.map.call(trackEls, function(trackEl) {
|
||||
let json = trackToJson_(trackEl.track);
|
||||
if (trackEl.src) {
|
||||
json.src = trackEl.src;
|
||||
}
|
||||
return json;
|
||||
});
|
||||
|
||||
|
@ -26,13 +26,12 @@ let cleanup = (item) => {
|
||||
if (Html5.supportsNativeTextTracks()) {
|
||||
q.test('trackToJson_ produces correct representation for native track object', function(a) {
|
||||
let track = document.createElement('track');
|
||||
track.src = 'http://example.com/english.vtt';
|
||||
track.src = 'example.com/english.vtt';
|
||||
track.kind = 'captions';
|
||||
track.srclang = 'en';
|
||||
track.label = 'English';
|
||||
|
||||
a.deepEqual(cleanup(c.trackToJson_(track.track)), {
|
||||
src: undefined,
|
||||
kind: 'captions',
|
||||
label: 'English',
|
||||
language: 'en',
|
||||
@ -45,12 +44,10 @@ if (Html5.supportsNativeTextTracks()) {
|
||||
kind: 'captions',
|
||||
label: 'English',
|
||||
language: 'en',
|
||||
src: 'http://example.com/english.vtt',
|
||||
tech: {}
|
||||
});
|
||||
|
||||
let nativeTrack = document.createElement('track');
|
||||
nativeTrack.src = 'http://example.com/spanish.vtt';
|
||||
nativeTrack.kind = 'captions';
|
||||
nativeTrack.srclang = 'es';
|
||||
nativeTrack.label = 'Spanish';
|
||||
@ -73,13 +70,11 @@ if (Html5.supportsNativeTextTracks()) {
|
||||
};
|
||||
|
||||
a.deepEqual(cleanup(c.textTracksToJson(tech)), [{
|
||||
src: 'http://example.com/spanish.vtt',
|
||||
kind: 'captions',
|
||||
label: 'Spanish',
|
||||
language: 'es',
|
||||
mode: 'disabled'
|
||||
}, {
|
||||
src: 'http://example.com/english.vtt',
|
||||
kind: 'captions',
|
||||
label: 'English',
|
||||
language: 'en',
|
||||
@ -92,12 +87,12 @@ if (Html5.supportsNativeTextTracks()) {
|
||||
kind: 'captions',
|
||||
label: 'English',
|
||||
language: 'en',
|
||||
src: 'http://example.com/english.vtt',
|
||||
src: 'example.com/english.vtt',
|
||||
tech: {}
|
||||
});
|
||||
|
||||
let nativeTrack = document.createElement('track');
|
||||
nativeTrack.src = 'http://example.com/spanish.vtt';
|
||||
nativeTrack.src = 'example.com/spanish.vtt';
|
||||
nativeTrack.kind = 'captions';
|
||||
nativeTrack.srclang = 'es';
|
||||
nativeTrack.label = 'Spanish';
|
||||
@ -137,12 +132,12 @@ q.test('trackToJson_ produces correct representation for emulated track object',
|
||||
kind: 'captions',
|
||||
label: 'English',
|
||||
language: 'en',
|
||||
src: 'http://example.com/english.vtt',
|
||||
src: 'example.com/english.vtt',
|
||||
tech: {}
|
||||
});
|
||||
|
||||
a.deepEqual(cleanup(c.trackToJson_(track)), {
|
||||
src: 'http://example.com/english.vtt',
|
||||
src: 'example.com/english.vtt',
|
||||
kind: 'captions',
|
||||
label: 'English',
|
||||
language: 'en',
|
||||
@ -155,12 +150,12 @@ q.test('textTracksToJson produces good json output for emulated only', function(
|
||||
kind: 'captions',
|
||||
label: 'English',
|
||||
language: 'en',
|
||||
src: 'http://example.com/english.vtt',
|
||||
src: 'example.com/english.vtt',
|
||||
tech: {}
|
||||
});
|
||||
|
||||
let anotherTrack = new TextTrack({
|
||||
src: 'http://example.com/spanish.vtt',
|
||||
src: 'example.com/spanish.vtt',
|
||||
kind: 'captions',
|
||||
srclang: 'es',
|
||||
label: 'Spanish',
|
||||
@ -185,13 +180,13 @@ q.test('textTracksToJson produces good json output for emulated only', function(
|
||||
};
|
||||
|
||||
a.deepEqual(cleanup(c.textTracksToJson(tech)), [{
|
||||
src: 'http://example.com/spanish.vtt',
|
||||
src: 'example.com/spanish.vtt',
|
||||
kind: 'captions',
|
||||
label: 'Spanish',
|
||||
language: 'es',
|
||||
mode: 'disabled'
|
||||
}, {
|
||||
src: 'http://example.com/english.vtt',
|
||||
src: 'example.com/english.vtt',
|
||||
kind: 'captions',
|
||||
label: 'English',
|
||||
language: 'en',
|
||||
@ -204,12 +199,12 @@ q.test('jsonToTextTracks calls addRemoteTextTrack on the tech with emulated trac
|
||||
kind: 'captions',
|
||||
label: 'English',
|
||||
language: 'en',
|
||||
src: 'http://example.com/english.vtt',
|
||||
src: 'example.com/english.vtt',
|
||||
tech: {}
|
||||
});
|
||||
|
||||
let anotherTrack = new TextTrack({
|
||||
src: 'http://example.com/spanish.vtt',
|
||||
src: 'example.com/spanish.vtt',
|
||||
kind: 'captions',
|
||||
srclang: 'es',
|
||||
label: 'Spanish',
|
||||
|
Loading…
Reference in New Issue
Block a user