Full screen kivy python

Video player¶

The video player widget can be used to play video and let the user control the play/pausing, volume and position. The widget cannot be customized much because of the complex assembly of numerous base widgets.

_images/videoplayer.jpg

Annotations¶

If you want to display text at a specific time and for a certain duration, consider annotations. An annotation file has a “.jsa” extension. The player will automatically load the associated annotation file if it exists.

An annotation file is JSON-based, providing a list of label dictionary items. The key and value must match one of the VideoPlayerAnnotation items. For example, here is a short version of a jsa file that you can find in examples/widgets/cityCC0.jsa :

[ "start": 0, "duration": 2, "text": "This is an example of annotation">, "start": 2, "duration": 2, "bgcolor": [0.5, 0.2, 0.4, 0.5], "text": "You can change the background color"> ] 

For our cityCC0.mpg example, the result will be:

_images/videoplayer-annotation.jpg

If you want to experiment with annotation files, test with:

python -m kivy.uix.videoplayer examples/widgets/cityCC0.mpg 

Fullscreen¶

The video player can play the video in fullscreen, if VideoPlayer.allow_fullscreen is activated by a double-tap on the video. By default, if the video is smaller than the Window, it will be not stretched.

You can allow stretching by passing custom options to a VideoPlayer instance:

player = VideoPlayer(source='myvideo.avi', state='play', options='fit_mode': 'contain'>) 

End-of-stream behavior¶

You can specify what happens when the video has finished playing by passing an eos (end of stream) directive to the underlying VideoBase class. eos can be one of ‘stop’, ‘pause’ or ‘loop’ and defaults to ‘stop’. For example, in order to loop the video:

player = VideoPlayer(source='myvideo.avi', state='play', options='eos': 'loop'>) 

The eos property of the VideoBase class is a string specifying the end-of-stream behavior. This property differs from the eos properties of the VideoPlayer and Video classes, whose eos property is simply a boolean indicating that the end of the file has been reached.

VideoPlayer class. See module documentation for more information.

By default, you can double-tap on the video to make it fullscreen. Set this property to False to prevent this behavior.

If set, it will be used for reading annotations box.

Duration of the video. The duration defaults to -1 and is set to the real duration when the video is loaded.

Switch to fullscreen view. This should be used with care. When activated, the widget will remove itself from its parent, remove all children from the window and will add itself to it. When fullscreen is unset, all the previous children are restored and the widget is restored to its previous parent.

The re-add operation doesn’t care about the index position of its children within the parent.

fullscreen is a BooleanProperty and defaults to False.

Image filename used when the video is loading.

image_loading is a StringProperty and defaults to ‘data/images/image-loading.zip’.

Image filename used to show a “play” overlay when the video has not yet started.

image_overlay_play is a StringProperty and defaults to ‘atlas://data/images/defaulttheme/player-play-overlay’.

Image filename used for the “Pause” button.

image_pause is a StringProperty and defaults to ‘atlas://data/images/defaulttheme/media-playback-pause’.

Image filename used for the “Play” button.

image_play is a StringProperty and defaults to ‘atlas://data/images/defaulttheme/media-playback-start’.

Image filename used for the “Stop” button.

image_stop is a StringProperty and defaults to ‘atlas://data/images/defaulttheme/media-playback-stop’.

Image filename used for the volume icon when the volume is high.

image_volumehigh is a StringProperty and defaults to ‘atlas://data/images/defaulttheme/audio-volume-high’.

Image filename used for the volume icon when the volume is low.

image_volumelow is a StringProperty and defaults to ‘atlas://data/images/defaulttheme/audio-volume-low’.

Image filename used for the volume icon when the volume is medium.

image_volumemedium is a StringProperty and defaults to ‘atlas://data/images/defaulttheme/audio-volume-medium’.

Image filename used for the volume icon when the volume is muted.

image_volumemuted is a StringProperty and defaults to ‘atlas://data/images/defaulttheme/audio-volume-muted’.

Receive a touch down event.

Parameters : touch : MotionEvent class

Touch received. The touch is in parent coordinates. See relativelayout for a discussion on coordinate systems.

bool If True, the dispatching of the touch event will stop. If False, the event will continue to be dispatched to the rest of the widget tree.

Optional parameters can be passed to a Video instance with this property.

Deprecated since version 1.4.0: Use state instead.

Boolean, indicates whether the video is playing or not. You can start/stop the video by setting this property:

# start playing the video at creation video = VideoPlayer(source='movie.mkv', play=True) # create the video, and start later video = VideoPlayer(source='movie.mkv') # and later video.play = True 

play is a BooleanProperty and defaults to False.

Position of the video between 0 and duration . The position defaults to -1 and is set to the real position when the video is loaded.

seek ( percent , precise = True ) [source] ¶ Change the position to a percentage (strictly, a proportion)

Parameters : percent : float or int

Position to seek as a proportion of total duration, must be between 0-1.

precise : bool, defaults to True

Precise seeking is slower, but seeks to exact requested percent.

Calling seek() before the video is loaded has no effect.

Changed in version 1.10.1: The precise keyword argument has been added.

Source of the video to read.

String, indicates whether to play, pause, or stop the video:

# start playing the video at creation video = VideoPlayer(source='movie.mkv', state='play') # create the video, and start later video = VideoPlayer(source='movie.mkv') # and later video.state = 'play' 

state is an OptionProperty and defaults to ‘stop’.

Thumbnail of the video to show. If None, VideoPlayer will try to find the thumbnail from the source + ‘.png’.

Volume of the video in the range 0-1. 1 means full volume and 0 means mute.

class kivy.uix.videoplayer. VideoPlayerAnnotation ( ** kwargs ) [source] ¶

Annotation class used for creating annotation labels.

Additional keys are available:

  • bgcolor: [r, g, b, a] — background color of the text box
  • bgsource: ‘filename’ — background image used for the background text box
  • border: (n, e, s, w) — border used for the background image

Duration of the annotation.

Start time of the annotation.

Источник

Issue setting Kivy to fullscreen

Fadi Abu Raid 773

Answering lately For those who are still struggling to figure out how to have the true fullscreen. I have managed to get the rid of those black strip by adding Config.set(‘graphics’,’window_state’_’maximized’ just after the fullscreen call. the whole code looks like

from kivy.config import Config # . if __name__ == "__main__": Config.set('graphics', 'fullscreen', 'auto') Config.set('graphics', 'window_state', 'maximized') Config.write() YourApp().run() 
Config.set('graphics', 'fullscreen', 'auto') 

Craynic Cai 348

I just want to complement:

from kivy.core.window import Window Window.size = (1366, 768) Window.fullscreen = True 

João Paulo 5920

I managed to do it as follows:

from kivy.core.window import Window Window.maximize() 
from kivy.core.window import Window Window.fullscreen = True 

Do this before you App.run() method, and it should switch to fullscreen mode.

Had a similar problem. Using the ‘auto’ option got rid of the bands for me.

Quote from Kivy Configuration Object documentation: «If set to auto, your current display’s resolution will be used instead. This is most likely what you want.«

Doug Williams 151

  • Issue with Web Scraping in Python: returning empty values
  • Setting default value of a drop down menu in nuke with python
  • Arguments and input in classes issue
  • nuke.File_Knob() class isn’t setting filenames in other nodes
  • Issue with Combining LSTM and CNN? (Python, Keras)
  • Python: CX_Freeze issue after build
  • Debugging htcondor issue running python script
  • Python kivy | Arabic text on Label text
  • Kivy copy button text to clipboard
  • Python Kivy Is Printing numbers while importing it
  • Python / Kivy Initial Variable Assignment
  • Import issue while mocking REST in py.test
  • kivy collide_point behavior not as expected
  • DragBehavior only work for the first time with on_touch_up in Kivy
  • Kivy: Kivy launcher fall down
  • Python’s Kivy FileBrowser doesn’t index the files properly
  • Cant exit fullscreen on tkinter window python
  • Issue with saving a modified list with pickle
  • Kivy : how to add vertical scrollbar in boxlayout
  • ESPN.com Python web scraping issue
  • For loop with json.loads issue
  • 800mb apk file using buildozer kivy
  • Kivy service stops when app is closed
  • Kivy Gaussian blur
  • Issue trying to implement stacked LSTM layers with Keras
  • Kivy update matplotlib graph with kivy.clock
  • python click app is failing with indication of «missing argument» but cannot locate the issue
  • Update value in Kivy (Python) widget
  • Python / Kivy — Changing Screen with phone screen orientation (android)
  • Pygame not returning mouse position in fullscreen mode
  • Odoo 8, get error ‘datestyle’ setting
  • pygame issue with placing the image on screen
  • Python install issue
  • Does setting a variable to empty list in Python reset the variable?
  • Python API Ansible verbosity setting
  • Setting a static outbound / source IP address on Google Compute Engine
  • Issue with Python modulo
  • re.compile() python: issue in getting particular pattern
  • Class attribute of an HTML element issue
  • bqplot: performance issue

More Query from same tag

  • minimalistic python service layer
  • How to use a for loop to calculate and plot multiple lines on one graph
  • How to stay logged in by crawler written in python?
  • Why does skimage.imread() not return RGB values for my bmp?
  • Creating multilabel HDF5 file for caffe
  • Data is not being scraped correctly
  • Python: Replace non ascii characters in a list of strings
  • How to run trained Yolov3 model with using GPU
  • How to print pdf file without opening PDF viewer print prompt in python
  • Unable to submit drupal menu add form using Selenium
  • Getting key corresponding to a max value in a dictionary of lists
  • Jinja2 filters: from a dictionary list to a json object list
  • How to know the trained model is correct?
  • how do I match a specific number into number set efficiently?
  • Undefined symbol «afinfo» when importing python-iptables package «iptc»
  • Git Commit-Msg in Python. Getting an EOF Error
  • How to change BOTH seaborn heatmap and colorbar
  • Can not get first node in the visited nodes of prolog graph traversal
  • How to remove special characters in json data python
  • Need last month’s data with additional 10 days of data from previous month and 3 days of data from the current month
  • Kivy module in python
  • Extract sound files from a powerpoint
  • How to access QString for QGIS-2.14 in PyQt4
  • How insert a line in a sorted file?
  • Can’t update Matplotlib using pip under Python 3.6
  • cx_Oracle.STRING to Python string conversion
  • Basic cluster computing and data management with Ray
  • Methods with keywords from the instances’s attributes
  • One to One LSTM
  • Get Scrapy spider to crawl depth first in order
  • How do I show random images from a folder on Tkinter?
  • classifier : axis 1 is out of bounds for array of dimension 1
  • Pass String from JS to Python Selenium
  • pygraphviz: How to get same edges connected on different ports without iterating?
  • How do I trap a popup in Selenium 2 python

Источник

Читайте также:  Register
Оцените статью