-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaption.as
More file actions
169 lines (161 loc) · 4.52 KB
/
Caption.as
File metadata and controls
169 lines (161 loc) · 4.52 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package {
public class Caption {
public static var ALIGN_LEFT:String = "left";
public static var ALIGN_CENTER:String = "center";
public static var ALIGN_RIGHT:String = "right";
// Location
public static var LOCATION_TOP_LEFT:String = "TL";
public static var LOCATION_TOP_CENTRE:String = "T";
public static var LOCATION_TOP_RIGHT:String = "TR";
public static var LOCATION_MIDDLE_LEFT:String = "L";
public static var LOCATION_MIDDLE_CENTRE:String = "C";
public static var LOCATION_MIDDLE_RIGHT:String = "R";
public static var LOCATION_BOTTOM_LEFT:String = "BL";
public static var LOCATION_BOTTOM_CENTRE:String = "B";
public static var LOCATION_BOTTOM_RIGHT:String = "BR";
private var begin:Number;
private var end:Number;
private var speaker:String;
private var location:String;
private var textAlign:String;
private var text:String;
private var emotions_array:Array;
/*
* Sets location and alignment of captions; sets the begin, end, speaker, text attributes and emotions array.
*
* @param captionparams Object
* @param emotions_array Array
*/
public function Caption(captionParams:Object, emotions_array:Array) {
this.begin = captionParams.begin;
this.end = captionParams.end;
this.speaker = captionParams.speaker;
// Sets location of captions
switch (captionParams.location.toUpperCase ())
{
case LOCATION_TOP_LEFT :
case "7" :
this.location = LOCATION_TOP_LEFT;
break;
case LOCATION_TOP_CENTRE :
case "8" :
this.location = LOCATION_TOP_CENTRE;
break;
case LOCATION_TOP_RIGHT :
case "9" :
this.location = LOCATION_TOP_RIGHT;
break;
case LOCATION_MIDDLE_LEFT :
case "4" :
this.location = LOCATION_MIDDLE_LEFT;
break;
case LOCATION_MIDDLE_CENTRE :
case "5" :
this.location = LOCATION_MIDDLE_CENTRE;
break;
case LOCATION_MIDDLE_RIGHT :
case "6" :
this.location = LOCATION_MIDDLE_RIGHT;
break;
case LOCATION_BOTTOM_LEFT :
case "1" :
this.location = LOCATION_BOTTOM_LEFT;
break;
case LOCATION_BOTTOM_CENTRE :
case "2" :
this.location = LOCATION_BOTTOM_CENTRE;
break;
case LOCATION_BOTTOM_RIGHT :
case "3" :
this.location = LOCATION_BOTTOM_RIGHT;
break;
default :
this.location = LOCATION_BOTTOM_CENTRE;
} // LOCATION SWITCH
// Sets text alignment of captions
switch (captionParams.align.toLowerCase ())
{
case ALIGN_LEFT :
case "0" :
this.textAlign = ALIGN_LEFT;
break;
case ALIGN_RIGHT :
case "2" :
this.textAlign = ALIGN_RIGHT;
break;
case ALIGN_CENTER :
case "1" :
this.textAlign = ALIGN_CENTER;
break;
default :
this.textAlign = ALIGN_CENTER;
} // TEXT ALIGNMENT SWITCH
this.text = captionParams.text;
this.emotions_array = emotions_array;
} // CONSTRUCTOR
//*********************************************
/*
* Returns the begin time of the caption.
* @return begin Number
*/
public function getBegin ():Number {
return this.begin;
}
/*
* Returns the end time of the caption.
* @return end Number
*/
public function getEnd ():Number {
return this.end;
}
/*
* Returns the display duration the caption.
* @return duration Number
*/
public function getDur ():Number {
return this.end - this.begin;
}
/*
* Returns the speaker's name.
* @return speaker String
*/
public function getSpeaker ():String {
return this.speaker;
}
/*
* Returns the location of the caption.
* @return location String
*/
public function getLocation ():String {
return this.location;
}
/*
* Returns the text alignment of the caption.
* @return textAlign String
*/
public function getTextAlign ():String {
return this.textAlign;
}
/*
* Returns the caption text.
* @return text String
*/
public function getText ():String {
return this.text;
}
/*
* Returns a number associated with an emotion
* @return emotions_array[index] Emotion
*/
public function getEmotion (index:Number):Emotion {
return this.emotions_array[index];
}
/*
* Returns length of the caption.
* @return emotions_array.length Number
*/
public function length ():Number {
return this.emotions_array.length;
}
} // CAPTION CLASS
} // PACKAGE