45 lines
1.1 KiB
Swift
45 lines
1.1 KiB
Swift
import AVKit
|
|
import ExpoModulesCore
|
|
|
|
public class AudioOutputModule: Module {
|
|
public func definition() -> ModuleDefinition {
|
|
Name("AudioOutput")
|
|
|
|
View(AudioOutputView.self) {
|
|
Prop("tint") { (view: AudioOutputView, color: UIColor) in
|
|
view.icon.tintColor = color
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
final class AudioOutputView: ExpoView {
|
|
private let picker = AVRoutePickerView()
|
|
let icon = UIImageView(
|
|
image: UIImage(
|
|
systemName: "airplay.audio",
|
|
withConfiguration: UIImage.SymbolConfiguration(pointSize: 27, weight: .semibold)
|
|
)
|
|
)
|
|
|
|
required init(appContext: AppContext? = nil) {
|
|
super.init(appContext: appContext)
|
|
picker.prioritizesVideoDevices = false
|
|
picker.backgroundColor = .clear
|
|
// Hide only the native glyph. Making the picker transparent prevents taps.
|
|
picker.tintColor = .clear
|
|
picker.activeTintColor = .clear
|
|
addSubview(picker)
|
|
icon.contentMode = .center
|
|
icon.isUserInteractionEnabled = false
|
|
icon.isAccessibilityElement = false
|
|
addSubview(icon)
|
|
}
|
|
|
|
override func layoutSubviews() {
|
|
super.layoutSubviews()
|
|
picker.frame = bounds
|
|
icon.frame = bounds
|
|
}
|
|
}
|