DayZ 1.29
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 = g_Game.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 = g_Game.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);
121 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(UpdateTotalTime);
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
190 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(UpdateCurrentTime, 0, true);
191 }
192
193 protected void OnPlaybackStop()
194 {
195 m_PlayButton.Show(true);
196 m_PauseButton.Show(false);
197
199
200 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(UpdateCurrentTime);
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_MSSTORE
241 path = ".\\video\\";
242 #endif
243 #ifdef PLATFORM_PS4
244 path = "/app0/video/";
245 #endif
246 #ifdef PLATFORM_XBOX
247 path = "G:\\video\\";
248 #endif
249
250 m_VideoWidget.Load(path + videoPath, m_VideoWidget.IsLooping());
251
252 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(UpdateTotalTime, 0, true);
253 }
254
256 {
257 m_VideoWidget.Play();
258 }
259
261 {
262 m_VideoWidget.Pause();
263 }
264
266 {
267 m_VideoWidget.Stop();
268 m_PlayButton.Show(true);
269 m_PauseButton.Show(false);
270 }
271
273 {
274 m_VideoWidget.SetLooping(false);
275 m_OnceButton.Show(false);
276 m_RepeatButton.Show(true);
277 }
278
280 {
281 m_VideoWidget.SetLooping(true);
282 m_RepeatButton.Show(false);
283 m_OnceButton.Show(true);
284 }
285
287 {
288 m_VideoWidget.Unload();
289 }
290}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Определения DayZGame.c:3942
Icon x
Icon y
string path
Определения OptionSelectorMultistate.c:142
Widget m_Root
Определения SizeToChild.c:91
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
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:255
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:279
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:272
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:286
map: item x vector(index, width, height)
Определения EnWidgets.c:657
Определения EnWidgets.c:220
Определения EnWidgets.c:190
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
Определения 3_Game/DayZ/tools/tools.c:8
VideoCallback
Определения EnWidgets.c:531
WorkspaceWidget Widget
Defined in code.