In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to add and read video and audio from PPT slides. I hope you will get something after reading this article. Let's discuss it together.
Using tools: Free Spire.Presentation for Java (free version)
Jar file acquisition and import:
Method 1: download the package through the official website. After downloading, extract the file and import the Spire.Presentaion.jar file under the lib folder into the Java program. As shown below:
Method 2: it can be installed and imported through maven warehouse. Refer to the path configuration and import method.
[example 1] add video and audio to PPT slides
Import com.spire.presentation.*; import java.awt.*; public class AddVideoAudio {public static void main (String [] args) throws Exception {/ / load the test document Presentation ppt = new Presentation (); ppt.loadFromFile ("test.pptx"); / / get the first slide ISlide slide = ppt.getSlides () .get (0) / add video files to the specified location slide.getShapes (). AppendVideoMedia ("Transition.mp4", new Rectangle (550,100,180,100)); / / add audio files to the specified location slide.getShapes () .appendAudioMedia ("Myheartwillgoon.mp3", 620,300, true); / / Save the document ppt.saveToFile ("result.pptx", FileFormat.PPTX_2010);}}
Add video and audio effects:
[example 2] read video and audio in PPT slides
Import com.spire.presentation.*; public class ExtractVideoAudio {public static void main (String [] args) throws Exception {/ / load the PPT document containing video and audio files Presentation ppt = new Presentation (); ppt.loadFromFile ("result.pptx"); / / get the first slide ISlide slide = ppt.getSlides () .get (0); IVideo video = null; IAudio audio = null / / iterate through the shape in the slide to determine whether the video for is included (int I = 0; I < slide.getShapes (). GetCount (); iTunes +) {IShape shape = slide.getShapes (). Get (I); if ((shape instanceof IVideo)) {/ / Save video video = (IVideo) shape Video.getEmbeddedVideoData () .saveToFile ("extracted video" + I + ".mp4");}} / / traverses the shape in the slide to determine whether it contains audio for (int j = 0; j < slide.getShapes (). GetCount (); jacks +) {IShape shape = slide.getShapes (). Get (j) / / Save audio if ((shape instanceof IAudio)) {audio = (IAudio) shape; audio.getData () .saveToFile ("extracted audio" + j + ".mp3");}
Reading results of video and audio files:
After reading this article, I believe you have a certain understanding of "how to add and read video and audio in PPT slides". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.