Видео

Показывает, как внедрять видеокадры и задавать параметры воспроизведения с помощью Aspose.Slides for Python via .NET.

Добавить видеокадр

Вставьте пустой видеокадр на слайд.

def add_video():
    with slides.Presentation() as presentation:
        slide = presentation.slides[0]

        # Добавить видеокадр.
        video_frame = slide.shapes.add_video_frame(50, 50, 320, 240, "video.mp4")

        presentation.save("video.pptx", slides.export.SaveFormat.PPTX)

Доступ к видеокадру

Получите первый видеокадр, добавленный на слайд.

def access_video():
    with slides.Presentation("video.pptx") as presentation:
        slide = presentation.slides[0]

        # Доступ к первому видеокадру на слайде.
        first_video = next(shape for shape in slide.shapes if isinstance(shape, slides.VideoFrame))

Удалить видеокадр

Удалите видеокадр со слайда.

def remove_video():
    with slides.Presentation("video.pptx") as presentation:
        slide = presentation.slides[0]

        # Предполагая, что первая фигура — видеокадр.
        video_frame = slide.shapes[0]

        # Удалить видеокадр.
        slide.shapes.remove(video_frame)

        presentation.save("video_removed.pptx", slides.export.SaveFormat.PPTX)

Настроить воспроизведение видео

Настройте видео на автоматическое воспроизведение при отображении слайда.

def set_video_playback():
    with slides.Presentation("video.pptx") as presentation:
        slide = presentation.slides[0]

        # Предполагая, что первая фигура — видеокадр.
        video_frame = slide.shapes[0]

        # Настроить видео для автоматического воспроизведения.
        video_frame.play_mode = slides.VideoPlayModePreset.AUTO

        presentation.save("video_playback.pptx", slides.export.SaveFormat.PPTX)