In this simple article, we will demonstrate how to add audio in Presentation using C# along with the detailed steps to configure the environment and use the example code. You can utilize this application without any dependence any third-party software or an Interop library and in any of the .NET configured environments inside Windows, Linux, or macOS to embed audio in PPTX using C#.
Steps to Insert Audio in Presentation using C#
- Configure the environment to install Aspose.Slides for .NET from NuGet package manager to add a audio frame
- Generate a sample presentation using the Presentation class to embed a audio inside the presentation
- Access the selected slide inside the presentation slides collection to add a audio frame
- Access the audio file and add inside the presentation slide audio frame
- Set the audio frame image after loading from the disk
- Save the presentation with an embedded audio on the disk
By using the aforementioned procedure in C# inserting audio in PowerPoint presentation can be swiftly managed with the help of simple API calls. The process is commenced by creating a sample presentation using the Presentation class and accessing the desired slide inside the presentation. Then the source audio file and an image is loaded from the disk and added inside the audio frame shape for the slide. Finally, the audio frame image will be set before saving the presentation with an embedded audio frame on the disk.
Code to Insert Audio in Presentation using C#
In C# saving MP3 audio in PPT presentation can be managed using a very simple API calls as specified in above example. We have employed IAudioFrame that also let you set the properties like setting the audio frame image, rewind mode, play mode and play audio in a loop to name a few. You may also insert an audio frame inside any slide of an existing presentation as well. Once the audio will be embedded inside the audio frame, the presentation can either be saved on the disk or inside a memory stream.
In this topic, we learnt about how to insert audio in Presentation using C#. If you want to learn about inserting video inside the presentation slide, refer to the article on how to add Video in presentation using C#.