Last active
January 14, 2023 08:12
-
-
Save thatswiftguy/742c1b26e248c7465457df6622dab4d0 to your computer and use it in GitHub Desktop.
This Function will Play the Audio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func startPlaying(url : URL) { | |
let playSession = AVAudioSession.sharedInstance() | |
do { | |
try playSession.overrideOutputAudioPort(AVAudioSession.PortOverride.speaker) | |
} catch { | |
print("Playing failed in Device") | |
} | |
do { | |
audioPlayer = try AVAudioPlayer(contentsOf : url) | |
audioPlayer.prepareToPlay() | |
audioPlayer.play() | |
for i in 0..<recordingsList.count{ | |
if recordingsList[i].fileURL == url{ | |
recordingsList[i].isPlaying = true | |
} | |
} | |
} catch { | |
print("Playing Failed") | |
} | |
} | |
func stopPlaying(url : URL){ | |
audioPlayer.stop() | |
for i in 0..<recordingsList.count { | |
if recordingsList[i].fileURL == url { | |
recordingsList[i].isPlaying = false | |
} | |
} | |
} |
yeah bro, I am were mad to not commit the code.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i can't see the project in github