Closed joereddington closed 6 years ago
This is a sprint designed to get Mrs Landingham to play music at specific time queues. The first thing to do is to get Mrs Landingham to Play sounds at all.
We leaded a few things in the process. Firstly we learned that if the player is given a filepath that isn't valid, then it crashes our app (which at least gives us an
I'm here and this is what I want.
First order of buisness - get it to play a sound when you press a button.
Stackoverflow instantly raises the question - 'how do you store a sound file on the watch...
I've given a random attempt, we'll see how it works (if it fails, I can put something onto stackoverflow)
Hmm. Running on watch, and loading sign. But nothing coming up. Let's have another look.
There's some debug:
2017-09-08 19:03:49.111732+0100 Mrs Landingham WatchKit Extension[516:2501915] [default] -[WKAudioFileAsset _initWithURL:title:albumTitle:artist:]_block_invoke:39: Received title: ring.wav
Let's try it with silent mode off...
Nope...
Trying with absolute path to sound.
I think I NSLog broke therthing...
Okay, since I put in the full path I'm getting it crashing every time. That's unhelpful.
Trying the name 'bing' also broke everything...
So the implication is that this must be correctly identifying the file - if I change the path even slightly it completely breaks.
So the question becomes. Why is it NOT making a noise?
So https://stackoverflow.com/questions/30744166/playing-sound-in-apple-watchkit suggests that I need to do most of the work in the awake section. Let's try that.
I've moved the declaration to be a class variable, and put most of the intialisation code into the awakeWithContext file.
It worked!
Wait, it worked exactly once...Hmmm.
Ah - it works exactly once each time that we go into this interface. Hmmm.
I'm trying a backwards way of doing it in case that helps.
It did and I've committed, it's still only working thought the bluetooth headphones tho..
Some argument in the comments here: https://stackoverflow.com/questions/28980152/play-sound-from-apple-watch-speaker
This is how we do the reminders, by finding out what the time will be in 5:00 and then checking how close we are to the current time...
Here's how you do the sound:
https://stackoverflow.com/a/31768957/170243