Adding video from website (like youtube)

Hi,

Is it possible to programmatically add a video object to a powerpoint slide where the source video is on an external website?

Like for example youtube.

It’s the equivalent of Insert Video from website option within powerpoint itself.

Best regards
Gurs

Hi Gurs,


Thanks for your interest in Aspose.Slide.

You can download video from internet using stream or byte arrays. You can then embed the video inside the presentation using streams. Please use the following code snippet for your kind reference. Moreover, the URL from youtube is actually not the actual video link to download the video in stream. Please share if I may help you further in this regard.

PresentationEx pres = new PresentationEx();
while (pres.Slides[0].Shapes.Count > 0)
pres.Slides[0].Shapes.RemoveAt(0);
VideoFrameEx vf = pres.Slides[0].Shapes.AddVideoFrame(110, 70, 100, 60, null);
VideoEx vid = pres.Videos.AddVideo(new FileStream(@"…\Wildlife2.wmv", FileMode.Open)); // adding VideoEx from stream
vf.EmbeddedVideo = vid;
MemoryStream ms = new MemoryStream();
pres.Write(@"…\NewEmbed.pptx");


Many Thanks,

Hi Mudassir,

many thanks for your reply, I am not quite following your answer however.Are you saying that you need to stream/download the file first and reference it locally before you can add the video to the slide? I need to replicate the exact functionality of Insert Video from website which simply references the video from where the video is online.

This is the type of thing I can embed into a Powerpoint slide:


http://www.somedomain.co.uk/player-viral.swf" />



<embed type="application/x-shockwave-flash" width="600" height="320" id="player2" name="player2"
src="player-viral.swf" allowscriptaccess="always" allowfullscreen="true" flashvars="file=http://www.somedomain.co.uk/avideo.flv&stretching=fill&image=image.jpg&" />

Many thanks

Gurs

Hi Gurs,


I regret to share that the desired functionality of embedding video inside presentation from web source as available in PowerPoint is unavailable in Aspose.Slides for .NET. An issue with ID 32388 has been created in our issue tracking system to investigate te possibility of implementing this feature.

As a work around, you may currently use the method I have shared before. You may first download the video from web source using streams and embed the video inside the presentation using those streams.

Many Thanks,

Many thanks for you help Mudassir - I will look out for new feature when/if it becomes available.

Regards

Gurs

The issues you have found earlier (filed as SLIDESNET-32388) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi,


Is it possible to add a video(an “.mp4” file from Azure Blob Storage Account) into PowePoint 2016 Slide using Aspose.Slides/Aspose.Slides-Cloud?

Thanks,
Stephen.
Hi Stephen,

I have observed your comments and regret to inform that support for adding video from azure storage account is currently unavailable in Aspose.Slides. An issue with ID SLIDESNET-38623 has been created in our issue tracking system as new feature request to provide the requested support. We will share the notification with you as soon as the feature will be available.

Best Regards,

Thanks Adnan for your quick reply. I have few questions:


1. Is there any work around to achieve this functionality? (e.g. serialize the blob video as a stream of bytes and then insert into PPT Slide on fly etc., without downloading the video to the local PC as the Project is hosted in Azure Platform)

2. Just want to know the use of Aspose Cloud API’s. I thought that’s to achieve the tasks such as my requirement (to insert a Video, from Azure Blob storage account, into PPT etc.)

3. Is it possible to insert a Video from the relative url of a .Net Web API Project, instead inserting from Azure Blob Storage Account?

Thanks,
Stephen.

Hi Stephen,

I have observed your requirement and like to share that Aspose.Slides does allow you to add video inside presentation without saving on disc. You can get video from any web source in the form of stream and then convert that stream to byte array and passing that to AddVideo method of IVideoCollection class. You can also pass stream object to AddVideo() method of IVideoCollection as well. Please visit this IVideoCollection class method for your reference. Please also visit documentation article, Add Embedded VideoFrame for your reference as well. For your question related to video from relative URL, the same embedding scheme shall be used.
You can have support for Youtube as PowerPoint 2010 and newer versions support YouTube videos. To play these videos in PowerPoint make sure your environment meet these requirements.

In order to add video from YouTube with Aspose.Slides, please use attached code snippet.
For other web sources like Facebook or OneDrive, PowerPoint internally download and embed video file. This could be performed by using WebClient to fetch the video in stream and then using documentation article, Add Embedded Video Frame.


For your question related to Aspose.Cloud, we will share the feedback with you shortly.

Many Thanks,

Thanks Muddssir for the solution that you have directed me to!. Passing the byte array to AddVideo() works well and playing the video once the play button is clicked. However, when the slide show is launched, it shows “No Image” in the video control until the play button in pressed, instead of showing the starting frame of the attached video as preview. Is there a way to fix that?


Thanks,
Stephen.

Hi Stephen,

I have observed your requirements and like to share that you can set image for video frame to avoid default red message. Please visit this documentation link to serve the purpose on your end.

Many Thanks,

Hello, I’m having the same issue using .NET code below. Setting Picture.Image property looks like sets it below the “No Image” place holder (once set you can see a pixel or so of it sticking out at the bottom and on the right). I cannot find out how to get rid of the “No Image” place holder.

using (Presentation presentation = new Presentation())
{
	// Get the first slide
	ISlide slide = presentation.Slides[0];

	var videoPath = Path.Combine(Util.CurrentQuery.Location, "Wildlife.mp4");
	IVideo vid = slide.Presentation.Videos.AddVideo(new FileStream(videoPath, FileMode.Open), LoadingStreamBehavior.ReadStreamAndRelease);
	IVideoFrame vf = slide.Shapes.AddVideoFrame(10, 10, 300, 200, vid);
	vf.EmbeddedVideo = vid;
	vf.PlayMode = VideoPlayModePreset.OnClick;
	vf.Volume = AudioVolumeMode.Medium;
	
	var imgx = presentation.Images.AddImage((Image)new Bitmap(Path.Combine(Util.CurrentQuery.Location, "pic.jpg")));
	vf.FillFormat.FillType = FillType.Picture;
	vf.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Tile;

	vf.FillFormat.PictureFillFormat.Picture.Image = imgx;

	// Save presentation
	presentation.Save(Path.Combine(Util.CurrentQuery.Location, "out.pptx"), SaveFormat.Pptx);
}

@ivoloshin,

Please try using following sample code on your end for adding image for Video Frame.

IPPImage img = null;
img = presentation.Images.AddImage(new FileStream(imgpath + "Tulips.jpg", FileMode.Open));
vf.PictureFormat.Picture.Image = img;

That worked, thank you!

The issues you have found earlier (filed as SLIDESNET-38623) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by mudassir.fayyaz