I am using this plugin to play my audio streams https://github.com/adrianstevens/Xamarin-Plugins/tree/master/SimpleAudioPlayer in Xamarin. The player works fine when you load the streams individually and play them. What I am trying to do is however to play all the audio files in a Collection sequentially.
The wav files are stored in a byte[] in an ObservableCollection. When I try to do something like this, only the last audio stream in the collection plays.
foreach (var voiceAudio in VoiceAudioCollection)
{
if (voiceAudio.FileBytes != null)
{
using (Stream stream = new MemoryStream(voiceAudio.FileBytes))
{
audioPlayer.Load(stream);
audioPlayer.Play();
}
}
}
Is there a way to combine all the wav stream data in byte[] into one byte[]/stream to play it sequentially? Or is there a better way to play all the streams sequentially? I am open to ideas.
EDIT:
Considered the Xamarin MediaManger plugin, I can't figure out how to play a local file for the life of me.
I am saving the file in the cache directory, as so:
var localPath = Path.Combine(FileSystem.CacheDirectory, "audio");
var file = Path.Combine(localPath, selectedRecord.FileName);
FileInfo f = new FileInfo(file);
and then even checking for the file (it does exist), but the MediaManeger won't play.
Any thoughts? SAP does play the file just fine.
if(File.Exists(file))
await CrossMediaManager.Current.Play(f);
Even tried something like
await CrossMediaManager.Current.Play($"file://" + file);
Also tried passing as a MediaItem
IMediaItem item = new MediaItem()
{
FileName = Path.GetFileName(file),
MediaUri = "file://" + file,
MediaLocation = MediaLocation.FileSystem,
MediaType = MediaType.Audio
};
from Recent Questions - Stack Overflow https://ift.tt/3EfEKyi
https://ift.tt/eA8V8J
No comments:
Post a Comment