Playing from iOS device to multiple speakers

I wrote an article a few days ago on using AirFoil to do multi room audio like sonos does using hardware you might already have. It was pretty well received, read it here if you missed it.  

However I didn't really explain the trick to playing to multiple speakers from an iOS device. This is totally possible, just requires one extra step. 

You need to install one other application on your Mac (or PC, if that's how you roll). This one's called AirFoil Satellite/Speakers. It's a companion app for AirFoil by the same people. It turns your Mac into an AirPlay speaker. 

This is AirFoil Speakers... they've since rebranded it as AirFoil Satellite, but I paid for the old version, so mine's still called Speakers

This is AirFoil Speakers... they've since rebranded it as AirFoil Satellite, but I paid for the old version, so mine's still called Speakers

 

Install it, and run it.  You'll see AirFoil Satellite show up in in your list of AirPlay speakers, in both your iOS devices and in AirFoil.  You don't want to tell AirFoil to play TO this speaker, you want to choose AirFoil Satellite as the SOURCE.  Once you've done that, select AirFoil Satellite in the AirPlay section of the iOS device you want to play to.  You should hear the music come out of all the speakers you have AirFoil set to play to.  I rename my AirFoil Satellite/Speaker to be called "~Whole House~".  This reminds me NOT to play to from AirFoil and the tilde (~) in the front keeps it at the top of my AirPlay speaker list in my iOS device. 

Click the top of the AirFoil window to select the audio source.  You want to choose AirFoil Satellite (Speakers in my case).  You may have to click "Other Application" and locate it in Finder if it's not in the list.

Click the top of the AirFoil window to select the audio source.  You want to choose AirFoil Satellite (Speakers in my case).  You may have to click "Other Application" and locate it in Finder if it's not in the list.

 

A note about doing this, your iOS device (particularly iPhones, more so than iPads), need to be in good wifi when playing using AirPlay.  You'll get much better results setting it on a table or something than if it's in your pocket.

 

Remotely connecting to your Mac

There are a multitude of ways to connect to your Mac remotely, be it across the room, or across the world. 

However, they’re not all crated equally.

I’ve tested many of them, and one seems clearly better in terms of performance.  Some of the ones I've tried are Log Me In, Google's screen sharing service, UltraVNC, and a few others I've since forgotten.

The best method (strictly in terms of performance) is the built in screen sharing. No extra software to install and configure.  You can connect from any other Mac without any additional software and, as I'll describe below, you can also connect from Windows PCs and iOS devices.  I'm honestly not sure why other services are so popular, since it seems that the best performing one is free and built into the OS. I guess it's just not well known and maybe a little tricky to setup. 

It’s not enabled by default, you need to make a quick change in the sharing section of your system preferences.  

Turn on Screen Sharing in your Mac's System Preferences

Turn on Screen Sharing in your Mac's System Preferences

 

Connecting from another Mac. This is the simplest.  Other mac on your network will appear in the finder sidebar, and you are two clicks and a password away from controlling it.

If you want to do this from outside your network, you need to setup port forwarding on your router. The port in question is tcp port 5900.  If you don’t feel good about opening this to the internet, good for you. You still have options, you could use ssh tunneling or a VPN.  VPN is probably the easiest, and is supported by some routers out of the box. If you're only planning to connect from other Macs, you can enable Back to my Mac in iCloud and in theory, this Mac will then show up in the side bar of any Mac you're using when signed into your iCloud account.  I've had mixed success with this, but using the method below works 100% of the time, and from non-Mac computers.

To connect to a remote Mac that doesn’t just show up in the side bar, you can use the menu option Go / Connect to Server... in the Finder. The address you enter should be in the format vnc://external IP address. If your port forwarding put you on a different port than 5900, specify the new one with the :12345 syntax. You'll probably want to setup a DDNS service to make your computer accessible from anywhere.  That's beyond the scope of this article, but check out your router's configuration and look for DDNS to see which service(s) it supports.  There are lots out there.

You’ll notice that the screen display is quite good, and updates pretty quickly. If you've used VNC on other platforms this might come as a surprise.  It's usually fast or nice looking,but not both. Apple has added some proprietary extensions that adapt to speed, and progressively send more detail do that the screen updates quickly, and static screens look perfect. 

There is a downside though. These extensions are not well supported by third party VNC clients. No big deal if you exclusively connect from other Macs, but from a PC or iOS device, you need a third party client, as Apple doesn't provide one. Most VNC clients work with a Mac, but only at full fidelity, resulting in a sluggish display over all but the fastest networks.   

I've found one welcome exception to this though.

 

Connecting from a PC or iOS Device. The Remotix client, available for iOS and Windows actually supports Apple's proprietary extensions and works just as well as connecting from a Mac.  

You can find out about the iOS version here: https://www.nulana.com/remotix-ios/

You can find out about the Windows version here: https://www.nulana.com/remotix-windows/

They also make a Mac version, although, I don't know why you'd want it for this purpose, as you can already connect natively from a Mac.

As far as I know, there are no Linux or Android clients that work nicely with Apple's proprietary VNC extensions.  You can get by with any VNC client, but the performance will be atrocious.  If you've found one, please leave a comment below, I'd love to know about it.

Updating UI from background threads, simple threading in Swift 3 for iOS

So, you’ve been working on your iOS app, and ran into some issue where the UI was stuttering. You googled it, and after a few minutes on stack overflow, your code is now downloading images for your table view on a background thread.  Now it scrolls buttery smooth.  You worked out the kink where the wrong image ua appearing in the cells, and you think you’re out of the woods.

You move on, but after a while you see some weirdness in your app... Suddenly all animations stop working.

There's a weird warning in the console: 

"This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release."

This sounds ominous, but luckily for you, the fix is easy.

Any code that changes the UI needs to execute in the main thread. 

Even if you’re not explicitly creating a separate thread, there are some functions that will implicitly run code in a closure in a background thread. 

I deal with this with a pair of really simple swift functions that I include in my utility file for all my projects.

UI() and BG() 

func BG(_ block: @escaping ()->Void) {
    DispatchQueue.global(qos: .background).async(execute: block)
}

func UI(_ block: @escaping ()->Void) {
    DispatchQueue.main.async(execute: block)
}

The usage couldn’t be simpler. 

UI() { 
    // everything in here will execute on the main thread
} 

BG() { 
    // everything in here will execute in the background
} 

No need to remember the Grand Central Dispatch functions, and the slightly odd looking functions stick out in your code so you don’t overlook them. 

You need to be a little careful, if you run too much of your code in the UI block, you defeat the purpose of running your code in the background in the first place.

Also, you need to keep in mind that the code in both of these blocks won’t necessarily run in sequence with the surrounding code. It’s likely the line after your block will run before the code in the block executes.  Be careful! 

Eventually, you’ll need to do something fancier with threading, but these two functions account for 99% of my threading needs. Anyone looking at it will know the intent right away too.

Shopping at the wrong store, Frozen edition

Did some more shopping at my favorite knock off store... Not much to say other than enjoy!

 

This isn’t Frozen, I have no idea what you’re talking about

This isn’t Frozen, I have no idea what you’re talking about

The doll looks passable, anyway

The doll looks passable, anyway

It’s not Disney Frozen, it’s Diversity Fashion! 

It’s not Disney Frozen, it’s Diversity Fashion! 

Bold claims from Wonderful World Magic Snow... HAPPY EVERY DAY! 

Bold claims from Wonderful World Magic Snow... HAPPY EVERY DAY! 

Multi room (like Sonos) music on the cheap

Multi room audio is great.  A few years ago, if you hadn’t built your house with speaker wire to every room, you were pretty much out of luck. Running wire after the fact is a nightmare, and the old analog wireless speakers were universally terrible. 

Now days bluetooth has made wireless audio pretty common, but generally limited to playing from one device to one speaker or set of headphones. 

Sonos is a company that has made multi room audio easy to setup and great sounding, but it’s very expensive, and you’re locked into buying from them if you want to expand.

Apple actually has a pretty good solution to this that’s been available for years, but no one seems to know about it. 

It’s AirPlay.   

Every iOS device, the old AirPort routers   and Apple TV supports AirPlay, and apple has licensed the protocol to 3rd parties to implement in their hardware.

These work great out of the box, but they're pretty much limited to one speaker playing back at a time. The only application I’ve seen that will play to multiple speakers simultaneously is iTunes.  

Enter Rogue Amoeba with an app called AirFoil. This $20 program runs on your mac or PC and manages all the air play devices on your network. It allows your mac to play to any combination of speakers and set their volume independently. It even has an EQ if you want more bass or treble in your sound. I don't have any relationship with Rogue Amoeba (I still have to spell check it every time I write it), I'm just a happy customer.

 

The Mac app to control your speakers

The Mac app to control your speakers

Even better, there is an iOS app that lets you control airfoil from your iPhone. Now, wherever you are in the house, you can control the music and volume.  If you want to turn the music on or off on certain rooms, you can do that too. The protocol keeps everything perfectly in sync. You'd be surprised how distracting a slight delay between different speakers can be. 

The iOS app to control your speakers

The iOS app to control your speakers

Aside from just buying AirPlay compatible speakers, any speaker that supports Chrome Cast can be added to your network of speakers. If you have an old iPod dock and an old iPhone, there's an airfoil app that can turn that into a remote speaker too. They have a legacy app that works on phones at least as old as an iPhone 3G. Finally an excuse to dig them out of the drawer they've been collecting dust in. 

I recently added a new room by plugging an old console stereo into an AirPort Express I got used for $20.  The stereo only had a record player and barely functional radio before, now it sounds great.

August Door Lock review, 2 years later

I've now had the August door lock and August Connect for 2 years.  Here are my impressions.

Update: thanks for the feedback reddit, I added a couple screen shots of the August app to clear a couple things up.

I haven’t been too drawn to many of the internet of things devices I’ve seen.  Most of them seem like more work than the non-connected devices that they replace. 

However, the way our house is laid out, we need to unlock our front door, even when coming in from the garage.

When these Bluetooth and wifi door locks first came on the market, there were quite a few options.  The August one stood out for two related reasons, it actually looked quite nice. Other locks were plasticity or had lots of flashing LEDs. Neither of which really worked with our house's esthetic.  We didn’t have to replace the outside lock. This was important again because we have a nice looking front door and the other locks just wouldn’t fit in. 

The installation was a breeze... If you can operate a screwdriver to replace batteries in a toy, you can handle this.

Software is pretty easy to setup too.

So, how was it? Pretty good. But it wasn’t 100% reliable.  More like 90%, which can be really frustrating. When something usually works, it’s all the more frustrating when it doesn’t.  That's not the end of the story though, read on!

One nice thing about software controlled devices is that they don’t necessarily stay the way they are out of the box. August has been really good about updating the lock. Things that didn’t quite work right that I had thought I’d just have to accept as a price for the convenience of having a magical door that unlocked itself were eventually resolved.  The August connect accessory that seemed to need to be restarted once a week to work reliably now seems to never need to be reset. 

After two years, the lock works the way I envisioned, 99.9% of the time, it works.  We don’t even think about it anymore. I don’t carry a house key.  I just expect by the time I get to the front door that it will be unlocked, and... It is.  Always. it’s quick to lock the door from the notification center, and if we forget when leaving the house, we can do it from anywhere using the connect accessory.

The lock installed, looks nice!  You need exactly 1 tool to install it, a screwdriver.

The lock installed, looks nice!  You need exactly 1 tool to install it, a screwdriver.

Here's the connect accessory, it is a wifi bridge that lets you see the status of your lock and lock it and unlock it from anywhere. 

Here's the connect accessory, it is a wifi bridge that lets you see the status of your lock and lock it and unlock it from anywhere. 

The battery life seems to have improved as well. Part of that may have been tweaking the physical installation so that the deadbolt moved more smoothly, but listening to the unit operate, I suspect August has tweaked the way the motor operates as well.

I should also note that it gets really cold here... like -40 cold, and the lock although it gets ice cold to the touch (as do all locks), never skips a beat.

My only two hardware complaints are:

  1. it seems thicker than it should be... honestly, I've pretty much gotten used to it, so it's not that big of a deal now, but I could have sworn it looked thinner in earlier pre-production shots.
  2. the battery cover comes off a little to easily.  Again, we're used to the way it works now.  You turn the outside sleeve to lock/unlock the door, and we grab it there now.  Guests who are unfamiliar with the lock usually grab the whole thing and start turning, popping the battery cover off in the process.

There is an updated version of the lock, that is also HomeKit enabled.  Since I don't have any other home kit devices, this doesn't really seem like a big deal to me. If my August died now, I'd probably replace it with one of those, but this one is working flawlessly.

August has also created a keypad accessory to let you unlock the door with a combination.  I don't know that I really want this now, perhaps when my kids are old enough to be coming and going on their own... although, by then, they'll probably have hand-me-down iPhones and won't need it.

Overall, I'd still strongly recommend the lock.  I'd get the bridge as well.  The peace of mind of knowing the door is really locked is worth it for me, and the couple times I've let people in with it have saved a lot of trouble.  If you are interested, you can purchase through one of the Amazon affiliate links below, and give me a small referral fee (at no cost to you).

Here are a couple screen shots of the app: 

the main screen... Big red button for currently locked, it’s green if currently unlocked

the main screen... Big red button for currently locked, it’s green if currently unlocked

You can set the lock to auto lock after a certain amount of time, in case you forget

You can set the lock to auto lock after a certain amount of time, in case you forget

Mac shortcut to see what channel everyone else is on

I just posted another article on adjusting your WiFi network's channel to avoid microwave interference.

Another source of interference is everybody else's WiFi networks.

If your network problems don't seem to be caused by microwave interference, you might be getting interference from neighbour's networks.  How do you tell?

The same trick we used in the other post.

Hold down alt / option when clicking the wifi strength indicator.  As discussed before, this will show advanced details including the channel your network is operating on.

But... if you hover over any of the other networks listed, you'll also see what channel they are on and their signal strength, even if you don't know the network key and can't use them.

In the example screenshot, you can see the Harry Potter 2 network is on channel 6.  By checking the other (especially strong) networks in your list, you can see the least popular channel, and set your network to that.

Picking a non-crowded channel is a great way to improve the performance of your network.

WiFi and microwaves

Everyone has a wifi network in their house these days, but for most it’s a black box. 

Most wifi access points and routers have literally hundreds of settings that can be tweaked.  

Most of it is inscrutable, even to it professionals. There are a few that are really important though, and don’t require a degree to understand. 

Wifi can operate in two main frequency bands, 2.4 and 5GHz. Most routers use 2.4, as it offers better range, at the expense of less available bandwidth. 

The reason that these bands are available for wifi is because they are unlicensed. Anyone can create a device that operates in this band without asking anyone, as long as they follow some rules about maximum power and so forth. The problem with this, is there are millions of devices competing to use this spectrum. 

In a typical western home, even if you don’t own any other wireless devices, you probably own a microwave. Microwaves heat food with radiation in the same 2.4GHz band. You may have noticed that your WiFi completely stops working or gets erratic when using a microwave.  This is often a problem in office buildings and apartments.

Often when it comes to situations of interference like this, you don't have much chance to fix it.  In this case, there's an easy fix.  Microwave ovens tend to use the higher end of the 2.4GHz band.  Routers will usually let you pick the channel they operate on.  The channel ranges from 1 - 11 in North America.  If microwaves are causing you problems, use channel 1.  Problem solved!  I can't use my wifi at all with the microwave on when on channel 11, but on channel 1, it's rock solid.  I've tested this in many places and with many different microwaves, and this almost always works.

How you set your router's channel depends on your router.  Assuming you know how to get to your router's configuration page, it usually looks something like this:

You can easily check what channel your router is currently on with a Mac.  Hold down the option / alt key and click on the wireless indicator.  You'll see a screen like this.  In my case, I'm on channel 6, and susceptible to microwave interference!

Tags , ,

Quick and dirty script to make Icons for macOS

Sometimes you just need a quick icon for your app.  You don't need anything fancy.  You cobble together something quick, then realize you need to save 10 copies of if and remember the syntax to create a .icns file, or drag each one into Xcode separately.  Or maybe find one of those online services that do it for free but sign you up their mailing list.

If none of that appeals to you, here is a quick (and extremely dirty) bash script that will do it for you in a second or two.  It's dead-simple, no fancy tricks and you should have the requirements pre-installed if you have a Mac and Xcode.  

Drop the code in a .sh file and chmod a+x it... it takes one parameter, the path to a .png file.  It should be at least 1536x1536 and should be square.  No error-checking of any kind is performed.

It uses the following 3 utilities that you probably have installed: 

  • sed for a quick regex
  • sips to do the image resizing
  • iconutil to make the .icns file

I'm sure you can improve on it, but I spent more time writing this post about it than I did writing the script, and it suits me just fine!

Hope it saves you some googling and time on stack overflow ; )

 

 

#!/bin/bash
infile=$(echo "$1" | sed -E 's/\.png//g')
echo "Making icons for $infile"

mkdir icon.iconset

sips $1 -Z 1024 --out icon.iconset/icon_512x512@2x.png
sips $1 -Z 512 --out icon.iconset/icon_512x512.png
sips $1 -Z 512 --out icon.iconset/icon_256x256@2x.png
sips $1 -Z 256 --out icon.iconset/icon_256x256.png
sips $1 -Z 256 --out icon.iconset/icon_128x128@2x.png
sips $1 -Z 128 --out icon.iconset/icon_128x128.png
sips $1 -Z 64 --out icon.iconset/icon_32x32@2x.png
sips $1 -Z 32 --out icon.iconset/icon_32x32.png
sips $1 -Z 32 --out icon.iconset/icon_16x16@2x.png
sips $1 -Z 16 --out icon.iconset/icon_16x16.png

sips $1 -Z 512 --out iTunesArtwork@1x.png
sips $1 -Z 1024 --out iTunesArtwork@2x.png
sips $1 -Z 1536 --out iTunesArtwork@3x.png

iconutil -c icns icon.iconset

Tags ,

Randomizing slide show order in macOS Photos.app

Update March 22, 2017: The slideshow randomizer discussed below is now complete!

Thank you to everyone who helped test it!

 Click here to get it.  The test version mentioned below is no longer available.

 

Original post follows:

The Yosemite version of macOS added the new Photos.app to replace iPhoto.  I think it’s better in most ways, but has one limitation that seems crazy to me. 

You can not display a slide show in random order!  The closest you can do is you use the screen saver as a slide show, but it a) doesn’t include your video clips, and b) for some reason always starts repeating after about 50 pictures or so.

I’ve looked for alternatives, but can’t really find anything that will just play a nice slide show with videos.

That’s the bad news, the good news is: 

I’ve come up with a solution.  I’m looking for testers of a macOS app that will give you a list of your Photos slide shows, and let you randomize the order. 

Send a note to electrollama@gmail.com to get a test version. 

Tags ,

iOS Bug in Weather Widget

I was surprised to see such an obvious bug in the built in weather app in iOS. If the temperature is below 0 degrees C (which is pretty normal here for half the year), the forecast doesn’t show the minus sign. 

These iOS engineers need to get out of California and deal with some cold weather! 

These iOS engineers need to get out of California and deal with some cold weather! 

I think I'm doing my Christmas shopping at the wrong stores

Was out looking for some gag gifts for an office gift exchange and ran across these beauties at my favorite liquidation store.  Some of these are truly inspired knock offs.  I’ve got a bunch of share, but will start with the Star Wars stuff...

Star world...  not terribly original or catchy. And the vehicles don't look anything from the galaxy far far away.  Maybe you'd get lucky though, seeing as though “product may vary from photo and specification on box”.  Compared to other stuff at the store, the English on the box is surprisingly readable. Someone knows how to use a thesaurus... I'd be hard pressed to come up with "inexhaustible fun" to describe these little rover things. 

Star world...  not terribly original or catchy. And the vehicles don't look anything from the galaxy far far away.  Maybe you'd get lucky though, seeing as though “product may vary from photo and specification on box”.  Compared to other stuff at the store, the English on the box is surprisingly readable. Someone knows how to use a thesaurus... I'd be hard pressed to come up with "inexhaustible fun" to describe these little rover things. 

This is some pretty shameless work.  Looks like they didn’t just knock off the logo, but also borrowed some artwork.  If the photo is accurate, they did a better job with the actual model, though.  I guess that’s why you pay $12. 

This is some pretty shameless work.  Looks like they didn’t just knock off the logo, but also borrowed some artwork.  If the photo is accurate, they did a better job with the actual model, though.  I guess that’s why you pay $12. 

Thai is my favorite.  The model looks pretty bad, but the name still makes me chuckle.  What kid wouldn’t want something from Star Wart?  I wonder if the logo creator even knew what they were writing, or if they just wanted something that looked close.

Thai is my favorite.  The model looks pretty bad, but the name still makes me chuckle.  What kid wouldn’t want something from Star Wart?  I wonder if the logo creator even knew what they were writing, or if they just wanted something that looked close.

Tags

Accessing your cameras from anywhere

You have your webcam setup, and you can reach it on your LAN.  You probably access it via a numeric IP address that starts with 192.168.  Setup this way, you can only access your camera when you're connected to your own network.

In order to access your camera from anywhere, you need a DDNS (dynamic DNS) service.  DDNS will take your external IP address from your service provider (something other than a 192.168 address) and translate it to a named address.  Something like myhomecamera.ddns.net.

There are many options for this.  Some router manufacturer's have this built into the router software itself.  Asus is one of these.  Look for DDNS in your router's configuration.  If it's not a simple one-click setup in your hardware, How-to-Geek has a pretty good tutorial on setting it up.

DDNS is only part of the solution.  You also need to make your camera accessible externally.  Again, there are a couple ways to do this.  If you are confident in the security of your camera, you can use port-forwarding, which will route external traffic on a select port to your camera.  

A note about ports.  Web traffic by default uses port 80. You can forward one of your cameras on port 80.  However, if you have more than one camera, you can't have multiple cameras on port 80.  In this case, you can use any other external port and forward it to port 80 internally.  That way, one of your cameras will be reachable at something like myhomecamera.ddns.net:80 and a second camera might be reachable at myhomecamera.net:81.

Some cameras have been shown to have questionable security.  This isn't a problem on your LAN, but you might think twice about making cameras like this available on the internet via port forwarding.  A safer solution is to use a VPN.  This was discussed in yesterday's blog post. Please take a look!

If you're having trouble getting your camera configured to use with eyeCam, feel free to send me a note.  I can help you with your individual setup, point you in the right direction!

 

Tags

Securing your web cam

Web cams have gotten a bad reputation for being insecure.  This reputation is somewhat deserved.  Lots of them included back door accounts that were hardcoded and allowed anyone knowing the password to access any camera.  In fact, you can still find sites online that index insecure cameras, and there are lots of them.

So, should you stop using these old cameras?  You don't want anyone to be able to access your video, and even if you don't care about people seeing your camera's feed, it could eat up your bandwidth.

Luckily there's an easy fix.  Rather than put your camera right on the internet via port forwarding, you can leave port forwarding disabled and use a VPN.  Without port forwarding, normally your camera would only be accessible from within your LAN.  When setting up a VPN, you need an extra layer of security and encryption to access devices on your LAN.

VPN setup can be complicated, but luckily, many modern routers support it out of the box.  iOS devices can connect to many VPN servers without additional software, and one of the most popular VPN types, OpenVPN is accessible from iOS devices using a free app.

How-to-Geek has an excellent article on setting up your own VPN.  If you use web accessible cameras at your home, I'd suggest checking it out!  

 

Tags

eyeCam beta testers

I'm looking for a few more beta testers for the latest version of eyeCam.

This version supports all the cameras of the previous version, plus many more with audio using the new ffmpeg based backed.

If you have any web enabled camera and would like to get a sneak peek at eyeCam and help test, please send me a note at electrollama@gmail.com

Thank you!

Tags