Aldo
Aldo

Reputation: 41

How to play a live video on youtube?

When playing any video from YouTube you have no problem, however I have problems trying to play a live video

<Grid Background="Black">
    <MediaElement Name="Media"
                  AreTransportControlsEnabled="True">
    </MediaElement>
</Grid>

I am using the package MyToolkit.Extended

    public async void SetDataPlayer()
    {
        _loadAnimationListener?.FinishLoadAnimation();
        var videoURL = await YouTube.GetVideoUriAsync("DU5u4oCR8l0", YouTubeQuality.Quality1080P);
        Media.Source = videoURL.Uri;
    }

Upvotes: 0

Views: 98

Answers (1)

Nico Zhu
Nico Zhu

Reputation: 32785

How to play a live video on youtube?

You could use CreateFromUri to converter YouTube video uri to MediaSource like the follow.

public async void SetDataPlayer()
{
    _loadAnimationListener?.FinishLoadAnimation();
    var videoURL = await YouTube.GetVideoUriAsync("Bey4XXJxxxxx", YouTubeQuality.Quality1080P);
    Media.Source = MediaSource.CreateFromUri(videoURL.Uri);
}

Upvotes: 1

Related Questions