Post

Replies

Boosts

Views

Activity

Reply to Get now playing track Apple Music API
The closest thing to this is by observing the SystemMusicPlayer.shared this class gives you queue and state instance properties . With the currentEntry.item of the queue you can get a Song or MusicVideo ID so you can use that to fetch the right content More about SystemPlayer: https://developer.apple.com/documentation/musickit/systemmusicplayer EDIT: Just noticed this was about the Apple Music API and not MusicKit
Dec ’22
Reply to SwiftUI with RoomPlan ?
You can use a UIViewRepresentable together with a singleton, not sure if this is the best way to do so but it works for me :) here's a quick example: Model (here you setup your RoomCaptureView) final class Model : ObservableObject, RoomCaptureViewDelegate { static var shared = Model() @Published var roomCaptureView : RoomCaptureView var captureSessionConfig : RoomCaptureSession.Configuration init() { roomCaptureView = RoomCaptureView(frame: .zero) captureSessionConfig = RoomCaptureSession.Configuration() } func startSession() { roomCaptureView.captureSession.run(configuration: captureSessionConfig) } func stopSession() { roomCaptureView.captureSession.stop() } func captureView(shouldPresent roomDataForProcessing: CapturedRoomData, error: Error?) -> Bool { return true } // Here you will get the final post-processed results. func captureView(didPresent processedResult: CapturedRoom, error: Error?) { if let error = error { print("Error: \(error)") } } } UIViewRepresentable struct RoomCaptureRep: UIViewRepresentable { func makeUIView(context: Context) -> RoomCaptureView { return Model.shared.roomCaptureView } func updateUIView(_ uiView: RoomCaptureView, context: Context) { } } Usage struct CoolRoomPlanView : View { @StateObject var model = Model.shared var body : some View { ZStack { RoomCaptureRep() Button { model.startSession() } label: { Text( "Start") } } } }
Jun ’22
Reply to Request content in a specific locale?
Hi Joe, Thank you for taking the time to respond. Bundle.main.preferredLocalizations = ["en"] Bundle.main.localizations = ["de", "es", "nl", "pt-PT", "en", "Base"] Bundle.main.developmentLocalization = Optional("en") MusicDataRequest.currentCountryCode = nl This is what I get back from the code snippet above. I used to support more languages but I've removed them. Looking at this response I noticed they were still considered to be active so I investigated it and noticed I still had some localized visuals. After removing them it seems to be fixed :) Maybe it's an idea that MusicKit looks at the Bundle.main.preferredLocalizations instead of the Bundle.main.localizations? Anyway, thank you so much for this pointer :)
May ’22