How can I get a name of audiostreamplayer file name?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By anutorn

I want something like…

If (this song is playing):
     do something cool

The thing is I don’t know how to check songs name.

I need help.

Thank you

:bust_in_silhouette: Reply From: Zylann

AudioStreamPlayer has a stream property, which contains the currently played audio file: AudioStreamPlayer — Godot Engine (stable) documentation in English

You can check the file name this way:

if stream.resource_path == "res://path/to/your/sound.ogg":

If your script is not directly on the player:

var player = get_node("Path/To/The/PlayerNode")
if == "res://path/to/your/sound.ogg":

Thank you so much!

anutorn | 2020-03-12 00:17