// ------------------------------------------------------------------------------------------- // Name : StopAudioRecording // Desc : Instructs the Audio Player to stop playing it's audio. Triggers a manual stop of // the audio player. // -------------------------------------------------------------------------------------------- public override void StopAudioRecording() { InventoryAudioPlayer audioPlayer = InventoryAudioPlayer.instance; if (audioPlayer) { audioPlayer.StopAudio(); } }
// -------------------------------------------------------------------------------------------- // Name : StopAudioListener // Desc : Called by the AudioPlayer when the audio stops // --------------------------------------------------------------------------------------------- protected void StopAudioListener() { InventoryAudioPlayer audioPlayer = InventoryAudioPlayer.instance; if (audioPlayer) { audioPlayer.OnEndAudio.RemoveListener(StopAudioListener); } _activeAudioRecordingIndex = -1; }
// -------------------------------------------------------------------------------------------- // Name : Awake // Desc : Initialize the Audio Player // -------------------------------------------------------------------------------------------- protected void Awake() { // Store singleton instance reference _instance = this; // Store Audio Source component _audioSource = GetComponent <AudioSource>(); // Configure audio source to play even when time is paused if (_audioSource) { _audioSource.ignoreListenerPause = true; } }
// -------------------------------------------------------------------------------------------- // Name : PlayAudioRecording // Desc : Instructs audio player to play the Audio Log and sets the current active index // -------------------------------------------------------------------------------------------- public override bool PlayAudioRecording(int recordingIndex) { if (recordingIndex < 0 || recordingIndex >= _recordings.Count) { return(false); } InventoryAudioPlayer audioPlayer = InventoryAudioPlayer.instance; if (audioPlayer) { audioPlayer.OnEndAudio.RemoveListener(StopAudioListener); audioPlayer.OnEndAudio.AddListener(StopAudioListener); audioPlayer.PlayAudio(_recordings[recordingIndex]); _activeAudioRecordingIndex = recordingIndex; } return(true); }