In this blog, we are going to learn about the AVFAudio framework in swift. AVFAudio is a framework that helps in play, record, and process audio files in swift. In every other app, we need to audio-video support like watching video and listening to music or audiobook.
Please follow the below steps to integrate the AVFAudio framework into your iOS project.
Step – 1
In this step, Create a project and create three buttons for play, stop and repeat audio player.
Now we will create a player from AVAudioPlayer class and outlet for the play, stop and repeat button and also create a variable for determining the repeat state
1
2
3
4
5
6
varplayer=AVAudioPlayer()
varrepeatAudio=false
@IBOutlet weakvarrepeatBtn:UIButton!
@IBOutlet weakvarplayBtn:UIButton!
@IBOutlet weakvarstopBtn:UIButton!
Step – 4
Now create a function for the tap of the Play Button and also the required URL from the audio file, after that handle the URL and assign delegates for the player.
Be the first to comment.