Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | noonewon4 |
using Godot;
using System;
public class exam : AudioStreamPlayer2D
{
private AudioStreamPlayer2D audioStreamPlayer;
private AudioStreamSample audioStreamSample;
public override void _Ready()
{
audioStreamPlayer = GetParent().GetNode< AudioStreamPlayer2D>("AudioStreamPlayer2D");
audioStreamSample = new AudioStreamSample();
audioStreamSample.SetPath("res://PianoSounds/A5.ogg");
audioStreamPlayer.SetStream(audioStreamSample);
audioStreamPlayer.Play();
}
}
I tried this out but doesn’t work
I know it works when click load button in AudioStreamPlayer2D
but i have to load AudioStreamSample from coding
thanks