Book Image

Panda3D 1.7 Game Developer's Cookbook

Book Image

Panda3D 1.7 Game Developer's Cookbook

Overview of this book

Table of Contents (20 chapters)
Panda3D 1.7 Game Developer's Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Playing a movie file


Whether it's showing your game studio's logo sequence at the start of the game, or it's telling an important part of your story using cutscenes—sometimes you need to play full motion video. That's why in this recipe you will learn how to load a video and replay it in the game window.

Getting ready

This sample uses the project structure created in Setting up the game structure found in Chapter 1. You also need to add a directory called videos to the project's source tree to keep your assets organized. Make sure that the videos directory is on Panda3D's content search path!

Of course, you need to provide a video file for playback. Panda3D uses the FFmpeg programming library for decoding video data, so it should be able to process any codec supported by FFmpeg. The sample code assumes you are using an AVI file.

How to do it...

To play a movie file, complete these tasks:

  1. Copy your video file to the videos directory and rename it to movie.avi.

  2. Open the Application.py file and add...