Aspose.Slides.Examples.CSharp.Shapes.AddVideoFrameFromWebSource.AddVideoFromYouTube C# (CSharp) Method

AddVideoFromYouTube() private static method

private static AddVideoFromYouTube ( Presentation pres, string videoId ) : void
pres Presentation
videoId string
return void
        private static void AddVideoFromYouTube(Presentation pres, string videoId)
        {
            //add videoFrame
            IVideoFrame videoFrame = pres.Slides[0].Shapes.AddVideoFrame(10, 10, 427, 240, "https://www.youtube.com/embed/" + videoId);
            videoFrame.PlayMode = VideoPlayModePreset.Auto;

            //load thumbnail
            using (WebClient client = new WebClient())
            {
                string thumbnailUri = "http://img.youtube.com/vi/" + videoId + "/hqdefault.jpg";
                videoFrame.PictureFormat.Picture.Image = pres.Images.AddImage(client.DownloadData(thumbnailUri));
            }
        }
    }
AddVideoFrameFromWebSource