-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVideoCmera+.as
More file actions
184 lines (140 loc) · 4.81 KB
/
VideoCmera+.as
File metadata and controls
184 lines (140 loc) · 4.81 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package
{
import darkBox.DarkBox;
import darkBox.ImageFile;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.StageVideoEvent;
import flash.filesystem.File;
import flash.geom.Rectangle;
import flash.media.StageVideo;
import flash.media.StageVideoAvailability;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.net.dns.AAAARecord;
import flash.utils.ByteArray;
import mx.utils.Base64Decoder;
import mx.utils.Base64Encoder;
import stageManager.StageManager;
import videoPlayer.myVideoPlayer;
import videoShow.VideoClass;
import videoShow.VideoEvents;
public class VideoCmera extends Sprite
{
private var vidFile:File ;
private var videoDisplay:VideoClass ;
private var camMC:MovieClip ;
private var cam2MC:MovieClip ;
private var cam3MC:MovieClip ;
private var sampleBitmap:Bitmap;
private var sv:StageVideo;
public function VideoCmera()
{
super();
StageManager.setUp(stage,0,0,false);
/*var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.client = this;
if(true && StageVideoAvailability.AVAILABLE)
{
sv = stage.stageVideos[0];
sv.addEventListener(StageVideoEvent.RENDER_STATE, onRender);
sv.attachNetStream(ns);
trace('available');
}
else
{
var vid:Video = new Video(1371, 771);
addChild(vid);
vid.attachNetStream(ns);
trace('not');
}
ns.play('vid.mp4');
return ;*/
trace("Version 6");
camMC = Obj.get("cam_mc",this);
cam2MC = Obj.get("cam2_mc",this);
cam3MC = Obj.get("cam3_mc",this);
camMC.addEventListener(MouseEvent.MOUSE_DOWN,onClicked);
cam2MC.addEventListener(MouseEvent.MOUSE_DOWN,onClicked2);
cam3MC.addEventListener(MouseEvent.MOUSE_DOWN,onClicked3);
//stage.addEventListener(MouseEvent.MOUSE_DOWN,saveVideo);
//saveVideo(null);
videoDisplay = new VideoClass(300,300);
this.addChild(videoDisplay);
sampleBitmap = new Bitmap();
this.addChild(sampleBitmap);
sampleBitmap.x = 200;
sampleBitmap.y = 200;
videoDisplay.addEventListener(VideoEvents.VIDEO_LOADED,playVideo);
var vidFile:File = File.applicationDirectory.resolvePath("vid.mp4");
var otherLocation:File = File.documentsDirectory.resolvePath("vid.mp4");
vidFile.copyTo(otherLocation,true);
//var vidFile2:File = new File("cdn.tabnak.ir/files/fa/news/1395/3/18/601986_353.mp4");
//trace("is exist?"+vidFile2.exists);
if(false && otherLocation.exists)
{
videoDisplay.loadThiwVideo(otherLocation.nativePath,true,NaN,NaN,null,false);//"http://cdn.tabnak.ir/files/fa/news/1395/3/18/601986_353.mp4"
}
videoDisplay.loadThiwVideo("http://as8.asset.aparat.com/aparat-video/a_b2cmk88m84j9n2mkn42j32l8092mm7k4lmm306650006-492y__921dc.mp4");
//DarkBox.setUp(new Rectangle(0,0,550,400));
}
private function onRender(e:StageVideoEvent):void
{
sv.viewPort = new Rectangle(0, 0, 1371, 771);
}
protected function onClicked3(event:MouseEvent):void
{
var items:Vector.<ImageFile> = new Vector.<ImageFile>();
items.push(new ImageFile('http://as5.asset.aparat.com/aparat-video/a_35dl23g6mkjjknljno7nkl3lnjj20l3l8l7k67753018-503y__93ba6.mp4','',4,false));
DarkBox.show(items);
}
protected function playVideo(event:Event):void
{
trace("Video ready");
videoDisplay.play();
}
/*protected function saveVideo(event:MouseEvent):void
{
var fileByte:ByteArray = new ByteArray();
var byte:Base64Decoder = new Base64Decoder();
byte.decode(savedVideo);
fileByte = byte.toByteArray() ;
vidFile = File.documentsDirectory.resolvePath('vid.mp4') ;
FileManager.seveFile(vidFile,fileByte,false);
vid = new VideoClass();
this.addChild(vid);
vid.loadThiwVideo(vidFile.url,true);
trace("File saved with lenght of "+fileByte.length);
}*/
protected function onClicked(event:MouseEvent):void
{
Obj.remove(videoDisplay);
videoDisplay = new VideoClass();
this.addChild(videoDisplay);
trace("Open camera");
DeviceImage.getVideoCamera(onVideoReady);
}
protected function onClicked2(event:MouseEvent):void
{
Obj.remove(videoDisplay);
videoDisplay = new VideoClass();
this.addChild(videoDisplay);
DeviceImage.loadVideo(onVideoReady,File.applicationDirectory.resolvePath("vid.mp4"));
}
private function onVideoReady():void
{
trace("Video is ready : ");
var tempFile:File = File.createTempFile() ;
FileManager.seveFile(tempFile,DeviceImage.videoBytes,false);
//sampleBitmap.bitmapData = DeviceImage.imageBitmapData.clone();
videoDisplay.loadThiwVideo(tempFile.url,true);
}
}
}