| page_type | sample | |||||
|---|---|---|---|---|---|---|
| languages |
|
|||||
| products |
|
|||||
| name | Custom Media Transport Controls | |||||
| urlFragment | CustomMediaTransportControls | |||||
| description | Demonstrates how to derive and style MediaTransportControls in a WinUI 3 app while preserving standard media playback commands. | |||||
| extendedZipContent |
|
This WinUI 3 sample demonstrates how to derive from MediaTransportControls, provide a custom control template, add a new transport command, and retain the standard media playback experience.
- Hosts packaged media in a
MediaPlayerElement. - Derives a custom control from
MediaTransportControls. - Adds an accessible Like video command to the transport bar.
- Raises and handles a custom event from the control template.
- Preserves play, pause, seek, playback-rate, aspect-ratio, casting, and full-screen commands.
- Uses a high-contrast-aware custom progress color and keyboard-focusable controls.
- Supports the Visual Studio Package and Unpackaged launch profiles.
- Install the prerequisites described in System requirements for Windows app development.
- Open
cs-winui\CustomMediaTransportControls.slnin Visual Studio 2022. - Select
x86,x64, orARM64and either theDebugorReleaseconfiguration. - Choose the Custom Media Transport Controls (Package) profile for the packaged app, or Custom Media Transport Controls (Unpackaged) for the unpackaged app.
- Build and run the solution.
After launch, use the transport bar to play the bundled video. Select Like video to exercise the custom command, or open the playback-rate menu to change the playback speed.
The sample code and bundled Assets/fishes.wmv media were obtained from the Microsoft Windows-universal-samples repository at commit 4eb2fcb499c5bc549e918920cfd2b64396a650d9. The media originated at:
SharedContent/media/Samples/fishes.wmv
That repository distributes the content under the MIT License. Packaging artwork (SplashScreen.png, Square150x150Logo.png, Square44x44Logo.png, Wide310x150Logo.png, and logo.png) is customized from this repository's WinUI C# sample template. The window icon (windows-sdk.ico) comes directly from that template. All are covered by this repository's MIT license.
