Flutter Audio Player (from URL, File, Assets)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
how to play music and audio files in flutter simply create an audio player that comes from the audio players package next creates three fields to store if the audio is currently playing the duration of the song and the current position of the song inside the build method we create an image a title and a subtitle a slider with the current position below it we create a row with the current position and the total duration of the song optionally display the remaining time of the song and lastly we create the play and pause button if we press on this button then we pause and play the song first of all we play the song from the internet from a url with this we can click on the play button and it already starts playing the song however the ui is not updated for this we go to the init state method and here inside we listen to the player changers to detect if our player is currently playing we also listen to audio duration changes and also save it in our state and finally we listen to the audio position changes and also save it within our state with this if i click on this play button then it is playing the song you see the duration and also the position is already updated and we can also pause the song and play it again however we cannot change the slider therefore let's also go to the slider and then we use the new slider position to change the position of our song and optionally if the audio was paused then you can also resume playing the audio let's also try it out as of now if we click on the play button then we are loading and playing the song from this url however instead of loading the song inside the play button we only want to resume playing the song and within the inner state method we load this audio inside of a separate method by the way if you want to repeat this song when it is completed then set this loop flag after this we load the song using the set url method next to loading a file from the internet you could also load a local file from the phone storage by setting this is local flag to true you could simply pick this file using the file picker package and the third option is to load this audio file from the assets folder again set this is local flag to true and then load this assets file from the assets folder to make this work go to your pop spec ml file and under the flutter tag add the assets folder [Music]
Info
Channel: HeyFlutter․com
Views: 84,259
Rating: undefined out of 5
Keywords: audio, audioplayer, audioplayers, flutter, flutter audio, flutter audio player, flutter audio player example, flutter audio player from assets, flutter audio player from url, flutter audio player local file, flutter audioplayer, flutter audioplayers, flutter audioplayers example, flutter music app, flutter music player, flutter music player github, flutter play audio, local asset, music, play, play audio in flutter, progress, progress bar, slider, songs, spotify
Id: MB3YGQ-O1lk
Channel Id: undefined
Length: 2min 48sec (168 seconds)
Published: Wed Apr 13 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.