how to avoid silence while playing audio file in xmarin forms media player

35 Views Asked by At

I want to play an audio file with extention .wav. when I press play I dont hear the sound. How to stop the audio

Code:

 using Plugin.AudioRecorder; // you have to download from nuGetPackage
 using Xamarin.Essentials;

 private AudioPlayer audioPlayer = new AudioPlayer();
  

  public NewEvent()
  {
    InitializeComponent();
    Permissions.CheckStatusAsync<Permissions.Media>();
    audioPlayer.Play("alert.wav");
  }

  private void StopPlay_Clicked(object sender, EventArgs e)
  {
     audioPlayer.Stop();
  }
1

There are 1 best solutions below

0
Marian34 On

The problem is solved. I put audio file to "Assets" folder. And changed Build Action of my audio file in properties to AndroidAsset. Now it works