This topic shows best practices for developing audio-aware applications, including things to consider for button design, using playback manager, and managing call control.
Best practices for configuring media buttons for an app
The following table presents the practices recommended when you add and configure media buttons in a Windows Store app.
| Practice | Description |
|---|---|
|
Design your button-press event handlers to respond with the least amount of delay possible. |
This will make sure that the user immediately gets verification of their button input. Long delays in response cause the user to press buttons multiple times, resulting in unexpected app behavior. |
|
Make sure that the media buttons are used in their standard ways. |
This makes sure that the user has a familiar experience with the use of the media buttons. |
|
Make sure that you do not use track and artist name strings that are longer than 127 characters. |
When you configure your app to display track metadata, make sure that the strings that you use to represent track name and artist name have a maximum length of 127 characters. If you use track and artist name strings that are longer than 127 characters, it will result in an error condition. If your app does not handle this error properly, it could cause the app to stop functioning. |
For a tutorial on how to add media buttons and configure them for a Windows Store app, see How to configure keys for media controls.
Best practices for using playback manager in an app
The following table presents the practices recommended for configuring audio/video (AV) streams, and working with playback manager.
| Practice | Description |
|---|---|
|
You must only consider using the msAudioCategory assignment if you need audio to play in the background. |
Audio playback drains the battery, so unless there is a clear need for background audio (media playback designed for longer term listening, for example) do not declare an audio category. Alternatively, you can use the "Other" category. Otherwise, your application will be muted and then suspended. |
|
Use low-latency audio only when it is needed for specific applications that require it (including multi-track recorders and low-latency video capture). |
Low-latency audio is automatically invoked when you select the "Communications" audio category. For any other category, consider leaving low-latency settings at their default (which is OFF). Low-latency buffers use significantly more CPU and battery resources, and are typically reserved for foreground applications on which the user is focused. |
|
You can use ForeGroundOnly media to mute playback of background media. |
If you develop a game that plays its own audio soundtrack while the user is playing the game, then the soundtrack will be muted if the user was already playing an audio track in the background when the game started. If you believe that the game's audio soundtrack is essential for the function of the game, you can choose ForeGroundOnlyMedia as the msAudioCategory for this soundtrack. This mutes the currently playing background audio. SoundEffects that are mixed in with background media will still be heard in either case. ForeGroundOnlyMedia can also be selected for video apps that should stop background media when the video starts, and should not run at all when they are in the background. |
For a tutorial on how to categorize an AV stream, and how to use playback manager in a Windows Store app, see How to categorize an AV stream for audio streaming.
Best practices for managing call control
The following table presents the practices recommended for managing call control on the default Bluetooth communications device.
| Practice | Description |
|---|---|
|
You must make call control functionality predictable for communications applications. |
This ensures that the user has an experience that is familiar and seamless. If your app uses call buttons in an unfamiliar way, make it very obvious to the user. |
|
Track call tokens carefully. Make sure you end the call correctly for the device, and also end the audio/video stream. |
Doing this helps you make sure that when the call is completed, you send an "endcall" notification back to the device, with the appropriate call token. That way the user has an indication from the device that the call has ended. |
For a tutorial on how to manage Bluetooth calls in a Windows Store app, see How to manage calls on the default Bluetooth communications device.
Security considerations
The following articles provide guidance for writing secure C++ code.
Related topics
Build date: 11/29/2012