🎶Flutter Music Player🎵
HELLO EVERYONE…… I am here again with new interesting task given by Mr. Vimal Daga sir….
Task 11 🎯
♦️ Team Task ♦️
⚡Description : Till date whatever we have learnt in Flutter ,is need to be implemented in some way integrating other technologies with it
So lets start……..
This project includes following features.
1. App is completely stateful and remembers the moves..
2. It uses mobile database for storing songs…
3. It uses a very basic search engine…
4. It have connectivity with mobile audio system….
5. It uses an API to fetch the songs…
🎼Demo of App :
🎼Introduction
Music is a language of emotions. Music apps have become an apparent hit and need of the times. Users are using different music apps to listen up to their favourite songs to help them relieve stress or in Improving their creative ability.
As an app developer, you must make some apps that you can use in your daily life. So I tried to make a personal music app, hoping that you will also like it. In this blog, I will help you to build your basic music app using flutter.😊😊
🎼Table of content::
🔹Packages used
🔹Setting up the project
🔹Playing music using the internet and assets
🔹Fetching music files from our external storage.
🔹Setting up the audio
🔹Creating a Control panel
🔹GitHub Link
🎼Packages used:
◼We will use flutter_audio_query
to fetch the music form our external storage(eg. mobile phone, memory card, etc).
Link to download this package:
https://pub.dev/packages/flutter_audio_query
◼audio_manager
package provides us various methods and functions to implement functionality in our app such as play, pause, seek, inc. or dec. volume.
Link to download this package:
🎼Setting up the project:
◼import the packages:
import 'package:flutter_audio_query/flutter_audio_query.dart';
import 'package:audio_manager/audio_manager.dart';
◼Modify your AndroidManifest.xml
<application
…
android:usesCleartextTraffic=”true”
…
>
◼Modify your build.gradle
file
defaultConfig {
minSdkVersion 16
}
🎼Playing music using internet and assets
◼Creating an audio manager instance
var audioManagerInstance = AudioManager.instance;
◼Playing music using the start method
AudioManager
provides us start()
method to play the music. It takes a URL, title, description, cover, and auto.
🎼Fetching music files from our external storage:
To fetch the music files form the external storage we will use a FutureBuilder
as FlutterAudioQuery
returns a future
. This class provides us various methods such as getSongs
, getSongsFromArtist
, getSongsFromAlbum
, getSongsFromArtistAlbum
, etc.
To keep the logic simple and sleek we will only use getSongs
method. You can use as many as you want.
◼Song Widget
To play the music from the external memory we require a path of that song. SongInfo
class provides us filePath
property to get the path of the music file.
🎼Setting up the audio:
This is the most important part, because this contolles various events of audio.
◼initializing setup Audio:
void initState() {
super.initState();
setupAudio();
}
🎼Creating a control pannel:
This panel has a playpause
button, previous
button, next
button, and a songProgress Slider
.
◼Song Duration
This function is used to format the duration of the song this is in millisecond format, we will convert it into this format 00:00
.
Here format
is a string 00:00
. _formatDuration
takes the duration of the song. If the duration is null then it returns — : —
otherwise it returns the duration in the given format.
🎼GitHub Link:
I would like to thanks Mr.Vimal Daga Sir & My Team….
Thats all guys….Thanks For Watching!!!