public AudioClip ParseAudioFromBytes(byte[] bytes) { AudioClip audioClip = OpenWavParser.ByteArrayToAudioClip(bytes); OnAudioClipParsed(audioClip); return(audioClip); }
public void PlayAudioFromBytes(byte[] bytes) { if (bytes == null || bytes.Length == 0) { Debug.LogWarning("Cannot play audio from null or empty bytes!"); return; } AudioClip audioClip = OpenWavParser.ByteArrayToAudioClip(bytes); if (audioSource != null) { audioSource.clip = audioClip; audioSource.Play(); } }
public void LoadCustomFile() { if (File.Exists(inputFile.text)) { byte[] wavFile = File.ReadAllBytes(inputFile.text); source.clip = OpenWavParser.ByteArrayToAudioClip(wavFile); loadDisplay.text = "Samples: " + source.clip.samples.ToString(); } else { loadDisplay.text = "File not found"; } }
public void LoadDefaultFile() { string filePath = Application.persistentDataPath + "/MyFile.wav"; if (File.Exists(filePath)) { byte[] wavFile = File.ReadAllBytes(filePath); source.clip = OpenWavParser.ByteArrayToAudioClip(wavFile); loadDisplay.text = "Samples: " + source.clip.samples.ToString(); } else { loadDisplay.text = "File not found"; } }
private void PlayAudio() { Text.text = "PLaying"; if (File.Exists(path)) { byte[] wavFile = File.ReadAllBytes(path); ListentoAudio.clip = OpenWavParser.ByteArrayToAudioClip(wavFile); ListentoAudio.Play(); Text.text = "playing over"; } else { Debug.Log("File not found"); Debug.Log(path); Text.text = "File not found"; } // StartCoroutine(AudioPLaying()); }