Book Image

Kivy - Interactive Applications and Games in Python

By : Roberto Ulloa
Book Image

Kivy - Interactive Applications and Games in Python

By: Roberto Ulloa

Overview of this book

Table of Contents (13 chapters)
Kivy – Interactive Applications and Games in Python Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Video – play, pause, and stop


We will start with simple code in this section, and then gradually include functionality until we get a complete video player. In this section, we will discuss how to use the Video widget in order to stream a video from the Internet. Let's start with the code in the video.kv file:

1. # File name: video.kv
2. #:set _default_video "http://video.ted.com/talk/stream/2004/None/DanGilbert_2004-180k.mp4"
3. 
4. <Video>:
5.     allow_stretch: True
6.     color: 0,0,0,0
7.     source: _default_video

In this code, we initially create a constant value with the set directive (line 2). This directive allows us to have global values that we can use inside the Kivy language scope. For example, we set the source property of the Video class with the value of the _default_video constant (line 7).

We set up three properties for the Video class. The allow_stretch property (line 5) allows the video to stretch according to the screen size available. The color property (line 6...