jfversluis / Plugin.Maui.Audio

Plugin.Maui.Audio provides the ability to play audio inside a .NET MAUI application
MIT License
254 stars 42 forks source link

Enable playing audio from a URL #13

Open jfversluis opened 2 years ago

Mephisztoe commented 2 years ago

Just a couple of notes regarding this request.

  1. AVAudioPlayer on iOS does not support streaming audio. So that the library can stream audio from a URL, AVAudioPlayer needs to be replaced by AVPlayer.
  2. AVPlayer does not natively support a couple of properties needed by IAudioPlayer (such as Panning, Positioning, Seeking and Looping). Other means need to be found to implement these.
  3. So that background streaming works on iOS, Background Modes need to be enabled for Audio and the MauiAppBuilder needs to catch the iOS FinishedLaunching LifeCycle event to configure the AVAudioSession as a Shared Instance for playback.
  4. The concrete player classes need to be refactored, because currently, they allow streams (files) and filenames (as strings) for construction. However, URLs are basically strings as well. Although you could inject Uris instead, you would need to extract their strings from within the players anyway, because they may have their own Uri implementation. Better is to provide static factory methods for creating AudioPlayer instances based on either filestreams, filenames or URLs.
Mephisztoe commented 1 year ago

Here's something, I stumbled across lately: When using Android.Media.MediaPlayer natively and implementing a streaming feature using the approach presented in this repo, you might run into issues with (un-) supported content provider. In other words: AAC+ (aacp) might not be supported. I am currently in the process of building an online radio player app. The radio station offers different stream qualities such as 128kbps and 64kbps via Mpeg Layer 3 and 24kbps via AAC+. Although Googles' documentation claims that MediaPlayer does support AAC+, we are getting "java.io.FileNotFoundException: No content provider" exceptions. Prior to this we used the ExoPlayer library on Android which works flawlessly. Looking at its sources, I can tell that it includes dedicated native AAC+ code.

FarazXTS commented 9 months ago

This fork was created for this: https://github.com/BlueSkyInnovations/Plugin.Maui.StreamingAudio/