Reputation: 1267
I tried to do a simple video playback following (https://msdn.microsoft.com/en-us/windows/uwp/controls-and-patterns/media-playback)[this article] by adding the following
<MediaPlayerElement AutoPlay="True" AreTransportControlsEnabled="True" Source="http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4" />
to my page XAML. But apparently, this does not work. Is this because we can only use local file for the Source
?
Upvotes: 1
Views: 944
Reputation: 10627
Is this because we can only use local file for the Source?
No, you can set http stream for the source. But the source property of MediaPlayerElement
is IMediaPlaybackSource
not Uri directly. You need to create MediaSource from Uri code behind. Code as follows.
XAML Code
<MediaPlayerElement AutoPlay="True" AreTransportControlsEnabled="True" x:Name="mediaplayer" Height="400" Width="400" />
Code behind
public MainPage()
{
this.InitializeComponent();
Uri pathUri = new Uri("http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4");
mediaplayer.Source = MediaSource.CreateFromUri(pathUri);
}
You can also use MediaElement control which its source type is Uri directly.
<MediaElement Height="400" Width="400" AutoPlay="True" Source="http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4"></MediaElement>
Upvotes: 1