Dart plugin to live stream audio URLs. The package will accept both HTTP and HTTPs URLs for streaming. Specifics will be discussed below for native designs, limitations, and implementations. Any help would be greatly appreciated if possible!
Add the dependency
Import the package into your dart file
Functions and usage
AudioStream stream = new AudioStream("https://your_url_goes_here.com"); stream.start(); stream.pause(); stream.resume(); stream.stop();
The Android MediaPlayer was used for audio streaming over HTTP/HTTPS. Refer to the Android for information about the MediaPlayer. The player uses setAudioAttributes method for setting up the MediaPlayer for API levels over 26. Anything under that API level will use setAudioStreamType method, which was deprecated in API level 26. Due to this adaption, the flutter compiler will give a message that the plugin is using a deprecated method.
Android requires an edit to your android manifest to allow connection to non-HTTP sources, follow this link to edit the manifest for clear text traffic.
The Swift AVPlayer was used for the implementation over HTTP/HTTPS. Refer to the Apple site for information about the AVPlayer. The player was designed in Swift 5 and requires a change in the Info.plist if you need to HTTP stream. According to the Apple article, iOS SDK 4.0+ is required for streaming.
For the clear text traffic, a change will need to be done in XCode on the Runner.xcworkspace file. The NSAppTransportSecurity flag will need to be changed. It is recommended that you add an exception to the site you are streaming, rather than allowing all HTTP traffic. You can follow this StackOverflow link for changing or adding domains for streaming.