I'm using SimpleAudioPlayer in a cross-platform (Android, iOS, UWP) Xamarin forms app [https://github.com/immunity-studios/viral-crushers]. Looping (repeating) audio file playback is working in UWP and Android Emulator (with Hyper-V) builds. But after testing on a physical Android phone over USB, the same audio clip does not loop on playback. I haven't tested on iOS yet.
In the Core ("Shared") Visual Studio project, I used a wrapper class to instantiate a SimpleAudioPlayer with the 'Loop' value to 'True'. But when debugging on a connected Pixel-3A Android 10 device using Visual Studio 19, the audio file stops after completing its first playback, instead of repeating.
I'm using SimpleAudioPlayer in the core Xamarin C# Project as below. It's a quick implementation which gives access to music clips from any PageView in the Core project
// Some songs and sounds, loaded statically at compilation time, that can be used globally through the C# project
public class Songs
{
public static AudioClip SONG_LOOP = new AudioClip(loop: true, filepath: "AudioFiles/Song1_Full_Loop.mp3");
}
// Page view which plays a song when button is clicked
public partial class SomePageView {
// Constructor, initializer omitted
void buttonClicked()
{
// Playback should loop on Android, but does not.
SONG_LOOP.Play();
}
}
// AudioClip class wraps SimpleAudioPlayer.and manages file loading.
// TODO On Android 10.0, Pixel 3A, audio does not loop correctly when loop is set to 'true'
public class AudioClip
{
private ISimpleAudioPlayer player;
public AudioClip(string filepath, bool loop = false, double startingVolume = 1.0)
{
// setup SimpleAudioPlayer
player = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
// set properties
SetLoop(loop);
SetVolume(startingVolume);
// Load the audio file as a stream, then load it into the audio player
player.Load(Helpers.ResourceFileHelpers.GetStreamFromFile(filepath));
}
public void Play()
{
player.Play();
}
public void SetVolume(double vol)
{
player.Volume = vol;
}
private void SetLoop(bool loop)
{
player.Loop = loop;
}
// additional methods omitted
}
}
I wasn't able to reproduce this issue testing on a Pixel 2 and a Samsung A71 but the new version (1.5.0) is now using the newer Android 10 SDK so that may fix this issue,
I'm using SimpleAudioPlayer in a cross-platform (Android, iOS, UWP) Xamarin forms app [https://github.com/immunity-studios/viral-crushers]. Looping (repeating) audio file playback is working in UWP and Android Emulator (with Hyper-V) builds. But after testing on a physical Android phone over USB, the same audio clip does not loop on playback. I haven't tested on iOS yet.
In the Core ("Shared") Visual Studio project, I used a wrapper class to instantiate a SimpleAudioPlayer with the 'Loop' value to 'True'. But when debugging on a connected Pixel-3A Android 10 device using Visual Studio 19, the audio file stops after completing its first playback, instead of repeating.
I'm using SimpleAudioPlayer in the core Xamarin C# Project as below. It's a quick implementation which gives access to music clips from any PageView in the Core project