void Update() { if (currentOpenFileName != null && currentPlaybackState == PlaybackState.NoOpenFile) { // Change the state to indicate that the file is opening SetPlaybackState(PlaybackState.OpeningFileInfo); } else if (currentPlaybackState == PlaybackState.OpeningFileInfo && fileInfoReady) { // If the file info is ready but the state has not transitioned, perform // the state change loadingManager.Progress(); SetPlaybackState(PlaybackState.OpeningFileData); } else if (currentPlaybackState == PlaybackState.OpeningFileData) { // If the playback manager is still loading the initial chunks, check // if the loading bar can be updated if (playbackManager.IsLoading) { int lastRemainingItems = loadingManager.RemainingDataItems; int actualRemainingItems = playbackManager.GetChunksToLoadCount(); // If the number of items in the processing queue has changed, update the // loading bar progress if (lastRemainingItems != actualRemainingItems) { // Update its progress by the difference between the remaining item values for (int i = 0; i < (lastRemainingItems - actualRemainingItems); i++) { loadingManager.Progress(); } } } else { // Call the method to show and initialise the mesh kinectMesh.ShowAndInitialiseMesh(); // Destroy and dereference the loading bar if it exists if (loadingManager != null) { loadingManager.DestroyLoading(); loadingManager = null; } // Initialise the slider and its timers, then change to the paused state sliderManager.InitialiseSlider(playbackManager.FileInfoOpen.TotalRecordingLength); SetPlaybackState(PlaybackState.PausedFile); } } else if (currentPlaybackState == PlaybackState.PlayingFile) { // If the playback manager has stopped playing because it needs to buffer, reflect this // in the canvas by changing the state if (!playbackManager.IsPlaying) { SetPlaybackState(PlaybackState.BufferingFile); } else if (kinectMesh.LastFrame) { // Else if the kinect mesh has reached its last frame, pause the file to stop playback TogglePlayPause(); } } else if (currentPlaybackState == PlaybackState.BufferingFile) { // If the playback manager is still buffering, check if the loading bar // can be updated if (playbackManager.IsLoading) { int lastRemainingItems = loadingManager.RemainingDataItems; int actualRemainingItems = playbackManager.GetChunksToLoadCount(); // If the number of items in the processing queue has changed, update the // loading bar progress if (lastRemainingItems != actualRemainingItems) { // Update its progress by the difference between the remaining item values for (int i = 0; i < (lastRemainingItems - actualRemainingItems); i++) { loadingManager.Progress(); } } } else { // Otherwise, destroy and dereference the loading bar if it still exists if (loadingManager != null) { loadingManager.DestroyLoading(); loadingManager = null; } // Then, go back to playing the video SetPlaybackState(PlaybackState.PlayingFile); } } }