I am doing an IOS App with web.MAUI and that i want to reproduce mp3 audio from url.
I am doing this with this code…
non-public async void PlayMp3(string fileName)
{
strive
{
if (isPlaying)
{
participant.Pause();
participant.Dispose();
}
AVPlayerItem merchandise = new AVPlayerItem(new NSUrl(fileName));
participant = AVPlayer.FromPlayerItem(merchandise);
participant.Play();
isPlaying = true;
var trackDuration = merchandise.Asset.Period.Seconds;
var trackTitle = Path.GetFileNameWithoutExtension(fileName);
var nowPlayingInfo = new MPNowPlayingInfo()
{
Title = trackTitle,
AlbumTitle = "Album Identify",
Artist = "Take a look at Artist",
PlaybackDuration = trackDuration,
ElapsedPlaybackTime = 0,
PlaybackRate = 1.0
};
MPNowPlayingInfoCenter.DefaultCenter.NowPlaying = nowPlayingInfo;
System.StartTimer(TimeSpan.FromSeconds(1), () =>
{
if (isPlaying)
{
nowPlayingInfo.ElapsedPlaybackTime = participant.CurrentTime.Seconds;
MPNowPlayingInfoCenter.DefaultCenter.NowPlaying = nowPlayingInfo;
}
return isPlaying; // Continua fino alla positive della riproduzione
});
_interfaceController.PushTemplate(CPNowPlayingTemplate.SharedTemplate, true);
}
catch (Exception ex)
{
}
}
The code learn the mp3, begin it and that i can hear it… CPNowPlayingTemplate is exhibiting with out data and progress bar…
Buttons earlier play and subsequent are seen however they do not reply. (however now is not matter)
I want to know why my nowPlayingInfo usually are not exhibiting…
Thanks…