# iPhone Media Playback When Plugged In

iOS automation project for automatically switching media playback and adjusting volume when iPhone is plugged into power.

## 📸 Documentation

### iOS Automation Setup

![iOS Automation - Run iOS Shortcut to switch media and turn volume up](iOS%20Automation%20-%20Run%20iOS%20Shortcut%20to%20switch%20media%20and%20turn%20volume%20up.PNG)

Configuration for iOS Automation that triggers when device is connected to power.

### iOS Shortcut

![iOS Shortcut - Switch media to bridge and volume to 100](iOS%20Shortcut%20-%20Switch%20media%20to%20bridge%20and%20volume%20to%20100.PNG)

Shortcut configuration that:

- Checks if audio bridge device is available/connected
- Switches media playback to audio bridge (if available)
- Sets volume to 100%

## 🎯 Purpose

Automatically configure iPhone media settings when plugged in for optimal audio playback through external speakers/bridge. Only switches output if the target device is physically connected and available.

## ⚙️ Setup

1. **Create iOS Shortcut:**
   - Open Shortcuts app on iOS
   - Create new shortcut with the following actions:
     1. **Get Available Playback Destinations** (or **Get Audio Output**)
     2. **If** [Playback Destinations] **contains** [Your Audio Bridge Name]
     3. **Set Playback Destination** → Select your audio bridge
     4. **Set Volume** → 100%
     5. **End If**
   - Name it appropriately (e.g., "Media Bridge Setup")

2. **Configure Automation:**
   - Open Settings → Shortcuts → Automation
   - Create new automation with "Charger" trigger
   - Select "Is Connected" condition
   - Add action to run the shortcut created above
   - Disable "Ask Before Running" for automatic execution

## 🔧 Requirements

- iOS device
- Shortcuts app (built-in on iOS)
- Audio bridge/external speaker system

## � Shortcut Logic

```
Get Available Playback Destinations
IF [Playback Destinations] [contains] [Your Audio Bridge]
    Set Playback Destination → [Your Audio Bridge]
    Set Volume → 100%
END IF
```

**Alternative approach using text matching:**

```
Get Audio Output
Get Text from [Audio Output]
IF [Text] [contains] [Bridge Name]
    Set Playback Destination → [Your Audio Bridge]
    Set Volume → 100%
END IF
```

## 📝 Notes

- Automation runs automatically when device is plugged in
- Shortcut checks for device availability before attempting to switch
- Volume is set to maximum (100%) - adjust in shortcut if needed
- If audio bridge is not available/connected, shortcut will do nothing (silent fail)
- Media output device name can be customized in the conditional check
- No error messages or notifications if device unavailable (prevents interruptions)

## 🚀 Future Enhancements

- [ ] Add volume level customization based on time of day
- [ ] Include notification when automation runs successfully
- [ ] Support for different audio devices based on location
- [ ] Add volume fade-in instead of instant 100%
- [x] Check device availability before switching (implemented)
- [ ] Add fallback device if primary bridge unavailable

---

**Status:** ⚙️ In Progress  
**Last Updated:** January 20, 2026
