How to obtain object's sound effect in PowerPoint

2017-01-24 07:29:25 Written by  support iceblue
Rate this item
(0 votes)

Animation is a great way to draw viewers' attention to a presentation. We can apply animation effects to text, shapes or any other objects on PowerPoint slides. To make the animations more attractive, we usually set sound effects for them. This article demonstrates how to obtain these sound effects by using Spire.Presentation and C#.

Below shape is set with a fly in animation which has a sound effect named "Applause".

How to obtain object's sound effect in PowerPoint

Refer below steps to get the sound effect from the shape:

Step 1: Load the PowerPoint document.

Presentation ppt = new Presentation(@"test.pptx", FileFormat.Pptx2013);

Step 2: Get the audio in a time node.

ISlide slide = ppt.Slides[0];
TimeNodeAudio audio = slide.Timeline.MainSequence[0].TimeNodeAudios[0];

Step 3: Now we can get the properties of the audio, such as sound name, volume or detect if it's mute.

string soundName = audio.SoundName;
float volume = audio.Volume;
bool isMute = audio.IsMute;

Output:

How to obtain object's sound effect in PowerPoint

Full code:

using System;
using Spire.Presentation;
using Spire.Presentation.Drawing.TimeLine;

namespace Get_Sound_Effect
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation ppt = new Presentation(@"test.pptx", FileFormat.Pptx2013);
            ISlide slide = ppt.Slides[0];
            TimeNodeAudio audio = slide.Timeline.MainSequence[0].TimeNodeAudios[0];
            string soundName = audio.SoundName;
            float volume = audio.Volume;
            bool isMute = audio.IsMute;
            Console.WriteLine("{0}, {1}, {2}", soundName, volume, isMute);
            Console.ReadKey();
        }
    }
}

Additional Info

  • tutorial_title: Obtain object's sound effect in PowerPoint
Last modified on Friday, 24 September 2021 09:11