music_player.gd 285 B

1234567891011121314151617181920212223
  1. class_name MusicPlayer
  2. extends AudioStreamPlayer
  3. func resume() -> void:
  4. if stream_paused:
  5. stream_paused = false
  6. else:
  7. play()
  8. func pause() -> void:
  9. stream_paused = true
  10. func _on_driver_got_in():
  11. print("play")
  12. resume()
  13. func _on_driver_got_out():
  14. print("stop")
  15. pause()