Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hapticをカスタマイズしてみよう / ZOZO Tech Talk #6 Customiz...

M"e
May 16, 2022

Hapticをカスタマイズしてみよう / ZOZO Tech Talk #6 Customize Haptic

M"e

May 16, 2022
Tweet

More Decks by M"e

Other Decks in Programming

Transcript

  1. © ZOZO, Inc. גࣜձࣾZOZO ZOZOTOWN։ൃຊ෦ ZOZOTOWNΞϓϦ෦ iOSϒϩοΫ ԕ౻ ສཬ Twitter:@re___you

    #ZOZOTOWN iOSΞϓϦ։ൃ୲౰👩💻 #վળ׆ಈ΋ͯ͠·͢🛠 #࠷ۙങͬͯΑ͔ͬͨ΋ͷ͸Apple Watch⌚ 2
  2. © ZOZO, Inc. 5 Apple WatchΛ͚͍ͭͯͨΒHapticͷόϦΤʔγϣϯʹؾ͍ͮͨ ☀ ىচΞϥʔϜ ಓҊ಺ͷࠨӈͷ ਐߦํ޲

    ϚεΫ࣌ͷ iPhoneͷղআ 🔓 ώμϦɾɾɾώμϦɾɾɾώμϦ ϛΪϛΪϛΪϛΪϛΪϛΪ Χνο ͱͱΜɺͱͱΜɺͱͱΜ
  3. © ZOZO, Inc. 8 UIFeedbackGeneratorͱCore Haptics UIFeedbackGenerator Core Haptics •

    iOS 10 ~ • ܾΊΒΕͨHapticύλʔϯͷΈ
 ࠶ੜՄೳ • ZOZOTOWN΋͓ؾʹೖΓͱ͔Ͱ ࢖ͬͯΔ • iOS 13 ~ • HapticύλʔϯΛΧελϚΠζͰ͖Δ
  4. © ZOZO, Inc. Core Hapticsͷ໾ׂ • Haptic ίϯςϯπͷ࡞੒ • CHHapticEvent:

    ৮֮ɺԻ • CHHapticEventParameter: CHHapticEventͷύϥϝʔλʔ • CHHapticPattern: CHHapticEventΛ૊Έ߹Θͤͨ΋ͷ • Hapticͷ࠶ੜ • CHHapticPlayer: CHHapticPatternΛ࠶ੜ • CHHapticEngine: CHHapticPlayerΛ࡞੒ 11
  5. © ZOZO, Inc. 14 Core HapticsͰઃఆͰ͖Δ2छྨͷ৮֮ τϯο ϰΡʔʔʔʔʔʔʔʔ - durationΛઃఆͰ͖Δ

    - duration͕0ͩͱHaptic͕࠶ੜͰ͖ͳ͍ - durationͷઃఆ͸ͳ͍ Designing Audio-Haptic ExperiencesΑΓ
  6. © ZOZO, Inc. 19 Engine४උ class ViewController: UIViewController { //

    ࠶ੜதʹ։์͞Εͳ͍Α͏ʹϝϯόม਺ʹ͢Δ private let engine: CHHapticEngine! override func viewDidLoad() { super.viewDidLoad() // engine͸init΍viewDidLoad()ͳͲͷૣ͍λΠϛϯάͰ࡞੒ engine = try! CHHapticEngine(audioSession: AVAudioSession.sharedInstance()) try! engine.start() } }
  7. © ZOZO, Inc. 20 Hapticίϯςϯπ࡞੒ // Transient Event let transientEvent

    = CHHapticEvent(eventType: .hapticTransient, parameters: [ CHHapticEventParameter(parameterID: .hapticIntensity, value: 0.3), CHHapticEventParameter(parameterID: .hapticSharpness, value: 0.3)], relativeTime: 0.2) // Audio Event let audioResourceID = try! engine.registerAudioResource(resourceURL) let audioEvent = CHHapticEvent(audioResourceID: audioResourceID, parameters: [CHHapticEventParameter(parameterID: .audioVolume, value: 0.3)], relativeTime: 0) do { // ΠϕϯτΛ΋ͱʹHapticύλʔϯΛ࡞੒ let pattern = try CHHapticPattern(events: [transientEvent, audioEvent], parameters: []) } catch let error {ɾɾɾ}
  8. © ZOZO, Inc. 21 Haptic࠶ੜ do { let pattern =

    try CHHapticPattern(events: [event, audioEvent], parameters: []) let player = try engine.makePlayer(with: pattern) try player?.start(atTime: CHHapticTimeImmediate) } catch let error {ɾɾɾ}
  9. © ZOZO, Inc. 32 ௐ࿨ੑ ඞཁͳ͜ͱ • ࢹ֮(Ξχϝʔγϣϯ)ɺௌ֮(Ի)ɺ৮֮ΛҰகͤ͞Δ ͳͥඞཁͳͷ͔ •

    ௐ࿨่͕ΕΔͱମݧ͕ଛͳΘΕΔ • ྫ) αοΧʔϘʔϧΛऽΔલʹ৮͕֮ൃੜ͢Δ
  10. © ZOZO, Inc. 45 • ାʹٵ͍ࠐ·ΕΔγϡοͬͯԻ • ϋϯΨʔˠ෰ˠΧʔτ(͔͝?)ɺʹ͋ͨΔͱ͢Ε͹ɺΰοͱ͔ίϯ ʹͳΔ •

    Ϙϑοͯײ͡ • ෍ͷ͜͢ΕΔԻ͔ͳ͋ʮγϡοʯͬͯײ͡ • ෍͕མͪͨԻ͔ͳ • ϙϑͬײʢϘϑΑΓϙϑ೿ʣ • ચ୕ΧΰʹҥྨΛೖΕΔΑ͏ͳʮόαοʯͱ͍͏ײ͡ νʔϜϝϯόʔʹҙݟΛฉ͍ͯΈͨ
  11. © ZOZO, Inc. 46 • ାʹٵ͍ࠐ·ΕΔγϡοͬͯԻ • ϋϯΨʔˠ෰ˠΧʔτ(͔͝?)ɺʹ͋ͨΔͱ͢Ε͹ɺΰοͱ͔ίϯ ʹͳΔ •

    Ϙϑοͯײ͡ • ෍ͷ͜͢ΕΔԻ͔ͳ͋ʮγϡοʯͬͯײ͡ • ෍͕མͪͨԻ͔ͳ • ϙϑͬײʢϘϑΑΓϙϑ೿ʣ • ચ୕ΧΰʹҥྨΛೖΕΔΑ͏ͳʮόαοʯͱ͍͏ײ͡ νʔϜϝϯόʔʹҙݟΛฉ͍ͯΈͨ