Skip to content

Instantly share code, notes, and snippets.

@christianselig
Created February 15, 2024 18:23
Show Gist options
  • Save christianselig/e27953dfd8b448cdd3bea996d0844f4c to your computer and use it in GitHub Desktop.
Save christianselig/e27953dfd8b448cdd3bea996d0844f4c to your computer and use it in GitHub Desktop.
import SwiftUI
import MediaPlayer
struct ContentView: View {
var body: some View {
VStack {
VolumeSlider()
.frame(width: 500.0, height: 50.0)
}
}
}
struct VolumeSlider: UIViewRepresentable {
func makeUIView(context: Context) -> MPVolumeView { .init(frame: CGRect.zero) }
func updateUIView(_ view: MPVolumeView, context: Context) {}
}
#Preview(windowStyle: .automatic) {
ContentView()
}
@kemalenver
Copy link

Cheers Christian, I'm targeting visionOS 2 and it still seems to do the same thing. I've also tried creating my own control and setting the volume with the deprecated volume property on MusicPlayerController and the same thing happens.

@christianselig
Copy link
Author

@kemalenver Ah that's brutal, yeah looks like Apple didn't get around to fixing this one then unfortunately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment