Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents from any .NET(C#, VB.NET, ASP.NET, .NET Core) application and Java (J2SE and J2EE) application.

Mon Aug 23, 2021 6:03 pm

Hi,

I am trying to add audio to presentation with some advanced settings.

I need to add audio with options to start audio automatically when slide is opened and hide audio play button during presentation.
When using settings IsPlayinBackground = true and IsLoop = false does hide the play button but the audio is looped and not stopped when moving to next slide.

Any advanced code samples would be helpful.

erkki.lohiniva
 
Posts: 2
Joined: Tue Aug 17, 2021 10:17 am

Tue Aug 24, 2021 8:35 am

Hello,

Thanks for your inquiry.
Please note that the property "IsPlayinBackground" of an audio will affect the property "IsLoop" in a ppt file. When both of them are set at the same time, the "IsLoop" is determined by the "IsPlayinBackground"; that is, when the "IsPlayinBackground" is true, "IsLoop" will be true; Isloop will be false when isplayinbackground is false.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Aug 24, 2021 2:32 pm

Hi,

Ok. That's how it works.
But how can I do this
- Hide play button from slides during presentation
- Automatically (or using animation triggers) start audio(s) when slide is opened during presentation

Using IsPlayinBackground = true hides the button but causes audio looping and if you have different audios for slides it makes them all loop when going in presentation mode.

erkki.lohiniva
 
Posts: 2
Joined: Tue Aug 17, 2021 10:17 am

Wed Aug 25, 2021 9:37 am

Hello,

Thank for your response.
I am sorry that our Spire.Presentation does not support hiding play button from slides during show, but I have added it as a new feature into our upgrade list. If it is implemented in the future, we will inform you immediately.
Regarding starting audio when slide is opened during show automatically, please refer to the following code.

Code: Select all
            Presentation presentation = new Presentation();

            presentation.LoadFromFile(@"InsertAudio.pptx");

            RectangleF audioRect = new RectangleF(220, 240, 80, 80);
            IAudio audio = presentation.Slides[0].Shapes.AppendAudioMedia("Music.wav", audioRect);
            AnimationEffect effect = presentation.Slides[0].Timeline.MainSequence.AddEffect(audio, AnimationEffectType.RandomBars);
            effect.AnimationEffectType = AnimationEffectType.MediaPlay;
            effect.Timing.TriggerType = AnimationTriggerType.WithPrevious;
            effect.Timing.AnimationRepeatType = AnimationRepeatType.UtilEndOfSlide;  //This line of code will loop the audio until the end of the current slide


            audio = presentation.Slides[1].Shapes.AppendAudioMedia("ANU - FLY.wav", audioRect);
            effect = presentation.Slides[1].Timeline.MainSequence.AddEffect(audio, AnimationEffectType.RandomBars);
            effect.AnimationEffectType = AnimationEffectType.MediaPlay;
            effect.Timing.TriggerType = AnimationTriggerType.WithPrevious;
            effect.Timing.AnimationRepeatType = AnimationRepeatType.UtilEndOfSlide;

            presentation.SaveToFile("Audio.pptx", FileFormat.Pptx2010);


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Sep 17, 2021 11:03 am

Hello,

Greetings from E-iceblue!
Glad to inform you that we just released Spire.Presentation Pack Hotfix Version:6.9.2 which supports hiding audio in show mode, please download it from the following links to test on your side. Looking forward to your test result.
Website link: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link: https://www.nuget.org/packages/Spire.Presentation/6.9.2

The sample code as below.
Code: Select all
            IAudio audio = presentation.Slides[0].Shapes.AppendAudioMedia("Music.wav", audioRect);
            audio.HideAtShowing = true;


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon Sep 27, 2021 2:16 am

Hello,

Greetings from E-iceblue!
Can this hotfix meet your needs? Could you please give us some feedback at your convenience?

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Presentation