Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Thu Mar 12, 2015 10:32 pm

The example you have for adding audio doesn't seem to work, everytime I click on the audio icon, it doesn't have sound with it.

Also, is it possible to add a image and then attach a mp3?

whittenmike807
 
Posts: 7
Joined: Thu Mar 05, 2015 9:23 pm

Fri Mar 13, 2015 8:06 am

Hello,

Thanks for your inquiry.
The audio data are not embedded in presentation, so when you click on the audio icon, it doesn’t work. Please add the codes as below:
Code: Select all
shape.Data = presentation.WavAudios.Append(File.ReadAllBytes(@"F:\download\Moves Like Jagger.mp3"));

The default volume type is mute, so you must to set the volume type manually.Please add the codes as below:
Code: Select all
shape.Volume = AudioVolumeType.Medium;

Here are all codes which can add a image and then attach a mp3:
Code: Select all
Presentation presentation = new Presentation();
Rectangle rec = new Rectangle(100, 100, 200, 200);
IAudio shape =  presentation.Slides[0].Shapes.AppendAudioMedia(@"F:\download\Moves Like Jagger.mp3", rec);
//change the picture of the audio
shape.PictureFill.Picture.EmbedImage = presentation.Images.Append(Image.FromFile(@"D:\spire.office\Demos\DocDemos\Data\Footer.png"));
//embed the audio data to the presentation
shape.Data = presentation.WavAudios.Append(File.ReadAllBytes(@"F:\download\Moves Like Jagger.mp3"));
// set volume to Medium
shape.Volume = AudioVolumeType.Medium;
presentation.SaveToFile("Audio.pptx", FileFormat.Pptx2010);

If there are any questions, welcome to get it back to us.

Best Regards,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Tue Mar 17, 2015 7:52 am

Hello,

Have you tried the codes I provided? Has your issue been resolved? Could you please give us some feedback at your convenience?

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Return to Spire.Presentation