简体   繁体   English

SwiftUI - watchOS NowPlayingView

[英]SwiftUI - watchOS NowPlayingView

I already created my Apple Watch music app with background sound in SwiftUI.我已经在 SwiftUI 中创建了带有背景声音的 Apple Watch 音乐应用程序。 I want to somehow present NowPlayigView.我想以某种方式呈现NowPlayigView。 The only thing I found on the Apple Developer website about it is in the attached picture.我在 Apple Developer 网站上找到的唯一关于它的信息在附图中。 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 https://developer.apple.com/documentation/watchkit/storyboard_support/adding_a_now_playing_view

Just put就放

NowPlayingView() where you want it. NowPlayingView()在你想要的地方。

Oh and make sure you import WatchKit .哦,确保你import WatchKit

Apple talks about it at about minute 15:40 in Build a workout App for Apple Watch Apple 在为 Apple Watch 构建锻炼应用程序中大约 15:40 分钟谈到了它

@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. @Antoni277 我相信您还必须提供有关您的应用正在播放的内容的元数据,以便它在任何“正在播放”屏幕中显示。 For instance your code will have to provide a instance of MPNowPlayingInfoCenter.例如,您的代码必须提供 MPNowPlayingInfoCenter 的实例。

Have a look at the documentation at Becoming a Now Playable App查看Becoming a Now Playable App中的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM