forked from boronia/ableplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsign.js
More file actions
95 lines (82 loc) · 2.64 KB
/
sign.js
File metadata and controls
95 lines (82 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
(function ($) {
AblePlayer.prototype.initSignLanguage = function() {
// Sign language is only currently supported in HTML5 player, not YouTube or Vimeo
if (this.player === 'html5') {
// check to see if there's a sign language video accompanying this video
// check only the first source
// If sign language is provided, it must be provided for all sources
this.signFile = this.$sources.first().attr('data-sign-src');
if (this.signFile) {
if (this.isIOS()) {
// IOS does not allow multiple videos to play simultaneously
// Therefore, sign language as rendered by Able Player unfortunately won't work
this.hasSignLanguage = false;
if (this.debug) {
console.log('Sign language has been disabled due to IOS restrictions');
}
}
else {
if (this.debug) {
console.log('This video has an accompanying sign language video: ' + this.signFile);
}
this.hasSignLanguage = true;
this.injectSignPlayerCode();
}
}
else {
this.hasSignLanguage = false;
}
}
else {
this.hasSignLanguage = false;
}
};
AblePlayer.prototype.injectSignPlayerCode = function() {
// create and inject surrounding HTML structure
var thisObj, signVideoId, signVideoWidth, i, signSrc, srcType, $signSource;
thisObj = this;
signVideoWidth = this.getDefaultWidth('sign');
signVideoId = this.mediaId + '-sign';
this.$signVideo = $('<video>',{
'id' : signVideoId,
'tabindex' : '-1'
});
this.signVideo = this.$signVideo[0];
// for each original <source>, add a <source> to the sign <video>
for (i=0; i < this.$sources.length; i++) {
signSrc = this.$sources[i].getAttribute('data-sign-src');
srcType = this.$sources[i].getAttribute('type');
if (signSrc) {
$signSource = $('<source>',{
'src' : signSrc,
'type' : srcType
});
this.$signVideo.append($signSource);
}
else {
// source is missing a sign language version
// can't include sign language
this.hasSignLanguage = false;
break;
}
}
this.$signWindow = $('<div>',{
'class' : 'able-sign-window',
'tabindex': '-1'
});
this.$signToolbar = $('<div>',{
'class': 'able-window-toolbar able-' + this.toolbarIconColor + '-controls'
});
this.$signWindow.append(this.$signToolbar, this.$signVideo);
this.$ableWrapper.append(this.$signWindow);
// make it draggable
this.initDragDrop('sign');
if (this.prefSign === 1) {
// sign window is on. Go ahead and position it and show it
this.positionDraggableWindow('sign',this.getDefaultWidth('sign'));
}
else {
this.$signWindow.hide();
}
};
})(jQuery);