Skip to content

Commit b1d5e7a

Browse files
committed
Addressing remaining UWP references
1 parent cb1cac4 commit b1d5e7a

4 files changed

Lines changed: 13 additions & 15 deletions

File tree

hub/apps/develop/media-playback/adaptive-streaming.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ To play adaptive streaming media in a WinUI app, create a **Uri** object pointin
3030

3131
The above example will play the audio of the media content but it doesn't automatically render the content in your UI. Most apps that play video content will want to render the content in a XAML page. To do this, add a [**MediaPlayerElement**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.mediaplayerelement) control to your XAML page.
3232

33-
:::code language="xml" source="~/../snippets-windows/windows-uwp/audio-video-camera/AdaptiveStreaming_RS1/cs/MainPage.xaml" id="SnippetMediaPlayerElementXAML":::
33+
:::code language="xml" source="~/../snippets-windows/winappsdk/audio-video-camera/adaptive-streaming-winui/cs/AdaptiveStreamingWinUI/MainWindow.xaml" id="SnippetMediaPlayerElementXAML":::
3434

3535
Call [**MediaSource.CreateFromUri**](/uwp/api/windows.media.core.mediasource.createfromuri) to create a **MediaSource** from the URI of a DASH or HLS manifest file. Then set the [**Source**](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.mediaplayerelement.source) property of the **MediaPlayerElement**. The **MediaPlayerElement** will automatically create a new **MediaPlayer** object for the content. You can call **Play** on the **MediaPlayer** to start playback of the content.
3636

@@ -96,7 +96,7 @@ The [**MediaBinder**](/uwp/api/Windows.Media.Core.MediaBinder) class allows you
9696

9797
Create a **MediaBinder** instance, set an app-defined [**Token**](/uwp/api/Windows.Media.Core.MediaBinder.Token) string to identify the content to be bound, and register for the [**Binding**](/uwp/api/Windows.Media.Core.MediaBinder.Binding) event. Create a **MediaSource** from the **Binder** by calling [**MediaSource.CreateFromMediaBinder**](/uwp/api/windows.media.core.mediasource.createfrommediabinder). Then, create a **MediaPlaybackItem** from the **MediaSource** and add it to the playback list.
9898

99-
:::code language="csharp" source="~/../snippets-windows/windows-uwp/audio-video-camera/MediaSource_RS1/cs/MainPage.xaml.cs" id="SnippetInitMediaBinder":::
99+
:::code language="csharp" source="~/../snippets-windows/winappsdk/audio-video-camera/media-source-winui/cs/MediaSourceWinUI/MainWindow.xaml.cs" id="SnippetInitMediaBinder":::
100100

101101
In the **Binding** event handler, use the token string to identify the content to be bound and then create the adaptive media source by calling one of the overloads of **[CreateFromStreamAsync](/uwp/api/windows.media.streaming.adaptive.adaptivemediasource.createfromstreamasync)** or **[CreateFromUriAsync](/uwp/api/windows.media.streaming.adaptive.adaptivemediasource.createfromuriasync)**. Because these are asynchronous methods, you should first call the [**MediaBindingEventArgs.GetDeferral**](/uwp/api/windows.media.core.mediabindingeventargs.GetDeferral) method to instruct the system to wait for your operation to complete before continuing. Set the adaptive media source as the bound content by calling **[SetAdaptiveMediaSource](/uwp/api/windows.media.core.mediabindingeventargs.setadaptivemediasource)**. Finally, call [**Deferral.Complete**](/uwp/api/windows.foundation.deferral.Complete) after your operation is complete to instruct the system to continue.
102102

hub/apps/develop/media-playback/integrate-with-systemmediatransportcontrols.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: This article shows you how to interact with the System Media Transp
44
title: Integrate with the System Media Transport Controls
55
ms.date: 02/08/2017
66
ms.topic: article
7-
keywords: windows 10, uwp
7+
keywords: windows 10, winui
88
ms.localizationpriority: medium
99
---
1010
# Integrate with the System Media Transport Controls
@@ -19,7 +19,7 @@ The System Media Transport Controls enable media application developers integrat
1919
For a complete sample that demonstrates integration with the SMTC, see [System Media Transport Controls sample on github](https://github.com/Microsoft/Windows-universal-samples/tree/dev/Samples/SystemMediaTransportControls).
2020

2121
## Automatic integration with SMTC
22-
Starting with Windows 10, version 1607, UWP apps that use the [**MediaPlayer**](/uwp/api/Windows.Media.Playback.MediaPlayer) class to play media are automatically integrated with the SMTC by default. Simply instantiate a new instance of **MediaPlayer** and assign a [**MediaSource**](/uwp/api/Windows.Media.Core.MediaSource), [**MediaPlaybackItem**](/uwp/api/Windows.Media.Playback.MediaPlaybackItem), or [**MediaPlaybackList**](/uwp/api/Windows.Media.Playback.MediaPlaybackList) to the player's [**Source**](/uwp/api/windows.media.playback.mediaplayer.source) property and the user will see your app name in the SMTC and can play, pause, and move through your playback lists by using the SMTC controls.
22+
Starting with Windows 10, version 1607, apps that use the [**MediaPlayer**](/uwp/api/Windows.Media.Playback.MediaPlayer) class to play media are automatically integrated with the SMTC by default. Simply instantiate a new instance of **MediaPlayer** and assign a [**MediaSource**](/uwp/api/Windows.Media.Core.MediaSource), [**MediaPlaybackItem**](/uwp/api/Windows.Media.Playback.MediaPlaybackItem), or [**MediaPlaybackList**](/uwp/api/Windows.Media.Playback.MediaPlaybackList) to the player's [**Source**](/uwp/api/windows.media.playback.mediaplayer.source) property and the user will see your app name in the SMTC and can play, pause, and move through your playback lists by using the SMTC controls.
2323

2424
Your app can create and use multiple **MediaPlayer** objects at once. For each active **MediaPlayer** instance in your app, a separate tab is created in the SMTC, allowing the user to switch between your active media players and those of other running apps. Whichever media player is currently selected in the SMTC is the one that the controls will affect.
2525

@@ -30,9 +30,9 @@ For more information on working with **MediaSource**, **MediaPlaybackItem**, and
3030
## Add metadata to be displayed by the SMTC
3131
If you want add or modify the metadata that is displayed for your media items in the SMTC, such as a video or song title, you need to update the display properties for the **MediaPlaybackItem** representing your media item. First, get a reference to the [**MediaItemDisplayProperties**](/uwp/api/Windows.Media.Playback.MediaItemDisplayProperties) object by calling [**GetDisplayProperties**](/uwp/api/windows.media.playback.mediaplaybackitem.getdisplayproperties). Next, set the type of media, music or video, for the item with the [**Type**](/uwp/api/windows.media.playback.mediaitemdisplayproperties.type) property. Then you can populate the fields of the [**MusicProperties**](/uwp/api/windows.media.playback.mediaitemdisplayproperties.musicproperties) or [**VideoProperties**](/uwp/api/windows.media.playback.mediaitemdisplayproperties.videoproperties), depending on which media type you specified. Finally, update the metadata for the media item by calling [**ApplyDisplayProperties**](/uwp/api/windows.media.playback.mediaplaybackitem.applydisplayproperties).
3232

33-
:::code language="csharp" source="~/../snippets-windows/windows-uwp/audio-video-camera/MediaSource_RS1/cs/MainPage.xaml.cs" id="SnippetSetVideoProperties":::
33+
:::code language="csharp" source="~/../snippets-windows/winappsdk/audio-video-camera/media-source-winui/cs/MediaSourceWinUI/MainWindow.xaml.cs" id="SnippetSetVideoProperties":::
3434

35-
:::code language="csharp" source="~/../snippets-windows/windows-uwp/audio-video-camera/MediaSource_RS1/cs/MainPage.xaml.cs" id="SnippetSetMusicProperties":::
35+
:::code language="csharp" source="~/../snippets-windows/winappsdk/audio-video-camera/media-source-winui/cs/MediaSourceWinUI/MainWindow.xaml.cs" id="SnippetSetMusicProperties":::
3636

3737

3838
> [!Note]
@@ -47,33 +47,33 @@ For every command, such as the *Next* command which by default skips to the next
4747

4848
The following example registers a handler for the **NextReceived** event and for the [**IsEnabledChanged**](/uwp/api/windows.media.playback.mediaplaybackcommandmanagercommandbehavior.isenabledchanged) event of the **NextBehavior**.
4949

50-
:::code language="csharp" source="~/../snippets-windows/windows-uwp/audio-video-camera/SMTC_RS1/cs/MainPage.xaml.cs" id="SnippetAddNextHandler":::
50+
:::code language="csharp" source="~/../snippets-windows/winappsdk/audio-video-camera/smtc-winui/cs/SMTC-WinUI/MainWindow.xaml.cs" id="SnippetAddNextHandler":::
5151

5252
The following example illustrates a scenario where the app wants to disable the *Next* command after the user has clicked through five items in the playlist, perhaps requiring some user interaction before continuing playing content. Each ## the **NextReceived** event is raised, a counter is incremented. Once the counter reaches the target number, the [**EnablingRule**](/uwp/api/windows.media.playback.mediaplaybackcommandmanagercommandbehavior.enablingrule) for the *Next* command is set to [**Never**](/uwp/api/Windows.Media.Playback.MediaCommandEnablingRule), which disables the command.
5353

54-
:::code language="csharp" source="~/../snippets-windows/windows-uwp/audio-video-camera/SMTC_RS1/cs/MainPage.xaml.cs" id="SnippetNextReceived":::
54+
:::code language="csharp" source="~/../snippets-windows/winappsdk/audio-video-camera/smtc-winui/cs/SMTC-WinUI/MainWindow.xaml.cs" id="SnippetNextReceived":::
5555

5656
You can also set the command to **Always**, which means the command will always be enabled even if, for the *Next* command example, there are no more items in the playlist. Or you can set the command to **Auto**, where the system determines whether the command should be enabled based on the current content being played.
5757

5858
For the scenario described above, at some point the app will want to reenable the *Next* command and does so by setting the **EnablingRule** to **Auto**.
5959

60-
:::code language="csharp" source="~/../snippets-windows/windows-uwp/audio-video-camera/SMTC_RS1/cs/MainPage.xaml.cs" id="SnippetEnableNextButton":::
60+
:::code language="csharp" source="~/../snippets-windows/winappsdk/audio-video-camera/smtc-winui/cs/SMTC-WinUI/MainWindow.xaml.cs" id="SnippetEnableNextButton":::
6161

6262
Because your app may have it's own UI for controlling playback while it is in the foreground, you can use the [**IsEnabledChanged**](/uwp/api/windows.media.playback.mediaplaybackcommandmanagercommandbehavior.isenabledchanged) events to update your own UI to match the SMTC as commands are enabled or disabled by accessing the [**IsEnabled**](/uwp/api/windows.media.playback.mediaplaybackcommandmanagercommandbehavior.isenabled) of the [**MediaPlaybackCommandManagerCommandBehavior**](/uwp/api/Windows.Media.Playback.MediaPlaybackCommandManagerCommandBehavior) passed into the handler.
6363

64-
:::code language="csharp" source="~/../snippets-windows/windows-uwp/audio-video-camera/SMTC_RS1/cs/MainPage.xaml.cs" id="SnippetIsEnabledChanged":::
64+
:::code language="csharp" source="~/../snippets-windows/winappsdk/audio-video-camera/smtc-winui/cs/SMTC-WinUI/MainWindow.xaml.cs" id="SnippetIsEnabledChanged":::
6565

6666
In some cases, you may want to completely override the behavior of an SMTC command. The example below illustrates a scenario where an app uses the *Next* and *Previous* commands to switch between internet radio stations instead of skipping between tracks in the current playlist. As in the previous example, a handler is registered for when a command is received, in this case it is the [**PreviousReceived**](/uwp/api/windows.media.playback.mediaplaybackcommandmanager.previousreceived) event.
6767

68-
:::code language="csharp" source="~/../snippets-windows/windows-uwp/audio-video-camera/SMTC_RS1/cs/MainPage.xaml.cs" id="SnippetAddPreviousHandler":::
68+
:::code language="csharp" source="~/../snippets-windows/winappsdk/audio-video-camera/smtc-winui/cs/SMTC-WinUI/MainWindow.xaml.cs" id="SnippetAddPreviousHandler":::
6969

7070
In the **PreviousReceived** handler, first a [**Deferral**](/uwp/api/Windows.Foundation.Deferral) is obtained by calling the [**GetDeferral**](/uwp/api/windows.media.playback.mediaplaybackcommandmanagerpreviousreceivedeventargs.getdeferral) of the [**MediaPlaybackCommandManagerPreviousReceivedEventArgs**](/uwp/api/Windows.Media.Playback.MediaPlaybackCommandManagerPreviousReceivedEventArgs) passed into the handler. This tells the system to wait for until the deferral is complete before executing the command. This is extremely important if you are going to make asynchronous calls in the handler. At this point, the example calls a custom method that returns a **MediaPlaybackItem** representing the previous radio station.
7171

7272
Next, the [**Handled**](/uwp/api/windows.media.playback.mediaplaybackcommandmanagerpreviousreceivedeventargs.handled) property is checked to make sure that the event wasn't already handled by another handler. If not, the **Handled** property is set to true. This lets the SMTC, and any other subscribed handlers, know that they should take no action to execute this command because it has already been handled. The code then sets the new source for the media player and starts the player.
7373

7474
Finally, [**Complete**](/uwp/api/windows.foundation.deferral.complete) is called on the deferral object to let the system know that you are done processing the command.
7575

76-
:::code language="csharp" source="~/../snippets-windows/windows-uwp/audio-video-camera/SMTC_RS1/cs/MainPage.xaml.cs" id="SnippetPreviousReceived":::
76+
:::code language="csharp" source="~/../snippets-windows/winappsdk/audio-video-camera/smtc-winui/cs/SMTC-WinUI/MainWindow.xaml.cs" id="SnippetPreviousReceived":::
7777

7878
## Manual control of the SMTC
7979
As mentioned previously in this article, the SMTC will automatically detect and display information for every instance of **MediaPlayer** that your app creates. If you want to use multiple instances of **MediaPlayer** but want the SMTC to provide a single entry for your app, then you must manually control the behavior of the SMTC instead of relying on automatic integration. Also, if you are using [**MediaTimelineController**](/uwp/api/Windows.Media.MediaTimelineController) to control one or more media players, you must use manual SMTC integration. Also, if your app uses an API other than **MediaPlayer**, such as the [**AudioGraph**](/uwp/api/Windows.Media.Audio.AudioGraph) class, to play media, you must implement manual SMTC integration for the user to use the SMTC to control your app. For information on how to manually control the SMTC, see [Manual control of the System Media Transport Controls](system-media-transport-controls.md).

hub/apps/develop/media-playback/media-playback.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This section provides guidance for creating WinUI 3 apps that play back audio an
2828
| [Enable audio playback from remote Bluetooth-connected devices](enable-remote-audio-playback.md) | Shows you how to use AudioPlaybackConnection to enable Bluetooth-connected remote devices to play back audio on the local machine. |
2929

3030

31-
## UWP app samples for media playback
31+
## App samples for media playback
3232

3333
* [Adaptive streaming sample](https://github.com/Microsoft/Windows-universal-samples/tree/dev/Samples/AdaptiveStreaming)
3434
* [Background Audio sample](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/BackgroundMediaPlayback)

hub/apps/develop/media-playback/system-media-transport-controls.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ In the handler for the event, first make sure that the requested value is within
104104

105105
If you are not using the automatic SMTC integration provided by **MediaPlayer** you must manually integrate with the SMTC to enable background audio. At a minimum, your app must enable the play and pause buttons by setting [**IsPlayEnabled**](/uwp/api/windows.media.systemmediatransportcontrols.isplayenabled) and [**IsPauseEnabled**](/uwp/api/windows.media.systemmediatransportcontrols.ispauseenabled) to true. Your app must also handle the [**ButtonPressed**](/uwp/api/windows.media.systemmediatransportcontrols.buttonpressed) event. If your app does not meet these requirements, audio playback will stop when your app moves to the background.
106106

107-
Apps that use the new one-process model for background audio should get an instance of the [**SystemMediaTransportControls**](/uwp/api/Windows.Media.SystemMediaTransportControls) by calling [**GetForCurrentView**](/uwp/api/windows.media.systemmediatransportcontrols.getforcurrentview). Apps that use the legacy two-process model for background audio must use [**BackgroundMediaPlayer.Current.SystemMediaTransportControls**](/uwp/api/windows.media.playback.mediaplayer.systemmediatransportcontrols) to get access to the SMTC from their background process.
108-
109107

110108

111109
## Related topics

0 commit comments

Comments
 (0)