In UWP project, I change MediaPlayerElement property "background", but it don't change, still black!
In UWP project, I change MediaPlayerElement property "background", but it don't change, still black!
Changing the background property on a MediaPlayerElement does not have the desired effect, because the colors of the media display surface (including the background) are determined by the content that is being played/streamed.
To provide your MediaPlayerElement with visual representation for states when the media is not showing (yet) you can use the PosterSource property.
<MediaPlayerElement PosterSource="imageUri" />
Since the PosterSource expects an ImageSource, you will have to provide a path to an image. If you want just a single color, adding a 1x1 pixel image to you project and providing the path to it as the imageUri property should work (I have no environment set up to test this).
From the UWP PosterSource docs:
The PosterSource is displayed in the following situations: When a
- valid source is not set. For example, Source is not set, Source was set to Null, or the source is invalid (as is the case when a MediaFailed event fires).
- While media is loading. For example, a valid source is set, but the MediaOpened event has not fired yet.
- When media is streaming to another device.
- When the media is audio only.
UWP docs sources: