-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vidik.as
155 lines (153 loc) · 3.77 KB
/
Vidik.as
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
class Vidik extends MovieClip {
//
var back:MovieClip;
var cap:TextField;
var cap1:TextField;
var capColor:Color;
var capColor1:Color;
var captionText:String;
var captionText1:String;
var captionColor:Number;
var captionColor1:Number;
var descriptionText:String;
//
private var controlBar:MovieClip;
//
var videoFile:String;
var previewFile:String;
var videoDuration:Number;
//
var videoMc:Video;
var preview:MovieClip;
var myNc:NetConnection;
var myNs:NetStream;
var firstPlay:Boolean;
var interval:Number;
//
var pointer:Object;
var initWidth:Number;
var initHeight:Number;
var initX:Number;
var initY:Number;
var initBarX:Number;
var initBarY:Number;
//
function Vidik() {
//
myNc = new NetConnection();
myNc.connect(null);
myNs = new NetStream(myNc);
videoMc.smoothing = true;
videoMc.attachVideo(myNs);
firstPlay = true;
//
initWidth = videoMc._width;
initHeight = videoMc._height;
initX = videoMc._x;
initY = videoMc._y;
initBarX = controlBar._x;
initBarY = controlBar._y;
//
}
function init(vf:String, pf:String, dt:String, ct:String, ct1:String, cc:Number, cc1:Number):Void {
videoFile = vf;
previewFile = pf;
descriptionText = dt;
captionText = ct;
captionText1 = ct1;
captionColor = cc;
captionColor1 = cc1;
//
preview.loadMovie(previewFile);
//trace(previewFile);
this.controlBar.description.txt.autoSize = true;
this.controlBar.description.txt.text = descriptionText;
this.controlBar.description.back._height = this.controlBar.description.txt._height+4;
//
//trace(this);
cap1.text = captionText1;
cap.text = captionText;
/*capColor = new Color(this.cap);
if (captionText) {
cap.text = captionText;
if (captionColor) {
capColor.setRGB(captionColor);
}
} else {
cap._visible = false;
back._height -= 14;
}*/
/*capColor1 = new Color(this.cap1);
if (captionText1) {
cap1.text = captionText1;
if (captionColor1) {
capColor1.setRGB(captionColor1);
}
} else {
cap1._visible = false;
back._height -= 14;
}*/
}
function seekVideo(t:Number):Void{
t = t<0?1:t;
t = t>videoDuration?videoDuration-4:t;
myNs.seek(t);
//trace("dsad");
}
function pauseVideo():Void {
if (firstPlay) {
firstPlay = false;
//preview._visible = false;
myNs.play(videoFile);
this.onEnterFrame = function():Void {
this.controlBar.bar.process(myNs.bytesLoaded/myNs.bytesTotal);
if (myNs.bytesLoaded/myNs.bytesTotal == 1) {
this.onEnterFrame = null;
}
};
myNs.mc = this;
myNs.onMetaData = function(infoObject:Object) {
this.mc.videoDuration = infoObject.duration;
this.mc.controlBar.bar.durationTime = infoObject.duration;
this.mc.controlBar.bar.setBar();
};
interval = setInterval(this, "checkTime", 500);
} else {
myNs.pause();
}
}
function checkTime():Void{
this.controlBar.bar.player(myNs.time);
//trace(videoDuration);
}
private function fullScreen(flag:Boolean):Void {
if (flag) {
//videoMc._xscale = 100;
//videoMc._yscale = 100;
pointer = new Object();
pointer.x = videoMc._x;
pointer.y = videoMc._y;
pointer = {x:0, y:0};
Stage.align = "TL";
this.globalToLocal(pointer);
preview._x = videoMc._x=pointer.x;
preview._y = videoMc._y=pointer.y;
preview._width = videoMc._width=Stage.width;
preview._height = videoMc._height=Stage.height;
//videoMc._alpha = 20;
trace(this);
controlBar._x = pointer.x;
controlBar._y = pointer.y+Stage.height-47;
controlBar.resizeBar(true);
} else {
Stage.align = "TL";
preview._width = videoMc._width=initWidth;
preview._height = videoMc._height=initHeight;
preview._x = videoMc._x=initX;
preview._y = videoMc._y=initY;
controlBar._x = initBarX;
controlBar._y = initBarY;
controlBar.resizeBar(false);
}
}
}