How to Extract Audio File from Slide Timeline?

Please open the file in the zip package and review the picutre below.
animation audio.pptx.zip (325.0 KB)
animation audio.png (154.3 KB)
Could you tell me how to get the drumroll.wav audio file in animation timeline?I am very grateful.

@oscarstar,
Thank you for posting the query. You can extract audio contents from the presentation using Aspose.Slides as shown below:

Presentation presentation = new Presentation(dataPath + "animation audio.pptx");
for (int i = 0; i < presentation.getAudios().size(); i++)
{
    IAudio audio = presentation.getAudios().get_Item(i);
    if(audio.getContentType() == "audio/x-wav")
    {
        File audioFile = new File(dataPath + "audio_" + i + ".wav");
        OutputStream outputStream = new FileOutputStream(audioFile);
        IOUtils.copy(audio.getStream(), outputStream);
    }
}

API Reference: IAudio interface

If the issue persists, please clarify your requirments.

Thank you for your reply.I hope to find the file or relation in the timeline animation collection.Please review the code below:
Presentation presentation = new Presentation(dataPath + “animation audio.pptx”);
IBehaviorCollection collection = presentation.getSlides().get_Item(0).getTimeline().getMainSequence().get_Item(0).getBehaviors();
for (int i = 0; i < collection.getCount(); i++) {
// todo: find the command effect and get the audio setting
}
I can’t find the audio file or relation in the collection or any where.Could you help me to find the relation of the audio and animation effect?Thanks a lot.

@oscarstar,
Unfortunately, I have not found a way to extract audio from the slide timeline. There seems to be no corresponding feature. I logged the issue with ID SLIDESJAVA-38590 in our tracking system. Our development team will investigate such a possibility. I will inform you of any progress.

Any progress?

@oscarstar,
I’ve requested an estimated time to implement such a feature from our development team. We will let you know as soon as possible.

Would it be possible to add the feature? We really need this one.

@oscarstar
We will conduct a detailed study and try to include this feature in the near future. I’ll let you know as soon as I get the ETA from the development team.

It’s very kind of you, It means a lot to me.

1 Like

The issues you have found earlier (filed as SLIDESJAVA-38590) have been fixed in Aspose.Slides for Java 22.8 (ZIP).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.

@oscarstar,
Please try using the following code snippet with Aspose.Slides 22.8:

Presentation presentation = new Presentation("demo.pptx");
try {
    ISlide slide = presentation.getSlides().get_Item(0);

    // Gets the effects sequence for the slide
    ISequence effectsSequence = slide.getTimeline().getMainSequence();

    for (IEffect effect : effectsSequence)
    {
        if (effect.getSound() == null)
            continue;

        // Extracts the effect sound in byte array
        byte[] audio = effect.getSound().getBinaryData();
    }
} finally {
    if (presentation != null) presentation.dispose();
}

Awesome! You are my hero!!!

@oscarstar,
Thank you for using Aspose.Slides.

Thank you for your attention and efforts. I can successfully get the audio file,It’s so good. But I still found a small problem. Please review the file in the zip package and the snapshot.
EffectAudio.pptx.zip (1.2 MB)
ui-snapshot.jpg (269.8 KB)
data-snapshot.png (655.1 KB)
We cannot distinguish between [no sound] in slide 2 and [stop the previous sound] in slide 3. Can you give us some guidance?

@oscarstar,
In the sample presentation you provided, I see Spin/Effect/Sound option equals [Stop Previous Sound] on slide 2 with a rectangle and Pulse/Effect/Sound option equals [No Sound] on slide 3 with a hexagon. Could you please confirm that this is what you mean?

Please review the file in this package. You can click the first button to playing sound. You can click the last button to stop the playing sound. Because the last button use [Stop Previous Sound] option.
动画音效测试.pptx.zip (367.2 KB)
Can I get the [Stop Previous Sound] value or enum through our effect api or property?

@oscarstar,
Thank you for the additional presentation file. Unfortunately, I did not find such a feature to read these values using Aspose.Slides. I’ve added a ticket with ID SLIDESJAVA-38896 to our issue tracking system. Our development team will consider implementing such a feature. You will be notified when the issue is resolved.

Thank you for your reply and look forward to your good news.

@oscarstar,
Thank you for your patience.

The issues you have found earlier (filed as SLIDESJAVA-38896) have been fixed in Aspose.Slides for Java 22.11 (JAR).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.