Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'anastasia/FLUID-4795'

* anastasia/FLUID-4795:
  FLUID-4795: Refactor captionator tests
  FLUID-4795: Modify captionator tests so most don't run in browsers with native track support
  FLUID-4795: Removing wayward 'console.log'
  FLUID-4795: Bring captionator tests up to latest changes
  FLUID-4795: Upgrade Captionator, to make captions work in Safari.
  FLUID-4795: Upgrade captionator to version that is more in line with spec, update VideoPlayer to new API.
  FLUID-4701: Adding the callback parameter that was accidentally removed back to the Amara url.
  FLUID-4701: Minor code tidy up.
  • Loading branch information...
commit 33c54acffefb66766f9ab20459a9a311ee21273e 2 parents 4539572 + 93e490b
@jobara jobara authored
View
178 demos/videos/ReorganizeFuture/ReorganizeFuture.fr.vtt
@@ -77,357 +77,357 @@ et nous développons des stratégies pour faire face à cette diversité.
Nous essayons de rendre les choses plus simples,
20
-00:00:55.600 -> 00:00:57.500
+00:00:55.600 --> 00:00:57.500
moins complexe, moins chaotique.
21
-00:00:57.500 -> 00:01:00.864
+00:00:57.500 --> 00:01:00.864
Une autre partie de la condition humaine est que nous
22
-00:01:00.864 -> 00:01:03.185
+00:01:00.864 --> 00:01:03.185
essayer de trouver communité et connexions.
23
-00:01:03.200 -> 00:01:09.538
+00:01:03.200 --> 00:01:09.538
Nous formons des groupes formels et informels avec des critères explicites et implicites.
24
-00:01:09.554 -> 00:01:13.979
+00:01:09.554 --> 00:01:13.979
Nous organisons, nous créons des catégories, on filtre, on étiquette.
25
-00:01:13.979 -> 00:01:19.679
+00:01:13.979 --> 00:01:19.679
A notre plus précaires et accablé nous divisons en deux, nous créons des binaires:
26
-00:01:19.679 -> 00:01:21.867
+00:01:19.679 --> 00:01:21.867
masculin, féminin
27
-00:01:21.867 -> 00:01:24.215
+00:01:21.867 --> 00:01:24.215
handicapés, normale
28
-00:01:24.215 -> 00:01:27.031
+00:01:24.215 --> 00:01:27.031
gauche, droite
29
-00:01:27.031 -> 00:01:29.579
+00:01:27.031 --> 00:01:29.579
nous, eux.
30
-00:01:29.579 -> 00:01:34.982
+00:01:29.579 --> 00:01:34.982
Cela se traduit tout dans les questions de qui appartient et qui est exclu.
31
-00:01:34.982 -> 00:01:37.536
+00:01:34.982 --> 00:01:37.536
L'adhésion à des groupes peuvent être auto assignés,
32
-00:01:37.536 -> 00:01:40.467
+00:01:37.536 --> 00:01:40.467
peut être imposée, peut-être même policée.
33
-00:01:40.467 -> 00:01:44.179
+00:01:40.467 --> 00:01:44.179
Les groupes sont utilisés pour affirmer ou d'attribuer des privilèges et des pouvoirs.
34
-00:01:44.179 -> 00:01:46.929
+00:01:44.179 --> 00:01:46.929
Nous utilisons des groupes de juger
35
-00:01:46.929 -> 00:01:49.225
+00:01:46.929 --> 00:01:49.225
valeurs sont attribuées à des groupes
36
-00:01:49.225 -> 00:01:51.887
+00:01:49.225 --> 00:01:51.887
souvent des caractéristiques qui n'ont rien à voir avec
37
-00:01:51.887 -> 00:01:53.356
+00:01:51.887 --> 00:01:53.356
les propriétés originales des groupes fondateurs du
38
-00:01:53.356 -> 00:01:55.982
+00:01:53.356 --> 00:01:55.982
sont généralisés à tous les individus dans le groupe.
39
-00:01:55.982 -> 00:02:00.071
+00:01:55.982 --> 00:02:00.071
Parfois, les gens qui sont dans un groupe imposé
40
-00:02:00.071 -> 00:02:02.831
+00:02:00.071 --> 00:02:02.831
prendre la propriété du groupe et de la réforme
41
-00:02:02.831 -> 00:02:04.423
+00:02:02.831 --> 00:02:04.423
les classifications et les valeurs de l'intérieur.
42
-00:02:04.423 -> 00:02:08.446
+00:02:04.423 --> 00:02:08.446
Parfois, quelqu'un a l'audace
43
-00:02:08.446 -> 00:02:11.746
+00:02:08.446 --> 00:02:11.746
pour sortir de la catégorie, nous avons la mettre dans
44
-00:02:11.746 -> 00:02:16.910
+00:02:11.746 --> 00:02:16.910
mais pour préserver notre catégorie, nous pouvons la renvoyer comme une anomalie.
45
-00:02:16.910 -> 00:02:20.031
+00:02:16.910 --> 00:02:20.031
Certains groupes sont plus fluides tandis que d'autres sont plus fixes.
46
-00:02:20.031 -> 00:02:23.561
+00:02:20.031 --> 00:02:23.561
Nous les groupes se forment pas seulement, mais des groupes de groupes
47
-00:02:23.561 -> 00:02:25.662
+00:02:23.561 --> 00:02:25.662
et des groupes, des groupes, des groupes.
48
-00:02:25.662 -> 00:02:29.100
+00:02:25.662 --> 00:02:29.100
L'adhésion à un groupe peut nous accorder l'adhésion à d'autres groupes.
49
-00:02:29.100 -> 00:02:33.036
+00:02:29.100 --> 00:02:33.036
Mais malgré tout cela, nous sommes diversifiés
50
-00:02:33.036 -> 00:02:34.859
+00:02:33.036 --> 00:02:34.859
nous sommes complexe
51
-00:02:34.859 -> 00:02:36.452
+00:02:34.859 --> 00:02:36.452
nous sommes chaotique.
52
-00:02:36.452 -> 00:02:38.818
+00:02:36.452 --> 00:02:38.818
Individuellement, nous sommes différents
53
-00:02:38.818 -> 00:02:40.441
+00:02:38.818 --> 00:02:40.441
au fil du temps, dans des contextes différents
54
-00:02:40.441 -> 00:02:42.356
+00:02:40.441 --> 00:02:42.356
dans des rôles différents, dans des groupes différents.
55
-00:02:42.356 -> 00:02:45.429
+00:02:42.356 --> 00:02:45.429
Nous devons affirmer notre spécificité
56
-00:02:45.429 -> 00:02:47.864
+00:02:45.429 --> 00:02:47.864
nous avons besoin de former et de perfectionner notre identité.
57
-00:02:47.864 -> 00:02:50.914
+00:02:47.864 --> 00:02:50.914
Nous luttons avec l'identité qui nous est imposé.
58
-00:02:50.914 -> 00:02:56.367
+00:02:50.914 --> 00:02:56.367
Généralement, les gens ne s'intègrent pas facilement dans les catégories assignées
59
-00:02:56.367 -> 00:02:58.982
+00:02:56.367 --> 00:02:58.982
et pourtant nous persistons à les affecter.
60
-00:02:58.982 -> 00:03:02.631
+00:02:58.982 --> 00:03:02.631
Et puis, quelque chose de nouveau arrive
61
-00:03:02.631 -> 00:03:05.415
+00:03:02.631 --> 00:03:05.415
et secoue nos groupes, nos catégories et nos règles
62
-00:03:05.415 -> 00:03:08.266
+00:03:05.415 --> 00:03:08.266
et nous avons besoin d'ajuster, de reconstruire et de repenser.
63
-00:03:08.266 -> 00:03:12.533
+00:03:08.266 --> 00:03:12.533
Quelque chose comme, réseaux et des trucs numérique.
64
-00:03:12.533 -> 00:03:15.471
+00:03:12.533 --> 00:03:15.471
Ce nouveau monde numérique et connecté
65
-00:03:15.471 -> 00:03:17.875
+00:03:15.471 --> 00:03:17.875
remet en question la façon dont nous les choses de groupe
66
-00:03:17.875 -> 00:03:20.759
+00:03:17.875 --> 00:03:20.759
et les défis nos excuses pour laisser les gens sortir.
67
-00:03:20.759 -> 00:03:25.469
+00:03:20.759 --> 00:03:25.469
Le numérique change notre vision du temps, d'espace et de distance
68
-00:03:25.469 -> 00:03:31.085
+00:03:25.469 --> 00:03:31.085
et par extension notre point de vue du design, ce qui est possible et quelles choses coût.
69
-00:03:31.085 -> 00:03:36.048
+00:03:31.085 --> 00:03:36.048
Things Digital sont en plastique, mutable, malléable et adaptable.
70
-00:03:36.048 -> 00:03:39.500
+00:03:36.048 --> 00:03:39.500
Avant, tout le monde ne pouvait en forme
71
-00:03:39.500 -> 00:03:42.167
+00:03:39.500 --> 00:03:42.167
permettre à quelqu'un de quelqu'un d'autre était destiné à l'écart.
72
-00:03:42.167 -> 00:03:46.067
+00:03:42.167 --> 00:03:46.067
. Dans le numérique, la chambre est très extensible
73
-00:03:46.067 -> 00:03:49.767
+00:03:46.067 --> 00:03:49.767
Avant, ce que nous avons créé ne pouvait pas convenir à tous
74
-00:03:49.767 -> 00:03:51.777
+00:03:49.767 --> 00:03:51.777
. Alors nous avons fait l'adapter le plus grand groupe
75
-00:03:51.777 -> 00:03:54.533
+00:03:51.777 --> 00:03:54.533
Nous l'avons fait pour le groupe appelé moyen ou typique
76
-00:03:54.533 -> 00:03:58.267
+00:03:54.533 --> 00:03:58.267
cette gauche à tous de ne pas en moyenne ou typique.
77
-00:03:58.267 -> 00:04:03.399
+00:03:58.267 --> 00:04:03.399
Dans la réalité numérique des choses que nous faisons peut reconfigurer, adapter
78
-00:04:03.399 -> 00:04:06.274
+00:04:03.399 --> 00:04:06.274
et prendre une forme qui est le mieux pour chaque individu.
79
-00:04:06.274 -> 00:04:11.900
+00:04:06.274 --> 00:04:11.900
Dans le monde solide, chaque copie coûte presque le même que l'original.
80
-00:04:11.900 -> 00:04:14.351
+00:04:11.900 --> 00:04:14.351
la consommation a réellement consommé.
81
-00:04:14.351 -> 00:04:18.567
+00:04:14.351 --> 00:04:18.567
Dans le monde numérique, nous pouvons copier presque sans coût.
82
-00:04:18.567 -> 00:04:21.000
+00:04:18.567 --> 00:04:21.000
La consommation ne consomme plus.
83
-00:04:21.000 -> 00:04:24.522
+00:04:21.000 --> 00:04:24.522
Avant, il a fallu beaucoup de temps et d'effort
84
-00:04:24.522 -> 00:04:27.233
+00:04:24.522 --> 00:04:27.233
pour livrer des choses, surtout pour les gens très loin.
85
-00:04:27.233 -> 00:04:30.933
+00:04:27.233 --> 00:04:30.933
Maintenant, il est aussi facile de livrer des choses dans le monde
86
-00:04:30.933 -> 00:04:33.133
+00:04:30.933 --> 00:04:33.133
. Comme il est de livrer des choses à côté
87
-00:04:33.133 -> 00:04:36.852
+00:04:33.133 --> 00:04:36.852
Avant, si on ne place pas les choses dans un endroit fixe
88
-00:04:33.133 -> 00:04:36.852
+00:04:33.133 --> 00:04:36.852
nous aurions du mal à les retrouver.
89
-00:04:39.533 -> 00:04:43.633
+00:04:39.533 --> 00:04:43.633
Maintenant, nous pouvons les placer n'importe où sur le réseau et
90
-00:04:43.633 -> 00:04:46.267
+00:04:43.633 --> 00:04:46.267
les récupérer n'importe où sur le réseau.
91
-00:04:46.267 -> 00:04:50.133
+00:04:46.267 --> 00:04:50.133
Avant, nous avions besoin d'étiqueter les choses clairement et simplement
92
-00:04:50.133 -> 00:04:52.800
+00:04:50.133 --> 00:04:52.800
. Afin que nous puissions les reconnaître et de savoir quoi faire avec eux
93
-00:04:52.800 -> 00:04:56.449
+00:04:52.800 --> 00:04:56.449
Maintenant nous pouvons voir une description de chaque personne ou une chose
94
-00:04:56.449 -> 00:04:59.027
+00:04:56.449 --> 00:04:59.027
ce qui est utile et pertinente à notre but.
95
-00:04:59.027 -> 00:05:03.020
+00:04:59.027 --> 00:05:03.020
Et en passant, nous avons appris que
96
-00:05:03.020 -> 00:05:06.367
+00:05:03.020 --> 00:05:06.367
l'inclusion et l'égalité sont bons pour nous tous.
97
-00:05:06.367 -> 00:05:09.359
+00:05:06.367 --> 00:05:09.359
Nous sommes tous sains, plus riches et plus sage
98
-00:05:09.359 -> 00:05:12.200
+00:05:09.359 --> 00:05:12.200
quand notre société est inclusive et égalitaire.
99
-00:05:12.200 -> 00:05:15.367
+00:05:12.200 --> 00:05:15.367
Nous avons également découvert que les divers groupes
100
-00:05:15.367 -> 00:05:18.936
+00:05:15.367 --> 00:05:18.936
sont plus innovantes et créatives, et mieux à la planification et la prévision.
101
-00:05:18.936 -> 00:05:23.733
+00:05:18.936 --> 00:05:23.733
Nous avons expérimenté avec la nouvelle organisation comme
102
-00:05:23.733 -> 00:05:26.333
+00:05:23.733 --> 00:05:26.333
le plus populaire, pour être ignoré
103
-00:05:26.333 -> 00:05:28.700
+00:05:26.333 --> 00:05:28.700
ami, pas un ami.
104
-00:05:28.700 -> 00:05:31.033
+00:05:28.700 --> 00:05:31.033
Mais nous pouvons faire mieux.
105
-00:05:31.033 -> 00:05:33.267
+00:05:31.033 --> 00:05:33.267
Nous pouvons nous permettre d'être généreux dans notre conception
106
-00:05:33.267 -> 00:05:35.400
+00:05:33.267 --> 00:05:35.400
nous avons moins d'excuses à exclure.
107
-00:05:35.400 -> 00:05:37.567
+00:05:35.400 --> 00:05:37.567
Nous pouvons être fidèles à notre diversité.
108
-00:05:37.567 -> 00:05:43.067
+00:05:37.567 --> 00:05:43.067
Peut-être maintenant, nous pouvons trouver un moyen de faire de la place pour nous tous.
View
7 js/VideoPlayer_html5Captionator.js
@@ -63,14 +63,15 @@ https://source.fluidproject.org/svn/LICENSE.txt
fluid.videoPlayer.html5Captionator.hideAllTracks = function (tracks) {
fluid.each(tracks, function (trackEl) {
- trackEl.track.mode = captionator.TextTrack.OFF;
+ trackEl.track.mode = trackEl.track.DISABLED;
});
};
fluid.videoPlayer.html5Captionator.showCurrentTrack = function (currentCaptions, tracks, captionSources) {
fluid.each(captionSources, function (element, key) {
- var currentState = $.inArray(key, currentCaptions) === -1 ? "OFF" : "SHOWING";
- tracks[key].track.mode = captionator.TextTrack[currentState];
+ var currentState = $.inArray(key, currentCaptions) === -1 ? "DISABLED" : "SHOWING";
+ var track = tracks[key].track;
+ track.mode = track[currentState];
});
};
View
4 lib/captionator/README.txt
@@ -4,8 +4,8 @@ Attribution:
Source:
* Original code is available on GIT https://github.com/cgiffard/Captionator
- * We are using a fork of the code available here:
- https://github.com/michelled/Captionator/tree/FLUID-4701
+ * We are using the master branch of a fork of the code available here:
+ https://github.com/fluid-project/Captionator/
Instructions:
* All necessary documentation about the Captionator could be found on the official Captionator website http://captionatorjs.com/
View
84 lib/captionator/js/captionator.js
@@ -166,7 +166,7 @@
this.oncuechange = function() {};
this.id = id || "";
- this.internalMode = captionator.TextTrack.OFF;
+ this.internalMode = this.DISABLED;
this.cues = new captionator.TextTrackCueList(this);
this.activeCues = new captionator.ActiveTextTrackCueList(this.cues,this);
this.kind = kind || "subtitles";
@@ -182,12 +182,12 @@
};
this.setMode = function(value) {
- var allowedModes = [captionator.TextTrack.OFF,captionator.TextTrack.HIDDEN,captionator.TextTrack.SHOWING], containerID, container;
+ var allowedModes = [this.DISABLED,this.HIDDEN,this.SHOWING], containerID, container;
if (allowedModes.indexOf(value) !== -1) {
if (value !== this.internalMode) {
this.internalMode = value;
- if (this.readyState === captionator.TextTrack.NONE && this.src.length > 0 && value > captionator.TextTrack.OFF) {
+ if (this.readyState === captionator.TextTrack.NONE && this.src.length > 0 && value > this.DISABLED) {
this.loadTrack(this.src,null);
}
@@ -195,7 +195,7 @@
this.videoNode._captionator_dirtyBit = true;
captionator.rebuildCaptions(this.videoNode);
- if (value === captionator.TextTrack.OFF) {
+ if (value === this.DISABLED) {
// make sure the resource is reloaded next time (Is this correct behaviour?)
this.cues.length = 0; // Destroy existing cue data (bugfix)
this.readyState = captionator.TextTrack.NONE;
@@ -242,13 +242,26 @@
this.onload.call(this);
};
+ /* Code with permission from Flocking: https://github.com/colinbdclark/Flocking/ */
+ var readDataUrl = function (url) {
+ var delim = url.indexOf(","),
+ header = url.substring(0, delim),
+ data = url.substring(delim + 1),
+ base64Idx = header.indexOf(";base64"),
+ isBase64 = base64Idx > -1,
+ mimeTypeStartIdx = url.indexOf("data:") + 5,
+ mimeTypeEndIdx = isBase64 ? base64Idx : delim,
+ mimeType = url.substring(mimeTypeStartIdx, mimeTypeEndIdx);
+
+ data = isBase64 ? window.atob(data) : decodeURIComponent(data);
+ return data;
+ };
+
this.loadTrack = function(source) {
var currentTrackElement = this;
if (source.substr(0, 5) == "data:") {
- // TODO: This parsing of the data url is too simplistic. Perhaps there is a library we could use here?
- var vttStart = source.indexOf(',') + 1;
- var vtt = decodeURIComponent(source.substr(vttStart));
- currentTrackElement.processCaptions(vtt);
+ var caps = readDataUrl(source)
+ currentTrackElement.processCaptions(caps);
} else {
var ajaxObject = new XMLHttpRequest();
this.src = source;
@@ -297,15 +310,18 @@
};
};
+
+ //TODO: readyState is an attribute of MediaTrack, not TextTrack, and its values are different
// Define constants for TextTrack.readyState
captionator.TextTrack.NONE = 0;
captionator.TextTrack.LOADING = 1;
captionator.TextTrack.LOADED = 2;
captionator.TextTrack.ERROR = 3;
+
// Define constants for TextTrack.mode
- captionator.TextTrack.OFF = 0;
- captionator.TextTrack.HIDDEN = 1;
- captionator.TextTrack.SHOWING = 2;
+ captionator.TextTrack.prototype.DISABLED = 0;
+ captionator.TextTrack.prototype.HIDDEN = 1;
+ captionator.TextTrack.prototype.SHOWING = 2;
// Define read-only properties
/**
@@ -494,7 +510,7 @@
this.isActive = function() {
var currentTime = 0;
if (this.track instanceof captionator.TextTrack) {
- if ((this.track.mode === captionator.TextTrack.SHOWING || this.track.mode === captionator.TextTrack.HIDDEN) && this.track.readyState === captionator.TextTrack.LOADED) {
+ if ((this.track.mode === this.track.SHOWING || this.track.mode === this.track.HIDDEN) && this.track.readyState === captionator.TextTrack.LOADED) {
try {
currentTime = this.track.videoNode.currentTime;
@@ -569,8 +585,8 @@
this.onerror = function() {};
this.id = id || "";
- this.internalMode = captionator.TextTrack.OFF;
- this.internalMode = captionator.TextTrack.OFF;
+ this.internalMode = this.DISABLED;
+ this.internalMode = this.DISABLED;
this.mediaElement = null;
this.kind = kind || "audiodescription";
this.label = label || "";
@@ -598,19 +614,19 @@
};
this.setMode = function(value) {
- var allowedModes = [captionator.TextTrack.OFF,captionator.TextTrack.HIDDEN,captionator.TextTrack.SHOWING], containerID, container;
+ var allowedModes = [this.DISABLED,this.HIDDEN,this.SHOWING], containerID, container;
if (allowedModes.indexOf(value) !== -1) {
if (value !== this.internalMode) {
this.internalMode = value;
- if (value === captionator.TextTrack.HIDDEN && !this.mediaElement) {
+ if (value === this.HIDDEN && !this.mediaElement) {
this.buildMediaElement();
}
- if (value === captionator.TextTrack.SHOWING) {
+ if (value === this.SHOWING) {
this.showMediaElement();
}
- if (value === captionator.TextTrack.OFF || value === captionator.TextTrack.HIDDEN) {
+ if (value === this.DISABLED || value === this.HIDDEN) {
this.hideMediaElement();
}
}
@@ -684,14 +700,14 @@
this.mediaElement.addEventListener("error",function(eventData) {
mediaElement.trackObject.readyState = captionator.TextTrack.ERROR;
- mediaElement.trackObject.mode = captionator.TextTrack.OFF;
+ mediaElement.trackObject.mode = this.DISABLED;
mediaElement.trackObject.mediaElement = null;
mediaElement.trackObject.onerror.call(mediaElement.trackObject,eventData);
},false);
} catch(Error) {
this.readyState = captionator.TextTrack.ERROR;
- this.mode = captionator.TextTrack.OFF;
+ this.mode = this.DISABLED;
this.mediaElement = null;
if (this.onerror) {
@@ -811,11 +827,11 @@
}).length) {
newTrack = new captionator.TextTrack(id,kind,label,language,src,null);
if (newTrack) {
- if (!(videoElement.tracks instanceof Array)) {
- videoElement.tracks = [];
+ if (!(videoElement.textTracks instanceof Array)) {
+ videoElement.textTracks = [];
}
- videoElement.tracks.push(newTrack);
+ videoElement.textTracks.push(newTrack);
return newTrack;
} else {
return false;
@@ -936,7 +952,7 @@
if ((trackObject.kind === "subtitles" || trackObject.kind === "captions") &&
(defaultLanguage === trackObject.language && options.enableCaptionsByDefault)) {
if (!trackList.filter(function(trackObject) {
- if ((trackObject.kind === "captions" || trackObject.kind === "subtitles") && defaultLanguage === trackObject.language && trackObject.mode === captionator.TextTrack.SHOWING) {
+ if ((trackObject.kind === "captions" || trackObject.kind === "subtitles") && defaultLanguage === trackObject.language && trackObject.mode === trackObject.SHOWING) {
return true;
} else {
return false;
@@ -953,7 +969,7 @@
if (trackObject.kind === "chapters" && (defaultLanguage === trackObject.language)) {
if (!trackList.filter(function(trackObject) {
- if (trackObject.kind === "chapters" && trackObject.mode === captionator.TextTrack.SHOWING) {
+ if (trackObject.kind === "chapters" && trackObject.mode === trackObject.SHOWING) {
return true;
} else {
return false;
@@ -969,7 +985,7 @@
if (trackObject.kind === "descriptions" && (options.enableDescriptionsByDefault === true) && (defaultLanguage === trackObject.language)) {
if (!trackList.filter(function(trackObject) {
- if (trackObject.kind === "descriptions" && trackObject.mode === captionator.TextTrack.SHOWING) {
+ if (trackObject.kind === "descriptions" && trackObject.mode === trackObject.SHOWING) {
return true;
} else {
return false;
@@ -984,8 +1000,8 @@
if (trackEnabled === true) {
trackList.forEach(function(trackObject) {
- if(trackObject.trackNode.hasAttribute("default") && trackObject.mode === captionator.TextTrack.SHOWING) {
- trackObject.mode = captionator.TextTrack.HIDDEN;
+ if(trackObject.trackNode.hasAttribute("default") && trackObject.mode === trackObject.SHOWING) {
+ trackObject.mode = trackObject.HIDDEN;
}
});
}
@@ -1011,7 +1027,7 @@
// Let the text track mode be disabled.
if (trackEnabled === true) {
- trackObject.mode = captionator.TextTrack.SHOWING;
+ trackObject.mode = trackObject.SHOWING;
}
});
@@ -1019,7 +1035,7 @@
var videoElement = eventData.target;
// update active cues
try {
- videoElement.tracks.forEach(function(track) {
+ videoElement.textTracks.forEach(function(track) {
track.activeCues.refreshCues.apply(track.activeCues);
});
} catch(error) {}
@@ -1051,7 +1067,7 @@
if (options.enableHighResolution === true) {
window.setInterval(function captionatorHighResProcessor() {
try {
- videoElement.tracks.forEach(function(track) {
+ videoElement.textTracks.forEach(function(track) {
track.activeCues.refreshCues.apply(track.activeCues);
});
} catch(error) {}
@@ -1081,7 +1097,7 @@
*/
"rebuildCaptions": function(videoElement) {
- var trackList = videoElement.tracks || [];
+ var trackList = videoElement.textTracks || [];
var options = videoElement._captionatorOptions instanceof Object ? videoElement._captionatorOptions : {};
var currentTime = videoElement.currentTime;
var compositeActiveCues = [];
@@ -1091,7 +1107,7 @@
// Work out what cues are showing...
trackList.forEach(function(track,trackIndex) {
- if (track.mode === captionator.TextTrack.SHOWING && track.readyState === captionator.TextTrack.LOADED) {
+ if (track.mode === track.SHOWING && track.readyState === captionator.TextTrack.LOADED) {
cueSortArray = [].slice.call(track.activeCues,0);
// Do a reverse sort
@@ -1186,7 +1202,7 @@
// Work out what cues are showing...
trackList.forEach(function(track,trackIndex) {
- if (track.mode === captionator.TextTrack.SHOWING && track.readyState >= captionator.TextTrack.LOADING) {
+ if (track.mode === track.SHOWING && track.readyState >= captionator.TextTrack.LOADING) {
synchroniseElement(track.mediaElement,videoElement);
}
});
View
204 tests/js/VideoPlayerHTML5CaptionatorTests.js
@@ -20,6 +20,8 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
$(document).ready(function () {
fluid.setLogging(false); // disable it not to mess up with FireBug in FF
+ var nativeTrackSupport = (typeof document.createElement("video").addTextTrack === "function");
+
var container = ".videoPlayer";
var firstEnglishCaption = "English caption here";
var firstFrenchCaption = "French caption here";
@@ -31,9 +33,10 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
var tracks = $("track", html5Captionator.locate("video"));
$.each(tracksShowing, function (index, showing) {
- var msg = showing ? " set to SHOWING" : " set to OFF";
+ var track = tracks[index];
+ var msg = showing ? " set to SHOWING" : " set to DISABLED";
jqUnit.assertEquals(html5Captionator.options.captions[index].label + msg,
- showing ? captionator.TextTrack.SHOWING : captionator.TextTrack.OFF, tracks[index].track.mode);
+ showing ? track.track.SHOWING : track.track.DISABLED, track.track.mode);
});
};
@@ -139,6 +142,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
});
+ // In browsers that have no native support for <track>, Captionator will do its thing.
var noHTML5Tests = [{
desc: "NO HTML5: html5Captionator was not initialized",
async: true,
@@ -147,116 +151,132 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
}];
- var envFeatures = {
+ var noHtml5envFeatures = {
supportsHtml5: null
};
- fluid.testUtils.testCaseWithEnv("Video Player Old Browsers HTML5 Captionator Tests", noHTML5Tests, envFeatures);
- var tests = [{
- desc: "HTML5: html5Captionator was initialized but without tracks",
- async: true,
- testFn: function () {
- testInit(defaultOptionsNoCaptions, true);
- }
- }, {
- desc: "HTML5: html5Captionator was initialized",
- async: true,
- testFn: function () {
- testInit(optionsFull, true, true);
- }
- }, {
- desc: "html5Captionator changing tracks and more",
- async: true,
- testFn: function () {
- initVideoPlayer(optionsFull, function (videoPlayer) {
- // VERY BAD. There is no callback for a captionator to fire when it loaded its captions, so we have to wait 1 second before do the test check
- setTimeout(function () {
- var tracks = $("track", videoPlayer.html5Captionator.locate("video")),
- html5Captionator = videoPlayer.html5Captionator;
+ var html5tests = [{
+ desc: "HTML5: html5Captionator was initialized but without tracks",
+ async: true,
+ testFn: function () {
+ testInit(defaultOptionsNoCaptions, true);
+ }
+ }, {
+ desc: "HTML5: html5Captionator was initialized",
+ async: true,
+ testFn: function () {
+ testInit(optionsFull, true, true);
+ }
+ }, {
+ desc: "html5Captionator changing tracks and more",
+ async: true,
+ testFn: function () {
+ initVideoPlayer(optionsFull, function (videoPlayer) {
+ // VERY BAD. There is no callback for a captionator to fire when it loaded its captions, so we have to wait 1 second before do the test check
+ setTimeout(function () {
+ var tracks = $("track", videoPlayer.html5Captionator.locate("video")),
+ html5Captionator = videoPlayer.html5Captionator;
- jqUnit.assertNotUndefined("html5Captionator has been instantiated", html5Captionator);
- testTrackMode(html5Captionator, [true, false]);
- testCaptionPresence(html5Captionator, firstEnglishCaption);
- fluid.videoPlayer.html5Captionator.showCurrentTrack([1], tracks, html5Captionator.options.captions);
+ jqUnit.assertNotUndefined("html5Captionator has been instantiated", html5Captionator);
+ testTrackMode(html5Captionator, [true, false]);
+ testCaptionPresence(html5Captionator, firstEnglishCaption);
+ fluid.videoPlayer.html5Captionator.showCurrentTrack([1], tracks, html5Captionator.options.captions);
- testTrackMode(html5Captionator, [false, true]);
- // VERY BAD. There is no callback for a captionator to fire when it loaded its captions, so we have to wait 1 second before do the test check
- setTimeout(function () {
- testCaptionPresence(html5Captionator, firstFrenchCaption);
- fluid.videoPlayer.html5Captionator.hideAllTracks(tracks);
- testTrackMode(html5Captionator, [false, false]);
- testCaptionPresence(html5Captionator, "");
- jqUnit.expect(1);
- start();
- }, 1000);
- }, 1000);
- });
- }
- }, { // TEST FLUID-4618. Writing a test to verify that functions in preInit work properly
- desc: "html5Captionator displayCaptions test",
- async: true,
- testFn: function () {
- initVideoPlayer(optionsFull, function (videoPlayer) {
+ testTrackMode(html5Captionator, [false, true]);
// VERY BAD. There is no callback for a captionator to fire when it loaded its captions, so we have to wait 1 second before do the test check
setTimeout(function () {
- var html5Captionator = videoPlayer.html5Captionator;
- html5Captionator.refreshCaptions();
- jqUnit.assertNotUndefined("html5Captionator has been instantiated", html5Captionator);
- testCaptionPresence(html5Captionator, firstEnglishCaption);
+ testCaptionPresence(html5Captionator, firstFrenchCaption);
+ fluid.videoPlayer.html5Captionator.hideAllTracks(tracks);
+ testTrackMode(html5Captionator, [false, false]);
+ testCaptionPresence(html5Captionator, "");
jqUnit.expect(1);
start();
}, 1000);
- });
- }
- }, {
- desc: "html5Captionator without currentTrack",
- async: true,
- testFn: function () {
- initVideoPlayer(optionsWithoutCurrentTrack, function (videoPlayer) {
- setTimeout(function () {
- var html5Captionator = videoPlayer.html5Captionator,
- currentTracks = html5Captionator.model.currentTracks;
+ }, 1000);
+ });
+ }
+ }, { // TEST FLUID-4618. Writing a test to verify that functions in preInit work properly
+ desc: "html5Captionator displayCaptions test",
+ async: true,
+ testFn: function () {
+ initVideoPlayer(optionsFull, function (videoPlayer) {
+ // VERY BAD. There is no callback for a captionator to fire when it loaded its captions, so we have to wait 1 second before do the test check
+ setTimeout(function () {
+ var html5Captionator = videoPlayer.html5Captionator;
+ html5Captionator.refreshCaptions();
+ jqUnit.assertNotUndefined("html5Captionator has been instantiated", html5Captionator);
+ testCaptionPresence(html5Captionator, firstEnglishCaption);
+ jqUnit.expect(1);
+ start();
+ }, 1000);
+ });
+ }
+ }, {
+ desc: "html5Captionator without currentTrack",
+ async: true,
+ testFn: function () {
+ initVideoPlayer(optionsWithoutCurrentTrack, function (videoPlayer) {
+ setTimeout(function () {
+ var html5Captionator = videoPlayer.html5Captionator,
+ currentTracks = html5Captionator.model.currentTracks;
- jqUnit.assertUndefined("currentTracks is empty in the model", optionsWithoutCurrentTrack.currentTracks);
+ jqUnit.assertUndefined("currentTracks is empty in the model", optionsWithoutCurrentTrack.currentTracks);
- jqUnit.assertNotUndefined("html5Captionator has been instantiated", html5Captionator);
+ jqUnit.assertNotUndefined("html5Captionator has been instantiated", html5Captionator);
- jqUnit.assertEquals("Current track is also empty in the html5Captionator model",
- 0, currentTracks.captions.length);
- // Can't support this "self-modification" of the model of captionator since it may corrupt data belonging
- // to others during startup
- //jqUnit.assertEquals("And this element is the index for the first element in the array of captions",
- // 0, currentTracks.captions[0]);
+ jqUnit.assertEquals("Current track is also empty in the html5Captionator model",
+ 0, currentTracks.captions.length);
+ // Can't support this "self-modification" of the model of captionator since it may corrupt data belonging
+ // to others during startup
+ //jqUnit.assertEquals("And this element is the index for the first element in the array of captions",
+ // 0, currentTracks.captions[0]);
- testTrackMode(html5Captionator, [false, false]);
+ testTrackMode(html5Captionator, [false, false]);
- // Check that captions are not present in the DOM
- testCaptionPresence(html5Captionator, "");
- jqUnit.expect(3);
- start();
- });
+ // Check that captions are not present in the DOM
+ testCaptionPresence(html5Captionator, "");
+ jqUnit.expect(3);
+ start();
});
- }
- }, {
- desc: "displayCaptions is set to false so no captions should be present at all in the DOM",
- async: true,
- testFn: function () {
- initVideoPlayer(optionsFullWithDisplayCaptionsOff, function (videoPlayer) {
- setTimeout(function () {
- var html5Captionator = videoPlayer.html5Captionator;
- testTrackMode(html5Captionator, [false, false]);
- // Check that captions are not present in the DOM
- testCaptionPresence(html5Captionator, "");
- start();
- });
+ });
+ }
+ }, {
+ desc: "displayCaptions is set to false so no captions should be present at all in the DOM",
+ async: true,
+ testFn: function () {
+ initVideoPlayer(optionsFullWithDisplayCaptionsOff, function (videoPlayer) {
+ setTimeout(function () {
+ var html5Captionator = videoPlayer.html5Captionator;
+ testTrackMode(html5Captionator, [false, false]);
+ // Check that captions are not present in the DOM
+ testCaptionPresence(html5Captionator, "");
+ start();
});
- }
- }];
+ });
+ }
+ }];
+
+ var html5envFeatures = {
+ "supportsHtml5": "fluid.browser.supportsHtml5"
+ };
- envFeatures = {
+ // In browsers that have native support for <track>, Captionator will bow out.
+ var nativeSupportTests = [{
+ desc: "HTML5: html5Captionator was initialized but bowed out: markup not present",
+ async: true,
+ testFn: function () {
+ testInit(optionsFull, true, false);
+ }
+ }];
+ var envFeatures = {
"supportsHtml5": "fluid.browser.supportsHtml5"
};
- fluid.testUtils.testCaseWithEnv("Video Player HTML5 Captionator Tests", tests, envFeatures);
+ if (!nativeTrackSupport) {
+ fluid.testUtils.testCaseWithEnv("Video Player Old Browsers HTML5 Captionator Tests", noHTML5Tests, noHtml5envFeatures);
+ fluid.testUtils.testCaseWithEnv("Video Player HTML5 Captionator Tests", html5tests, html5envFeatures);
+ } else {
+ fluid.testUtils.testCaseWithEnv("Video Player Native-track-support HTML5 Captionator Tests", nativeSupportTests, envFeatures);
+ }
});
})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.