PresentationPlayer

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.ms.System.IDisposable

public class PresentationPlayer implements System.IDisposable

Represents the player of animations associated with the Presentation.


Presentation pres = new Presentation("pres.pptx");
 try {
     PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(pres);
     try {
         // Play animation with 33 FPS
         PresentationPlayer player33 = new PresentationPlayer(animationsGenerator, 33);
         try {
             player33.setFrameTick(new PresentationPlayer.FrameTick() {
                 public void invoke(PresentationPlayer sender, FrameTickEventArgs args) {
                     FileOutputStream fos = null;
                     try {
                         fos = new FileOutputStream("33fps/frame_" + sender.getFrameIndex() + ".png");
                         args.getFrame().compress(android.graphics.Bitmap.CompressFormat.PNG, 100, fos);
                     } catch (IOException e) {
                         throw new RuntimeException(e);
                     } finally {
                         if (fos != null) {
                             try {
                                 fos.close();
                             } catch (IOException e) {
                                 e.printStackTrace();
                             }
                         }
                     }
                 }
             });
             animationsGenerator.run(pres.getSlides());
         } finally {
             if (player33 != null) player33.dispose();
         }
         // Play animation with 45 FPS
         PresentationPlayer player45 = new PresentationPlayer(animationsGenerator, 45);
         try {
             player45.setFrameTick(new PresentationPlayer.FrameTick() {
                 public void invoke(PresentationPlayer sender, FrameTickEventArgs args) {
                     FileOutputStream fos = null;
                     try {
                         fos = new FileOutputStream("45fps/frame_" + sender.getFrameIndex() + ".png");
                         args.getFrame().compress(android.graphics.Bitmap.CompressFormat.PNG, 100, fos);
                     } catch (IOException e) {
                         throw new RuntimeException(e);
                     } finally {
                         if (fos != null) {
                             try {
                                 fos.close();
                             } catch (IOException e) {
                                 e.printStackTrace();
                             }
                         }
                     }
                 }
             });
             animationsGenerator.run(pres.getSlides());
         } finally {
             if (player45 != null) player45.dispose();
         }
     } finally {
         if (animationsGenerator != null) animationsGenerator.dispose();
     }
 } finally {
     if (pres != null) pres.dispose();
 }

Constructors

ConstructorDescription
PresentationPlayer(PresentationAnimationsGenerator generator, double fps)Creates new instance of the PresentationPlayer.

Methods

MethodDescription
dispose()Disposes the instance of the PresentationPlayer.
getFrameIndex()Gets the frame index.
setFrameTick(PresentationPlayer.FrameTick event)Set a new frame tick event.

PresentationPlayer(PresentationAnimationsGenerator generator, double fps)

public PresentationPlayer(PresentationAnimationsGenerator generator, double fps)

Creates new instance of the PresentationPlayer.

Parameters:

ParameterTypeDescription
generatorPresentationAnimationsGeneratorPresentation animations generator
fpsdoubleFrames per second (FPS)

dispose()

public final void dispose()

Disposes the instance of the PresentationPlayer.

getFrameIndex()

public final int getFrameIndex()

Gets the frame index.


Presentation pres = new Presentation("pres.pptx");
 try {
     PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(pres);
     try {
         PresentationPlayer player = new PresentationPlayer(animationsGenerator, 33);
         try {
             player.setFrameTick(new PresentationPlayer.FrameTick() {
                 public void invoke(PresentationPlayer sender, FrameTickEventArgs args) {
                     FileOutputStream fos = null;
                     try {
                         fos = new FileOutputStream("frame_" + sender.getFrameIndex() + ".png");
                         args.getFrame().compress(android.graphics.Bitmap.CompressFormat.PNG, 100, fos);
                     } catch (IOException e) {
                         throw new RuntimeException(e);
                     } finally {
                         if (fos != null) {
                             try {
                                 fos.close();
                             } catch (IOException e) {
                                 e.printStackTrace();
                             }
                         }
                     }
                 }
             });
             animationsGenerator.run(pres.getSlides());
         } finally {
             if (player != null) player.dispose();
         }
     } finally {
         if (animationsGenerator != null) animationsGenerator.dispose();
     }
 } finally {
     if (pres != null) pres.dispose();
 }

Returns: int

setFrameTick(PresentationPlayer.FrameTick event)

public void setFrameTick(PresentationPlayer.FrameTick event)

Set a new frame tick event.


Presentation pres = new Presentation("pres.pptx");
 try {
     PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(pres);
     try {
         PresentationPlayer player = new PresentationPlayer(animationsGenerator, 33);
         try {
             player.setFrameTick(new PresentationPlayer.FrameTick() {
                 public void invoke(PresentationPlayer sender, FrameTickEventArgs args) {
                     FileOutputStream fos = null;
                     try {
                         fos = new FileOutputStream("frame_" + sender.getFrameIndex() + ".png");
                         args.getFrame().compress(android.graphics.Bitmap.CompressFormat.PNG, 100, fos);
                     } catch (IOException e) {
                         throw new RuntimeException(e);
                     } finally {
                         if (fos != null) {
                             try {
                                 fos.close();
                             } catch (IOException e) {
                                 e.printStackTrace();
                             }
                         }
                     }
                 }
             });
             animationsGenerator.run(pres.getSlides());
         } finally {
             if (player != null) player.dispose();
         }
     } finally {
         if (animationsGenerator != null) animationsGenerator.dispose();
     }
 } finally {
     if (pres != null) pres.dispose();
 }

Occurs when each frame of the animation created by PresentationAnimationsGenerator is generated by the player.

Parameters:

ParameterTypeDescription
eventFrameTickFrame tick event.