How do I make a media player that can be controlled by the system?
Asked on 2024-07-18
1 search
To create a media player that can be controlled by the system, you can leverage the new controls feature introduced in iOS 18. Controls allow you to extend your app's functionality into system spaces such as Control Center, the lock screen, and the action button. Here’s a step-by-step guide based on the session "Extend your app’s controls across the system":
-
Understand Controls: Controls are a new type of widget that focus on actions and succinct information. They can be either buttons or toggles. Buttons perform discrete actions, while toggles change a piece of boolean state (e.g., turning something on or off).
-
Build a Control:
- Define the Control: Use WidgetKit to create your control. You will need to provide a symbol, title, tint, color, and additional content.
- Perform Actions: Use app intents to define the actions your control will perform. For a media player, this could include play, pause, next, and previous actions.
- Maintain State: Ensure your control maintains its state across different devices. You can use the push notification API to handle state changes from different devices.
-
Configure the Control:
- User Configurable: Make your control user configurable if needed. For example, you can allow users to choose which media player action they want the control to perform.
- Sync Across Devices: Use push notifications to sync the state of your control across all devices.
-
Refine Integration: Tailor your control style to the action it performs and ensure it features distinctive symbols. This will help users quickly identify and use the control.
For a detailed walkthrough, you can refer to the session "Extend your app’s controls across the system" at the following timestamps:
- Introduction
- Learn about controls
- Build a control
- Update toggle states
- Make controls configurable
- Add refinements
By following these steps, you can create a media player control that integrates seamlessly with the system, providing users with quick and easy access to media playback functions.

Explore game input in visionOS
Discover how to design and implement great input for your game in visionOS. Learn how system gestures let you provide frictionless ways for players to interact with your games. And explore best practices for supporting custom gestures and game controllers.

Meet the next generation of CarPlay architecture
Dive into the architecture for the next generation of CarPlay. Learn how your vehicle system works with iPhone to create a single cohesive experience that showcases the best of your car and iPhone. Learn how UI is rendered and composited, and explore ways to configure and customize a special experience for each vehicle model. This session is intended for automakers and system developers interested in the next generation of CarPlay.

Extend your app’s controls across the system
Bring your app’s controls to Control Center, the Lock Screen, and beyond. Learn how you can use WidgetKit to extend your app’s controls to the system experience. We’ll cover how you can to build a control, tailor its appearance, and make it configurable.
