How to Pause/Resume a dialogue (audio) with player's movement?

I am working on a 2d game, where the player moves left/right through pressing buttons. There is a dialogue(audio file) playing in the background.
What I am trying to achieve is-

  • If the player stops moving/walking- the audio dialogue(AUDIO A) should pause and a new audio (AUDIO B) to play for that period, when player is not moving.
  • once the player starts moving- another audio (AUDIO C) should play once and then AUDIO A can be resumed.

sorry i am just a beginner and have no idea on how to get this thing done. I would really appreciate any help on this.

Thanks

If you look at the documentation for the AudioSource component, there is a “time” properties that gives you the playback time of the current audio’s playing. You could store this in a variable when the player stops moving, do whatever you want, then when you want to resume, simple set the time to your variable value.