0

I already created my Apple Watch music app with background sound in SwiftUI. I want to somehow present NowPlayigView. The only thing I found on the Apple Developer website about it is in the attached picture. Maybe the solution is very simple, but I can't find it. Please help. Image

https://developer.apple.com/documentation/watchkit/storyboard_support/adding_a_now_playing_view

Antoni277
  • 3
  • 1

2 Answers2

1

Just put

NowPlayingView() where you want it.

Oh and make sure you import WatchKit.

Apple talks about it at about minute 15:40 in Build a workout App for Apple Watch

lorem ipsum
  • 21,175
  • 5
  • 24
  • 48
  • Thanks for the reply. This is my code used to play audio. I can hear music in background. Now playing view is displayed in app but is blank. https://pastebin.com/R8Uazp9B – Antoni277 Jan 20 '22 at 13:47
  • @Antoni277 No way to know with the stuff you have provided. I would say that if you app is blank make sure you are not locking the main thread somehow. Make sure all the work is being done in another thread and you aren't waiting for updates. I don't use audio much but if you post a [Minimal Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) in a question somebody with be able to examine you code for the hold up. – lorem ipsum Jan 20 '22 at 13:56
0

@Antoni277 I believe you also have to provide meta data about what your App is playing for it to show in any Now Playing screen. For instance your code will have to provide a instance of MPNowPlayingInfoCenter.

Have a look at the documentation at Becoming a Now Playable App

Drew Westcott
  • 521
  • 4
  • 13