I created the project for myself to figure out how audio players work in flutter, without any kind of state management solutions or fancy widgets and whatever that make me not understand a project in few hours.
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
Clone repository
git clone https://github.com/hooshyar/flutter_simple_podcast_player.git
and open pubspec.yaml
run
flutter packages get
open lib/config.dart and change "podcastList"
to your list of favorite podcasts
final List<String> podcastList = [
'joerogan',
'the daily',
'chawg',
'1619',
'Ted Radio Hour'
];
run app on a simulator
flutter run
on error do the following setup for each platform
add these for playing audio in the background
<manifest ...>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application ...>
...
<service android:name="com.ryanheise.audioservice.AudioService">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>
<receiver android:name="com.ryanheise.audioservice.MediaButtonReceiver" >
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
</application>
</manifest>
If you wish to connect to non-HTTPS URLS, add the following to your Info.plist
file:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsForMedia</key>
<true/>
</dict>
Insert this in your Info.plist
file for Audio service:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>