DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
VideoPlayer.c
См. документацию.
1class VideoPlayer extends ScriptedWidgetEventHandler
2{
3 protected Widget m_Root;
4
5 protected ButtonWidget m_PlayButton;
6 protected ButtonWidget m_PauseButton;
7
8 protected ButtonWidget m_StopButton;
9
10 protected ButtonWidget m_OnceButton;
11 protected ButtonWidget m_RepeatButton;
12
13 protected ButtonWidget m_LoadButton;
14 protected GridSpacerWidget m_LoadVideo;
15
16 protected SliderWidget m_Progress;
17
20
21 protected ImageWidget m_Buffering;
22 /*protected*/ VideoWidget m_VideoWidget;
23
24 void VideoPlayer(Widget parent)
25 {
26 m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/video_player.layout", parent);
27 m_Root.SetHandler(this);
28 m_Root.SetSort(333);
29 Init();
30 }
31
33 {
34 }
35
36 void Show(bool show)
37 {
38 m_Root.Show(show);
39 }
40
41 private void Init()
42 {
43 m_PlayButton = ButtonWidget.Cast(m_Root.FindAnyWidget("vp_PlayButton"));
44 m_PauseButton = ButtonWidget.Cast(m_Root.FindAnyWidget("vp_PauseButton"));
45 m_StopButton = ButtonWidget.Cast(m_Root.FindAnyWidget("vp_StopButton"));
46
47 m_OnceButton = ButtonWidget.Cast(m_Root.FindAnyWidget("vp_OnceButton"));
48 m_RepeatButton = ButtonWidget.Cast(m_Root.FindAnyWidget("vp_RepeatButton"));
49
50 m_LoadButton = ButtonWidget.Cast(m_Root.FindAnyWidget("vp_LoadButton"));
51 m_LoadVideo = GridSpacerWidget.Cast(m_Root.FindAnyWidget("vp_LoadVideo"));
52 m_LoadVideo.Show(false);
53
54 m_Progress = SliderWidget.Cast(m_Root.FindAnyWidget("vp_Progress"));
55 m_Progress.SetCurrent(0);
56
57 m_CurrentTime = TextWidget.Cast(m_Root.FindAnyWidget("vp_CurrentTime"));
58 m_TotalTime = TextWidget.Cast(m_Root.FindAnyWidget("vp_TotalTime"));
59
60 m_Buffering = ImageWidget.Cast(m_Root.FindAnyWidget("vp_Buffering"));
61 m_Buffering.Show(false);
62 m_VideoWidget = VideoWidget.Cast(m_Root.FindAnyWidget("vp_Video"));
63
64 m_VideoWidget.SetCallback(VideoCallback.ON_PLAY, OnPlaybackStart);
65 m_VideoWidget.SetCallback(VideoCallback.ON_PAUSE, OnPlaybackStop);
66 m_VideoWidget.SetCallback(VideoCallback.ON_STOP, OnPlaybackStop);
67 m_VideoWidget.SetCallback(VideoCallback.ON_END, OnPlaybackStop);
68 m_VideoWidget.SetCallback(VideoCallback.ON_LOAD, OnPlaybackStop);
69 m_VideoWidget.SetCallback(VideoCallback.ON_SEEK, UpdateCurrentTime);
70 m_VideoWidget.SetCallback(VideoCallback.ON_BUFFERING_START, OnBufferingStart);
71 m_VideoWidget.SetCallback(VideoCallback.ON_BUFFERING_END, OnBufferingEnd);
72 }
73
74 private void InitVideoLoading()
75 {
76 string path = "video\\*";
77
78 string fileName;
79 FileAttr fileAttr;
80
81 FindFileHandle handle = FindFile(path, fileName, fileAttr, FindFileFlags.DIRECTORIES);
82
83 if (fileName != "")
84 {
86 }
87
88 while (FindNextFile(handle, fileName, fileAttr))
89 {
90 CreateVideoLoadingEntry(fileName);
91 }
92
93 CloseFindFile(handle);
94 }
95
96 private void CreateVideoLoadingEntry(string entryName)
97 {
98 Widget entry = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/video_player_entry.layout", m_LoadVideo);
99 ButtonWidget entryButton = ButtonWidget.Cast(entry.GetChildren());
100 entryButton.SetText(entryName);
101 entryButton.SetUserID(333);
102 }
103
104 private void UpdateCurrentTime()
105 {
106 int time = m_VideoWidget.GetTime();
108
109 m_Progress.SetCurrent(time);
110 }
111
112 // This can be an async op
113 private void UpdateTotalTime()
114 {
115 int time = m_VideoWidget.GetTotalTime();
116
117 if (time != 0)
118 {
119 UpdateTime(m_TotalTime, time);
120 m_Progress.SetMinMax(0, time);
122 }
123 }
124
125 private void UpdateTime(TextWidget widget, int time)
126 {
127 FullTimeData timeData = new FullTimeData();
128 TimeConversions.ConvertSecondsToFullTime(time / 1000, timeData);
129 widget.SetText(timeData.FormatedAsTimestamp());
130 }
131
132 override bool OnChange(Widget w, int x, int y, bool finished)
133 {
134 if (w == m_Progress)
135 {
136 m_VideoWidget.SetTime(m_Progress.GetCurrent(), finished);
137 }
138
139 return super.OnChange(w, x, y, finished);
140 }
141
142 override bool OnClick(Widget w, int x, int y, int button)
143 {
144 if (w == m_PlayButton)
145 {
146 PlayVideo();
147 }
148 else if (w == m_PauseButton)
149 {
150 PauseVideo();
151 }
152 else if (w == m_StopButton)
153 {
154 StopVideo();
155 }
156 else if (w == m_OnceButton)
157 {
158 OnceVideo();
159 }
160 else if (w == m_RepeatButton)
161 {
162 RepeatVideo();
163 }
164 else if (w == m_LoadButton)
165 {
167 }
168 else if (w == m_Progress)
169 {
170 Print(x);
171 Print(y);
172 Print(button);
173 }
174 else if (w.GetUserID() == 333)
175 {
176 string name;
177 ButtonWidget.Cast(w).GetText(name);
180 }
181
182 return super.OnClick(w, x, y, button);
183 }
184
185 protected void OnPlaybackStart()
186 {
187 m_PlayButton.Show(false);
188 m_PauseButton.Show(true);
189
191 }
192
193 protected void OnPlaybackStop()
194 {
195 m_PlayButton.Show(true);
196 m_PauseButton.Show(false);
197
199
201 }
202
203 protected void OnBufferingStart()
204 {
205 m_Buffering.Show(true);
206 }
207
208 protected void OnBufferingEnd()
209 {
210 m_Buffering.Show(false);
211 }
212
214 {
215 if (!m_LoadVideo.IsVisible())
216 {
218 }
219 else
220 {
221 Widget child = m_LoadVideo.GetChildren();
222
223 while (child)
224 {
225 Widget c = child;
226 child = child.GetSibling();
227 c.Unlink();
228 }
229 }
230
231 m_LoadVideo.Show(!m_LoadVideo.IsVisible());
232 }
233
234 void LoadVideo(string videoPath)
235 {
236 string path;
237 #ifdef PLATFORM_WINDOWS
238 path = ".\\video\\";
239 #endif
240 #ifdef PLATFORM_PS4
241 path = "/app0/video/";
242 #endif
243 #ifdef PLATFORM_XBOX
244 path = "G:\\video\\";
245 #endif
246
247 m_VideoWidget.Load(path + videoPath, m_VideoWidget.IsLooping());
248
250 }
251
253 {
254 m_VideoWidget.Play();
255 }
256
258 {
259 m_VideoWidget.Pause();
260 }
261
263 {
264 m_VideoWidget.Stop();
265 m_PlayButton.Show(true);
266 m_PauseButton.Show(false);
267 }
268
270 {
271 m_VideoWidget.SetLooping(false);
272 m_OnceButton.Show(false);
273 m_RepeatButton.Show(true);
274 }
275
277 {
278 m_VideoWidget.SetLooping(true);
279 m_RepeatButton.Show(false);
280 m_OnceButton.Show(true);
281 }
282
284 {
285 m_VideoWidget.Unload();
286 }
287}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Icon x
Icon y
string path
Определения OptionSelectorMultistate.c:142
Widget m_Root
Определения SizeToChild.c:91
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native WorkspaceWidget GetWorkspace()
int m_Days int m_Hours int m_Minutes int m_Seconds string FormatedAsTimestamp()
Определения TimeConversions.c:11
struct that keeps Time relevant information for future formatting
Определения TimeConversions.c:5
proto void Remove(func fn)
remove specific call from queue
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
ImageWidget m_Buffering
Определения VideoPlayer.c:21
void Show(bool show)
Определения VideoPlayer.c:36
void OnBufferingEnd()
Определения VideoPlayer.c:208
void VideoPlayer(Widget parent)
Определения VideoPlayer.c:24
void CreateVideoLoadingEntry(string entryName)
Определения VideoPlayer.c:96
VideoWidget m_VideoWidget
Определения MainMenuPromo.c:17
override bool OnChange(Widget w, int x, int y, bool finished)
Определения VideoPlayer.c:132
GridSpacerWidget m_LoadVideo
Определения VideoPlayer.c:14
void UpdateCurrentTime()
Определения VideoPlayer.c:104
void PlayVideo()
Определения VideoPlayer.c:252
Widget m_Root
Определения SizeToChild.c:9
void ~VideoPlayer()
Определения VideoPlayer.c:32
TextWidget m_CurrentTime
Определения VideoPlayer.c:18
void OnPlaybackStop()
Определения VideoPlayer.c:193
ButtonWidget m_PlayButton
Определения VideoPlayer.c:5
void StopVideo()
Определения MainMenuPromo.c:121
void ToggleVideoSelection()
Определения VideoPlayer.c:213
void InitVideoLoading()
Определения VideoPlayer.c:74
void LoadVideo(string videoPath)
Определения VideoPlayer.c:234
TextWidget m_TotalTime
Определения VideoPlayer.c:19
ButtonWidget m_LoadButton
Определения VideoPlayer.c:13
void PauseVideo()
Определения MainMenuPromo.c:126
ButtonWidget m_StopButton
Определения VideoPlayer.c:8
override bool OnClick(Widget w, int x, int y, int button)
Определения VideoPlayer.c:142
void RepeatVideo()
Определения VideoPlayer.c:276
void OnBufferingStart()
Определения VideoPlayer.c:203
void Init()
Определения MainMenuPromo.c:48
void UpdateTotalTime()
Определения VideoPlayer.c:113
ButtonWidget m_PauseButton
Определения VideoPlayer.c:6
void OnceVideo()
Определения VideoPlayer.c:269
SliderWidget m_Progress
Определения VideoPlayer.c:16
void UpdateTime(TextWidget widget, int time)
Определения VideoPlayer.c:125
void OnPlaybackStart()
Определения VideoPlayer.c:185
ButtonWidget m_RepeatButton
Определения VideoPlayer.c:11
ButtonWidget m_OnceButton
Определения VideoPlayer.c:10
void KillVideo()
Определения VideoPlayer.c:283
map: item x vector(index, width, height)
Определения EnWidgets.c:651
Определения EnWidgets.c:220
Определения EnWidgets.c:190
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
proto native void CloseFindFile(FindFileHandle handle)
enum FindFileFlags FindFile(string pattern, out string fileName, out FileAttr fileAttributes, FindFileFlags flags)
FindFileFlags
Определения EnSystem.c:514
proto bool FindNextFile(FindFileHandle handle, out string fileName, out FileAttr fileAttributes)
int[] FindFileHandle
Определения EnSystem.c:503
FileAttr
Определения EnSystem.c:506
const int CALL_CATEGORY_SYSTEM
Определения tools.c:8
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.
VideoCallback
Определения EnWidgets.c:531
proto native void SetText(string text, bool immedUpdate=true)
WorkspaceWidget Widget
Defined in code.