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

iOSDC 2017 - Implementing Music Playback on watchOS

nalydadad
September 17, 2017

iOSDC 2017 - Implementing Music Playback on watchOS

nalydadad

September 17, 2017
Tweet

More Decks by nalydadad

Other Decks in Technology

Transcript

  1. Goal To make Apple Watch to play music offline, but

    not only a remote controller of your iPhone.
  2. It is saved in a temporary path !! func session(_

    session: WCSession, didReceive file: WCSessionFile). Saving file
  3. Save it to a proper location. func session(_ session: WCSession,

    didReceive file: WCSessionFile). Saving file
  4. Save it to a proper location. func session(_ session: WCSession,

    didReceive file: WCSessionFile). Saving file 50 MB Each
  5. You should save the files to the “ Shared Group

    Path.” func session(_ session: WCSession, didReceive file: WCSessionFile). Saving file 50 MB Each
  6. You should save the files to the “ Shared Group

    Path.” func session(_ session: WCSession, didReceive file: WCSessionFile). Saving file 50 MB Each Move the files synchronously.
  7. Playing through Speaker AVAudioPlayer WKAudioFilePlayer AVAudioEngine Framework AVFoundation WatchKit AVFoundation

    Version watchOS 3.0+ watchOS 2.0+ watchOS 2.0+ Support [ Bluetooth Headsets ] YES YES YES Support [ Speaker ] NO NO YES
  8. Now Playing Controller AVAudioPlayer WKAudioFilePlayer AVAudioEngine Framework AVFoundation WatchKit AVFoundation

    Version watchOS 3.0+ watchOS 2.0+ watchOS 2.0+ Support [ Bluetooth Headsets ] YES YES YES Support [ Speaker ] NO NO YES Support [ Now Playing ] NO YES NO
  9. Completion Handler AVAudioPlayer WKAudioFilePlayer AVAudioEngine Framework AVFoundation WatchKit AVFoundation Version

    watchOS 3.0+ watchOS 2.0+ watchOS 2.0+ Support [ Bluetooth Headsets ] YES YES YES Support [ Speaker ] NO NO YES Support [ Now Playing ] NO YES NO Completion Handler Delegate NO Callback
  10. Completion Handler AVAudioPlayer WKAudioFilePlayer AVAudioEngine Framework AVFoundation WatchKit AVFoundation Version

    watchOS 3.0+ watchOS 2.0+ watchOS 2.0+ Support [ Bluetooth Headsets ] YES YES YES Support [ Speaker ] NO NO YES Support [ Now Playing ] NO YES NO Completion Handler Delegate NO Callback Make your choice.
  11. Handling Interrupt Phone call Interrupt Bluetooth Headset Pairing Route Change

    AVAudioSessionInterruptionNotification AVAudioSessionRouteChangeNotification
  12. Activate AVAudioSession Start playing Go into background Pause playing …

    … App is still running. Battery Power Consumption
  13. Activate AVAudioSession Start playing Go into background Pause playing …

    … App is still running. Battery Power Consumption When to deactivate AVAudioSession?
  14. Battery Power Consumption If you want to resume in background?

    Pause playing Go into background … Deactivate AVAudioSession App is killed.
  15. Battery Power Consumption Pause playing Go into background Set a

    timer … Deactivate AVAudioSession Invalidate timer Resume playing …