Hi there,
just toying around with the WatchOS2 SDK and I'm trying to figure out how to
- directly access the scroll values of the digital crown
- receive touch event infos
- play alert sounds similar to
AudioServicesPlaySystemSound
thanks!
Hi there,
just toying around with the WatchOS2 SDK and I'm trying to figure out how to
AudioServicesPlaySystemSound
thanks!
I've had some success with accessing the crown values by setting up a dummy array of data for it to scroll thorugh in an WKInterfacePicker and then accessing the values through @IBAction func pickerAction(value: Int). The size of the initial array will determine how many steps you get of crown spinning in either direction.
Touch event I don't believe exists, and neither does system sound. The Haptic control WKInterfaceDevice().playHaptic(type: WKHapticType) also plays a sound through the watch speaker alongside the haptic if it's just beeps and things you want rather than your own sounds that might be the way to go.
For playing sounds through a connected bluetooth device, this should work:
if let audioURL = NSBundle.mainBundle().URLForResource("Audio/Beep5", withExtension: "caf") {
let asset = WKAudioFileAsset(URL: audioURL)
let playerItem = WKAudioFilePlayerItem(asset: asset)
let player = WKAudioFilePlayer(playerItem: playerItem)
player.play()
}
About the dummy array + WKInterfacePicker, yeah I also figured that out. Thanks for the info about playing sound via bluetooth that might be interesting.
Did you figure out how to respond to TAP events for the WKInterfacePicker? According to the docs:
"A
WKInterfacePicker
object presents a scrolling list of items for the user to choose from. Items in the picker may consist of text, images, or a combination of the two. The user interacts with a picker by tapping it, using the crown to scroll through items, and tapping again to select an item. A single interface controller may contain multiple pickers, each with its own set of items."