forked from lopezs/ableplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsign.js
More file actions
89 lines (79 loc) · 2.99 KB
/
sign.js
File metadata and controls
89 lines (79 loc) · 2.99 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
(function ($) {
AblePlayer.prototype.initSignLanguage = function() {
// Sign language is only currently supported in HTML5 player, not fallback or YouTube
// only initialize sign language if user wants it
// since it requires downloading a second video & consumes bandwidth
if (this.player === 'html5' && this.prefSignLanguage) {
// 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.debug) {
console.log('This video has an accompanying sign language video: ' + this.signFile);
}
this.hasSignLanguage = true;
this.injectSignPlayerCode();
}
else {
this.hasSignLanguage = false;
}
}
};
AblePlayer.prototype.injectSignPlayerCode = function() {
// create and inject surrounding HTML structure
// If IOS:
// If video:
// IOS does not support any of the player's functionality
// - everything plays in its own player
// Therefore, AblePlayer is not loaded & all functionality is disabled
// (this all determined. If this is IOS && video, this function is never called)
// If audio:
// HTML cannot be injected as a *parent* of the <audio> element
// It is therefore injected *after* the <audio> element
// This is only a problem in IOS 6 and earlier,
// & is a known bug, fixed in IOS 7
var thisObj, signVideoId, i, signSrc, srcType, $signSource;
thisObj = this;
signVideoId = this.mediaId + '-sign';
this.$signVideo = $('<video>',{
'id' : signVideoId,
'width' : this.playerWidth,
'tabindex' : '-1' // remove from tab order
});
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',
'draggable': 'true',
'tabindex': '-1'
});
this.$signWindow.append(this.$signVideo).hide();
// Place sign window in div.able-column-right
// If div doesn't exist yet, create it
if (this.$ableColumnRight) {
this.$ableColumnRight.append(this.$signWindow);
}
else {
this.splitPlayerIntoColumns('sign');
}
this.initDragDrop(this.$signWindow);
};
})(jQuery);