How to build a Workout app on WatchOS with audio feedback?

后端 未结 1 1802
Happy的楠姐
Happy的楠姐 2021-01-02 22:14

I am building a very simple workout app on WatchOS: One of it functions is to give audio feedback during the training. I am able to play a file when the display is on, but w

1条回答
  •  -上瘾入骨i
    2021-01-02 22:38

    I figured out what I did wrong: For the sound to play with the screen off, it is very important to set the category to AVAudioSessionCategoryPlayback, not ambient.

    So that is all I did to get it working: I changed one word in line 10 of my extensionDelegate.swift:

            try audioSession.setCategory(AVAudioSessionCategoryPlayback, with: .duckOthers)
    

    0 讨论(0)
提交回复
热议问题