private void SetPlaybackState(PlaybackState newState) { // If the playback state has not changed, return if (currentPlaybackState == newState) { return; } // Otherwise, make changes to the UI based on the new state switch (newState) { // For the no open file state, disable all playback controls apart from the home button and the // open file button case PlaybackState.NoOpenFile: SetUiStates(true, true, false, false, false, false, false); break; // If the open file button is selected, open the panel with this set of controls visible and disable // the toolbar buttons apart from the home button. Also, disable the playback controls whilst the // panel is open case PlaybackState.OpenFileSelected: SetUiStates(true, false, false, true, true, false, false); if (playbackManager.IsPlaying) { playbackManager.StopPlaying(); } // Remove this line once download is implemented DownloadButton.interactable = false; break; // Downloading file state not implemented case PlaybackState.DownloadingFile: break; // If the user has selected a file to open, disable all UI controls whilst it loads the file info case PlaybackState.OpeningFileInfo: SetUiStates(false, false, false, false, false, false, false); // Indicate to the playback manager that it should begin opening the specified file // and add a event handler to the file info finished loading event playbackManager.OpenFile(currentOpenFileName); // Instantiate a loading bar prefab and get a reference to its manager class GameObject loadingBar = Instantiate(LoadingBar, gameObject.transform) as GameObject; loadingManager = loadingBar.GetComponent <LoadingBarManager>(); // Then, initialise it with 1 data item and the loading file info message before showing // it in the canvas loadingManager.InitialiseLoading(loadingFileInfoMessage, 1); loadingManager.ShowLoading(); // Finally, set the file info ready flag to false fileInfoReady = false; break; // If the file info has been loaded in and chunk data is now being loaded in, disable all UI // controls whilst this happens case PlaybackState.OpeningFileData: SetUiStates(false, false, false, false, false, false, false); // An instance of the loading bar should be available with a reference to its manager // cached, so reinitialise the loading bar with the new chunk queue data loadingManager.InitialiseLoading(loadingChunksMessage, playbackManager.GetChunksToLoadCount()); loadingManager.ShowLoading(); break; // If the user has opened a file and they are playing it or they have paused it, everything will be enabled // apart from the options panel case PlaybackState.PausedFile: SetUiStates(true, true, true, false, false, false, true); if (playbackManager.IsPlaying) { playbackManager.StopPlaying(); } sliderManager.StopPlaying(); break; case PlaybackState.PlayingFile: SetUiStates(true, true, true, false, false, false, true); if (!playbackManager.IsPlaying) { playbackManager.StartPlaying(); } sliderManager.StartPlaying(); break; // If the file is buffering, everything should be disabled to prevent errors from occurring case PlaybackState.BufferingFile: SetUiStates(false, false, false, false, false, false, false); sliderManager.StopPlaying(); // Instantiate a loading bar prefab and get a reference to its manager class GameObject bufferingBar = Instantiate(LoadingBar, gameObject.transform) as GameObject; loadingManager = bufferingBar.GetComponent <LoadingBarManager>(); // Then, initialise it with the chunks to load count from the playback manager and the // buffering messgae before showing it in the canvas loadingManager.InitialiseLoading(bufferingMessage, playbackManager.GetChunksToLoadCount()); loadingManager.ShowLoading(); break; // If the upload file button is selected, open the panel with this set of controls visible and disable // the toolbar buttons apart from the home button. Also, disable the playback controls whilst the // panel is open case PlaybackState.UploadFileSelected: SetUiStates(true, false, false, true, false, true, false); if (playbackManager.IsPlaying) { playbackManager.StopPlaying(); } // Remove this line once upload is implemented UploadRecordingButton.interactable = false; break; // Uploading file state not implemented case PlaybackState.UploadingFile: break; } // Store the new state currentPlaybackState = newState; }