Adding Audio Frame to Slide in PHP

Aspose.Slides - Adding Audio Frame to Slide

To Add Audio Frame to Slide using Aspose.Slides Java for PHP, call add_audio_frame method of Frame module. Here you can see example code.

PHPCode


 public static function add_audio_frame($dataDir=null)

{

    # Create an instance of Presentation class

    $pres = new Presentation();

    # Get the first slide

    $sId = $pres->getSlides()->get_Item(0);

    # Load the wav sound file to stram

    $fstr = new FileInputStream(new File($dataDir . "Bass-Drum.wav"));

    # Add Audio Frame

    $af = $sId->getShapes()->addAudioFrameEmbedded(50, 150, 100, 100, $fstr);

    # Set Play Mode and Volume of the Audio

    $audioPlayModePreset = new AudioPlayModePreset();

    $audioVolumeMode = new AudioVolumeMode();

    $af->setPlayMode($audioPlayModePreset->Auto);

    $af->setVolume($audioVolumeMode->Loud);

    # Write the presentation as a PPTX file

    $save_format = new SaveFormat();

    $pres->save($dataDir . "AudioFrameEmbed.pptx", $save_format->Pptx);

    print "Added audio frame to slide, please check the output file." . PHP_EOL;

}

Download Running Code

Download Adding Audio Frame to Slide (Aspose.Slides) from any of the below mentioned social coding sites: