Home No sound after returning to my player app
Reply: 1

No sound after returning to my player app

altralaser
1#
altralaser Published in 2018-02-12 15:06:20Z

I built a simple player app by using AVPlayer. By tapping one button the playback starts, by tapping an other button it stops. This works fine so far.
After stopping the playback I press the home button to return to the home screen. I start another player app (f.e. Spotify) and listen to some music there.
Then I return to my own app and tap the play button and - there's suddenly no sound. The mp3 file is playing but I can't hear anything.
Is there a special function to call in viewDidAppear or something like this?

cwilliamsz
2#
cwilliamsz Reply to 2018-02-12 15:54:29Z

try using bellow code

any questions call me back, if it does not work post your player code so I can help you

@IBAction func playButtonAction(_ sender: Any){
    if avAudio != nil {

        if avAudio.isPlaying {
            avAudio.pause()

        } else {
            avAudio.play()
        }

    } else {
        avAudio = try! AVAudioPlayer(contentsOf: song.assetURL!)
        avAudio.delegate = self as AVAudioPlayerDelegate
    }       
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309628 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO