Video

Hiển thị cách nhúng khung video và thiết lập các tùy chọn phát lại bằng Aspose.Slides for Python via .NET.

Thêm một Khung Video

Chèn một khung video trống vào slide.

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

        # Thêm một khung video.
        video_frame = slide.shapes.add_video_frame(50, 50, 320, 240, "video.mp4")

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

Truy cập Khung Video

Lấy khung video đầu tiên được thêm vào slide.

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

        # Truy cập khung video đầu tiên trên slide.
        first_video = next(shape for shape in slide.shapes if isinstance(shape, slides.VideoFrame))

Xóa Khung Video

Xóa một khung video khỏi slide.

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

        # Giả sử hình dạng đầu tiên là một khung video.
        video_frame = slide.shapes[0]

        # Xóa khung video.
        slide.shapes.remove(video_frame)

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

Thiết lập Phát Video

Cấu hình video để tự động phát khi slide được hiển thị.

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

        # Giả sử hình dạng đầu tiên là một khung video.
        video_frame = slide.shapes[0]

        # Cấu hình video để tự động phát.
        video_frame.play_mode = slides.VideoPlayModePreset.AUTO

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