Commit 627a5379d047881bd39cb6adc9904e3d0186da17
1 parent
debee6bb
Exists in
master
and in
3 other branches
Finish Permission Dialog
Showing
4 changed files
with
174 additions
and
47 deletions
Show diff stats
Assets/Scripts/Export Video/ExportVideo.cs
@@ -207,6 +207,7 @@ public class ExportVideo : MonoBehaviour { | @@ -207,6 +207,7 @@ public class ExportVideo : MonoBehaviour { | ||
207 | if (videoRequestRunning) | 207 | if (videoRequestRunning) |
208 | { | 208 | { |
209 | StopCoroutine("requestVideoInfo"); | 209 | StopCoroutine("requestVideoInfo"); |
210 | + StopCoroutine("VideoStatus"); | ||
210 | PlayerLogger.Log("ExportVideo", "OnRequestCancel", "User canceled the request, resetting states to default."); | 211 | PlayerLogger.Log("ExportVideo", "OnRequestCancel", "User canceled the request, resetting states to default."); |
211 | 212 | ||
212 | } else if (videoDownloadRunning) | 213 | } else if (videoDownloadRunning) |
@@ -250,76 +251,174 @@ public class ExportVideo : MonoBehaviour { | @@ -250,76 +251,174 @@ public class ExportVideo : MonoBehaviour { | ||
250 | 251 | ||
251 | private IEnumerator requestVideoInfo() | 252 | private IEnumerator requestVideoInfo() |
252 | { | 253 | { |
253 | - videoRequestRunning = true; | ||
254 | - WWWForm JsonRequest = new WWWForm(); | ||
255 | - JsonRequest.AddField("gloss", gloss); | ||
256 | - WWW videoInfoRequest = new WWW(SERVER_URL, JsonRequest); | 254 | + |
255 | + videoRequestRunning = true; | ||
256 | + WWWForm JsonRequest = new WWWForm(); | ||
257 | + JsonRequest.AddField("gloss", gloss); | ||
258 | + WWW videoInfoRequest = new WWW(SERVER_URL, JsonRequest); | ||
257 | 259 | ||
258 | PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Request for: " + SERVER_URL); | 260 | PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Request for: " + SERVER_URL); |
259 | 261 | ||
260 | yield return WaitForResponse(videoInfoRequest); | 262 | yield return WaitForResponse(videoInfoRequest); |
261 | 263 | ||
262 | - try | ||
263 | - { | ||
264 | - if (!videoInfoRequest.isDone) | 264 | + try |
265 | { | 265 | { |
266 | + if (!videoInfoRequest.isDone) | ||
267 | + { | ||
268 | + | ||
269 | + screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
270 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.CONNECTION_TIMEOUT_FAILURE); | ||
271 | + PlayerLogger.Log("ExportVideo", "requestVideoInfo", "TimeOut"); | ||
272 | + | ||
273 | + } | ||
274 | + else if (videoInfoRequest.error != null) | ||
275 | + { | ||
276 | + | ||
277 | + screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
278 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.INTERNET_CONNECTION_FAILURE); | ||
279 | + PlayerLogger.Log("ExportVideo", "requestVideoInfo", "(WWW) Error: " + videoInfoRequest.error); | ||
280 | + | ||
281 | + } | ||
282 | + else if (videoInfoRequest.responseHeaders.Count == 0) | ||
283 | + { | ||
284 | + screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
285 | + PlayerLogger.Log("ExportVideo", "requestVideoInfo", "(WWW) Unsucessful Answer"); | ||
286 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE); | ||
287 | + | ||
288 | + | ||
289 | + | ||
290 | + } | ||
291 | + else if (!videoInfoRequest.responseHeaders["STATUS"].Contains("200")) | ||
292 | + { | ||
293 | + screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
294 | + PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Unsuccessful answer (" + videoInfoRequest.responseHeaders["STATUS"] + ")."); | ||
295 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE); | ||
296 | + | ||
297 | + | ||
298 | + } | ||
299 | + else if (String.IsNullOrEmpty(videoInfoRequest.text)) | ||
300 | + { | ||
301 | + | ||
302 | + screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
303 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.DEFAULT); | ||
304 | + PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Empty answer."); | ||
305 | + | ||
306 | + } | ||
307 | + else | ||
308 | + { | ||
309 | + PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Answer: " + videoInfoRequest.text); | ||
310 | + | ||
311 | + FileContent fileContent = new FileContent(); | ||
312 | + fileContent = FileContent.CreateFromJSON(videoInfoRequest.text); | ||
313 | + videoId = fileContent.file; | ||
314 | + StartCoroutine("VideoStatus"); | ||
315 | + | ||
316 | + } | ||
266 | 317 | ||
267 | - screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
268 | - GetConnectionStatusError(ExportLayers.ConnectionStatusError.CONNECTION_TIMEOUT_FAILURE); | ||
269 | - PlayerLogger.Log("ExportVideo", "requestVideoInfo", "TimeOut"); | ||
270 | - } | ||
271 | - else if (videoInfoRequest.error != null) | ||
272 | - { | ||
273 | 318 | ||
274 | - screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
275 | - GetConnectionStatusError(ExportLayers.ConnectionStatusError.INTERNET_CONNECTION_FAILURE); | ||
276 | - PlayerLogger.Log("ExportVideo", "requestVideoInfo", "(WWW) Error: " + videoInfoRequest.error); | ||
277 | } | 319 | } |
278 | - else if (videoInfoRequest.responseHeaders.Count == 0) | 320 | + finally |
279 | { | 321 | { |
280 | - screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
281 | - PlayerLogger.Log("ExportVideo", "requestVideoInfo", "(WWW) Unsucessful Answer"); | ||
282 | - GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE); | 322 | + videoRequestRunning = false; |
323 | + | ||
283 | 324 | ||
284 | 325 | ||
285 | } | 326 | } |
286 | - else if (!videoInfoRequest.responseHeaders["STATUS"].Contains("200")) | ||
287 | - { | ||
288 | - screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
289 | - PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Unsuccessful answer (" + videoInfoRequest.responseHeaders["STATUS"] + ")."); | ||
290 | - GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE); | 327 | + |
291 | 328 | ||
329 | + yield break; | ||
330 | + | ||
331 | + } | ||
292 | 332 | ||
293 | - } | ||
294 | - else if (String.IsNullOrEmpty(videoInfoRequest.text)) | ||
295 | - { | 333 | + private IEnumerator VideoStatus() |
334 | + { | ||
335 | + | ||
336 | + WWWForm JsonRequest = new WWWForm(); | ||
337 | + JsonRequest.AddField("id", videoId); | ||
338 | + while (true) | ||
339 | + { | ||
340 | + WWW videoStatusRequest = new WWW(SERVER_URL, JsonRequest); | ||
296 | 341 | ||
297 | - screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
298 | - GetConnectionStatusError(ExportLayers.ConnectionStatusError.DEFAULT); | ||
299 | - PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Empty answer."); | ||
300 | - } | ||
301 | - else | 342 | + |
343 | + yield return WaitForResponse(videoStatusRequest); | ||
344 | + | ||
345 | + try | ||
302 | { | 346 | { |
303 | - PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Answer: " + videoInfoRequest.text); | 347 | + if (!videoStatusRequest.isDone) |
348 | + { | ||
304 | 349 | ||
305 | - FileContent fileContent = new FileContent(); | ||
306 | - fileContent = FileContent.CreateFromJSON(videoInfoRequest.text); | ||
307 | - videoId = fileContent.file; | ||
308 | - videoSize = int.Parse(fileContent.size); | ||
309 | - OnFinishGetVideoInfo(); | 350 | + screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); |
351 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.CONNECTION_TIMEOUT_FAILURE); | ||
352 | + PlayerLogger.Log("ExportVideo", "VideoStatus", "TimeOut"); | ||
353 | + break; | ||
310 | 354 | ||
311 | - yield break; | ||
312 | - } | 355 | + } |
356 | + else if (videoStatusRequest.error != null) | ||
357 | + { | ||
313 | 358 | ||
359 | + screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
360 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.INTERNET_CONNECTION_FAILURE); | ||
361 | + PlayerLogger.Log("ExportVideo", "VideoStatus", "(WWW) Error: " + videoStatusRequest.error); | ||
362 | + break; | ||
314 | 363 | ||
315 | - } | ||
316 | - finally | ||
317 | - { | ||
318 | - videoRequestRunning = false; | 364 | + } |
365 | + else if (videoStatusRequest.responseHeaders.Count == 0) | ||
366 | + { | ||
367 | + screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
368 | + PlayerLogger.Log("ExportVideo", "VideoStatus", "(WWW) Unsucessful Answer"); | ||
369 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE); | ||
370 | + break; | ||
319 | 371 | ||
320 | 372 | ||
321 | 373 | ||
322 | - } | 374 | + } |
375 | + else if (!videoStatusRequest.responseHeaders["STATUS"].Contains("200")) | ||
376 | + { | ||
377 | + screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
378 | + PlayerLogger.Log("ExportVideo", "VideoStatus", "Unsuccessful answer (" + videoStatusRequest.responseHeaders["STATUS"] + ")."); | ||
379 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE); | ||
380 | + break; | ||
381 | + | ||
382 | + } | ||
383 | + else if (String.IsNullOrEmpty(videoStatusRequest.text)) | ||
384 | + { | ||
385 | + | ||
386 | + screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | ||
387 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.DEFAULT); | ||
388 | + PlayerLogger.Log("ExportVideo", "VideoStatus", "Empty answer."); | ||
389 | + break; | ||
390 | + | ||
391 | + } | ||
392 | + else | ||
393 | + { | ||
394 | + PlayerLogger.Log("ExportVideo", "VideoStatus", "Answer: " + videoStatusRequest.text); | ||
395 | + | ||
396 | + | ||
397 | + FileContent fileContent = new FileContent(); | ||
398 | + fileContent = FileContent.CreateFromJSON(videoStatusRequest.text); | ||
399 | + if(fileContent.status == "done") | ||
400 | + { | ||
401 | + videoSize = int.Parse(fileContent.size); | ||
402 | + OnFinishGetVideoInfo(); | ||
403 | + break; | ||
404 | + } | ||
405 | + | ||
406 | + yield return new WaitForSeconds(1f); | ||
407 | + | ||
408 | + | ||
409 | + } | ||
410 | + | ||
411 | + | ||
412 | + } | ||
413 | + finally | ||
414 | + { | ||
415 | + videoRequestRunning = false; | ||
416 | + } | ||
417 | + | ||
418 | + yield break; | ||
419 | + | ||
420 | + | ||
421 | + }// while | ||
323 | } | 422 | } |
324 | 423 | ||
325 | 424 | ||
@@ -395,7 +494,7 @@ public class ExportVideo : MonoBehaviour { | @@ -395,7 +494,7 @@ public class ExportVideo : MonoBehaviour { | ||
395 | 494 | ||
396 | public IEnumerator WaitForResponse(WWW www, Events.RequestSuccess success, Events.RequestError error) | 495 | public IEnumerator WaitForResponse(WWW www, Events.RequestSuccess success, Events.RequestError error) |
397 | { | 496 | { |
398 | - yield return Methods.WaitForResponse(www, 60 * 5f, success, error); | 497 | + yield return Methods.WaitForResponse(www, 15f, success, error); |
399 | 498 | ||
400 | } | 499 | } |
401 | 500 |
Assets/Scripts/Export Video/FileContent.cs
@@ -5,6 +5,7 @@ public class FileContent { | @@ -5,6 +5,7 @@ public class FileContent { | ||
5 | 5 | ||
6 | public string file; | 6 | public string file; |
7 | public string size; | 7 | public string size; |
8 | + public string status; | ||
8 | 9 | ||
9 | 10 | ||
10 | public static FileContent CreateFromJSON(string jsonString) | 11 | public static FileContent CreateFromJSON(string jsonString) |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +fileFormatVersion: 2 | ||
2 | +guid: e0091546b0e8aa84681fc5b2da5de595 | ||
3 | +timeCreated: 1487781948 | ||
4 | +licenseType: Free | ||
5 | +MonoImporter: | ||
6 | + serializedVersion: 2 | ||
7 | + defaultReferences: [] | ||
8 | + executionOrder: 0 | ||
9 | + icon: {instanceID: 0} | ||
10 | + userData: | ||
11 | + assetBundleName: | ||
12 | + assetBundleVariant: |