Your iPhone has a built-in sleep timer for media playback that can be used with Apple Music and Shortcuts automation to build the perfect bedtime noise machine. Here's how to set it up.
Apple Music has many curated albums meant to be played at bedtime
If you've ever used third-party apps like Dark Noise or other noise machines, a popular feature is the sleep timer. Users may want to stop streaming media from playing after a specific interval, just like setting a sleep timer for a TV, so it doesn't play infomercials all night.
Anyone who uses ambient noise, music, or ocean sounds to fall asleep may not want those sounds playing all night. You can accomplish this by setting up a sleep timer, but as some may have discovered already, there's no obvious sleep option in Apple Music.
Apple has hidden an option to stop media playback within the Clock app. We've also discovered this ability can be automated using Shortcuts so that you can create automated sleep timers.
How to manually set a sleep timer for Apple Music (and other media on iOS):
Ensure the Timer is set to 'Stop Playing' and your iPhone is the audio source
- Open the Clock App.
- Select "Timer" at the bottom right.
- Set the desired duration.
- Tap the "When timer ends" block.
- Scroll all the way down.
- Select "Stop Playing".
- Tap "Start" to begin the sleep timer.
If performed correctly, any audio playing directly from your iPhone will stop playing at the end of the timer. No alarm will sound, and the user will not have to take action.
We use this for Apple Music in our example, but it works for any media, as long as it is sourced from your device. That means you cannot use this feature for HomePod mini or Apple TV if those devices are playing their own audio.
This gets tricky with AirPlay 2 since source devices can use Handoff to make HomePod into their own audio source. If you want the sleep timer to work, it must be set on the device sourcing the audio. To avoid this issue, use Bluetooth speakers or AirPlay 2 non-HomePod speakers for playing bedtime audio.
If you want to use the HomePod for bedtime audio, the same sleep timer trick can be performed, but it must be done on the device. Simply tell Siri on that HomePod to "set a sleep timer for one hour" to stop audio from playing in an hour.
Automation tools make this all much simpler, and iOS has one built-in that's easy to use called Shortcuts.
Automating sleep sounds using Shortcuts on iOS
We're approaching these examples for setting up a bedtime sound machine, but you can set up shortcuts for sleep-timed music for anything. For instance, you could create a Shortcut that plays music for exactly one hour from your favorite playlist every time it is pressed.
First, you should build a Shortcut with the actions needed to play your desired playlist and set a timer. Then we'll set up the automation using that Shortcut later.
Apple Music sleep timer Shortcut
Use the Apple Music Sleep category to find playlist options for your Shortcut
You can play audio from your iPhone for this automation, but we recommend having at least a cheap Bluetooth speaker or audio system. We've set this automation up using a bedroom Sonos system with AirPlay 2 capabilities.
- Open the Shortcuts app and tap the "+" at the top to get started.
- Name your Shortcut using the text block at the top.
- Search for the term "AirPlay."
- Select the "Change Playback Destination" action and change your device to the desired speaker that isn't a HomePod.
- Search for the "Set Volume" action and choose a desired volume level.
- Search for Apple Music and select the action group.
- Select the "Play Music" action then tap the empty "Music" text box.
- Pick your favorite playlist or search "Sleep" to find curated sleep playlists made in Apple Music.
- We recommend setting the action details to shuffle songs and not repeat tracks.
- Finally, search for "Timer" and add the "Start Timer" action.
- Set the timer to the desired length.
If set up correctly, the shortcut should look like our image above. If you tap the play button on the shortcut, it will perform the steps in order. You can do this manually each day when you're preparing for bed, but Shortcuts lets you take this one step further.
Automating the Sleep Sounds Shortcut
Run your Sleep Sounds Shortcut at your designated Betime each night
This step requires a little more setup but utilizes the built-in systems found across your iPhone for better control. Before creating the automation, you'll need to verify you have a Bedtime in the Health app.
Open the Health app, tap the "Browse" tab, and select "Sleep." Here you can see your sleep schedule and tap "edit" to ensure your Bedtime and Wake Up alarms are correct. Once these are set up, you'll have access to some clever automation tools in Shortcuts.
Here's how to get your Sleep Sounds Shortcut to happen automatically every day at your set Bedtime.
- Tap the "Automation" tab in the Shortcuts app.
- Tap the "+" at the top and select "Create Personal Automation."
- Select "Sleep" then "Bedtime Begins" then "Next."
- Tap "Add Action" then search "Run Shortcut."
- Add your Sleep Sounds Shortcut to the block. If you want lights to turn off or other actions to occur at Bedtime, add those actions now.
- Tap "Next" then toggle off "Ask Before Running" so the automation occurs without user input.
If set up correctly, your iPhone will connect to your desired speaker, set a specified volume, start playing a playlist from Apple Music, then stop an hour later every day at Bedtime. Add any steps you want to create an even more complex Bedtime automation, like changing your Apple Watch face to a custom face for sleep.
Note that you'll need to make sure the timer in the Clock app has "Stop Playing" selected for this to work. The automation doesn't perform this step for you, so if you use the timer on your iPhone during the day, make sure you've set this back.
Be sure to explore the variety of sleep sounds and ambient noise found in Apple Music. We use the curator "Apple Music Sleep" for this automation.