Max
Max

Reputation: 326

C# WPF MediaElement MyToolKit Youtube

I would like to run youtube videos in a media element. This morning, everything worked well but now I have an error saying that an object is null. I've tried to find the object but there is not. An other group has the same case as mine. I didn't change anything.

private async void runYoutubeVideo(String youtubeId)
    {
        try
        {
            Console.WriteLine(youtubeId);
            var url = await YouTube.GetVideoUriAsync(youtubeId, YouTubeQuality.Quality480P);
            _mediaElementObject.Source = url.Uri;
            _modelPlayer.CurrentMedia = new Media(url.Uri, YoutubeURLString);
            TitleFile = _modelPlayer.CurrentMedia.FileName;

            YoutubeURLString = null;
            Uri tmp = new Uri(_modelPlayer.CurrentMedia.FilePath);
            this._mediaElementObject.Source = tmp;
            this.SliderVideoObject = 0;
            createTimerTrick();
            _mediaElementObject.Play();
        }
        catch
        {
            Console.WriteLine("Youtube Runner Error");
            new NullReferenceException("Error");
            return;
        }
    }

Upvotes: 1

Views: 388

Answers (0)

Related Questions