Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- reimplemented pause feature in video and videoplayer

  • Loading branch information...
commit 95b626cdaee317bb6fded2e56cfd1237dfef93aa 1 parent ccd3f06
@aspidites aspidites authored
View
2  Makefile
@@ -56,5 +56,5 @@ distclean: clean
-git clean -dxf
theming:
- python -m kivy.atlas kivy/data/images/defaulttheme 512 kivy/tools/theming/defaulttheme/*.png
+ $(PYTHON) -m kivy.atlas kivy/data/images/defaulttheme 512 kivy/tools/theming/defaulttheme/*.png
View
2  kivy/data/images/defaulttheme.atlas
@@ -1 +1 @@
-{"defaulttheme-0.png": {"player-play-overlay": [306, 396, 117, 115], "spinner_pressed": [91, 124, 29, 37], "progressbar_background": [220, 137, 24, 24], "media-playback-pause": [448, 344, 48, 48], "tab_btn_pressed": [465, 178, 32, 32], "image-missing": [399, 344, 48, 48], "filechooser_selected": [187, 393, 118, 118], "audio-volume-muted": [350, 344, 48, 48], "sliderv_background": [473, 404, 37, 41], "tab": [332, 228, 96, 32], "close": [490, 491, 20, 20], "ring": [1, 326, 185, 185], "vkeyboard_key_down": [121, 129, 32, 32], "vkeyboard_background": [187, 328, 64, 64], "checkbox_off": [300, 178, 32, 32], "bubble_arrow": [148, 162, 16, 10], "player-background": [228, 222, 103, 103], "bubble": [424, 446, 65, 65], "spinner": [61, 124, 29, 37], "sliderh_background": [148, 173, 41, 37], "audio-volume-medium": [301, 344, 48, 48], "media-playback-start": [1, 162, 48, 48], "tab_btn": [432, 178, 32, 32], "bubble_btn_pressed": [267, 178, 32, 32], "tree_closed": [490, 470, 20, 20], "switch-background": [429, 228, 83, 32], "filechooser_file": [332, 261, 64, 64], "checkbox_radio_off": [366, 178, 32, 32], "vkeyboard_key_normal": [154, 129, 32, 32], "checkbox_radio_on": [399, 178, 32, 32], "checkbox_on": [333, 178, 32, 32], "tree_opened": [490, 449, 20, 20], "button_pressed": [31, 124, 29, 37], "media-playback-stop": [50, 162, 48, 48], "audio-volume-high": [424, 397, 48, 48], "audio-volume-low": [252, 344, 48, 48], "bubble_btn": [234, 178, 32, 32], "slider_cursor": [99, 162, 48, 48], "button": [1, 124, 29, 37], "progressbar": [187, 137, 32, 24], "switch-button": [190, 178, 43, 32], "filechooser_folder": [397, 261, 64, 64], "popup-background": [462, 271, 45, 54], "textinput_active": [1, 211, 114, 114], "textinput": [116, 214, 111, 111]}}
+{"defaulttheme-0.png": {"player-play-overlay": [306, 396, 117, 115], "spinner_pressed": [91, 124, 29, 37], "progressbar_background": [220, 137, 24, 24], "media-playback-pause": [448, 344, 48, 48], "tab_btn_pressed": [465, 178, 32, 32], "image-missing": [399, 344, 48, 48], "filechooser_selected": [187, 393, 118, 118], "audio-volume-muted": [350, 344, 48, 48], "sliderv_background": [473, 404, 37, 41], "tab": [332, 228, 96, 32], "close": [490, 491, 20, 20], "ring": [1, 326, 185, 185], "vkeyboard_key_down": [121, 129, 32, 32], "vkeyboard_background": [187, 328, 64, 64], "checkbox_off": [300, 178, 32, 32], "bubble_arrow": [148, 162, 16, 10], "player-background": [228, 222, 103, 103], "bubble": [424, 446, 65, 65], "spinner": [61, 124, 29, 37], "sliderh_background": [148, 173, 41, 37], "audio-volume-medium": [301, 344, 48, 48], "media-playback-start": [1, 162, 48, 48], "tab_btn": [432, 178, 32, 32], "bubble_btn_pressed": [267, 178, 32, 32], "tree_closed": [490, 470, 20, 20], "switch-background": [429, 228, 83, 32], "filechooser_file": [332, 261, 64, 64], "checkbox_radio_off": [366, 178, 32, 32], "vkeyboard_key_normal": [154, 129, 32, 32], "checkbox_radio_on": [399, 178, 32, 32], "checkbox_on": [333, 178, 32, 32], "tree_opened": [490, 449, 20, 20], "button_pressed": [31, 124, 29, 37], "media-playback-stop": [50, 162, 48, 48], "audio-volume-high": [424, 397, 48, 48], "audio-volume-low": [252, 344, 48, 48], "bubble_btn": [234, 178, 32, 32], "slider_cursor": [99, 162, 48, 48], "button": [1, 124, 29, 37], "progressbar": [187, 137, 32, 24], "switch-button": [190, 178, 43, 32], "filechooser_folder": [397, 261, 64, 64], "popup-background": [462, 271, 45, 54], "textinput_active": [1, 211, 114, 114], "textinput": [116, 214, 111, 111]}}
View
8 kivy/data/style.kv
@@ -714,11 +714,17 @@
size_hint_y: None
height: 44
+ VideoPlayerStop:
+ size_hint_x: None
+ video: root
+ width: 44
+ source: root.image_stop
+
VideoPlayerPlayPause:
size_hint_x: None
video: root
width: 44
- source: root.image_play if not root.play else root.image_pause
+ source: root.image_pause if root.state == 'play' else root.image_play
VideoPlayerVolume:
video: root
View
1  kivy/factory_registers.py
@@ -119,6 +119,7 @@
r('Video', module='kivy.uix.video')
r('VideoPlayer', module='kivy.uix.videoplayer')
r('VideoPlayerVolume', module='kivy.uix.videoplayer')
+r('VideoPlayerStop', module='kivy.uix.videoplayer')
r('VideoPlayerPlayPause', module='kivy.uix.videoplayer')
r('VideoPlayerProgressBar', module='kivy.uix.videoplayer')
r('VKeyboard', module='kivy.uix.vkeyboard')
View
7 kivy/uix/video.py
@@ -29,8 +29,8 @@ def on_duration_change(instance, value):
from kivy.uix.image import Image
from kivy.core.video import Video as CoreVideo
from kivy.resources import resource_find
-from kivy.properties import (BooleanProperty, NumericProperty, ObjectProperty
- OptionProperty)
+from kivy.properties import (BooleanProperty, NumericProperty, ObjectProperty,
+ OptionProperty)
class Video(Image):
@@ -177,8 +177,9 @@ def on_state(self, instance, value):
elif value == 'pause':
self._video.pause()
else:
- #self._video.position = 0
self._video.stop()
+ self._video.position = 0
+ self._video.eos = False
def _on_video_frame(self, *largs):
self.duration = self._video.duration
View
47 kivy/uix/videoplayer.py
@@ -62,7 +62,7 @@
from json import load
from os.path import exists
from kivy.properties import ObjectProperty, StringProperty, BooleanProperty, \
- NumericProperty, DictProperty
+ NumericProperty, DictProperty, OptionProperty
from kivy.animation import Animation
from kivy.uix.gridlayout import GridLayout
from kivy.uix.floatlayout import FloatLayout
@@ -112,6 +112,7 @@ class VideoPlayerPlayPause(Image):
video = ObjectProperty(None)
def on_touch_down(self, touch):
+ '''.. versionchanged:: 1.4.0'''
if self.collide_point(*touch.pos):
if self.video.state == 'play':
self.video.state = 'pause'
@@ -123,9 +124,10 @@ def on_touch_down(self, touch):
class VideoPlayerStop(Image):
video = ObjectProperty(None)
- def on_touch_down(sel, touch):
+ def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
self.video.state = 'stop'
+ self.video.position = 0
return True
@@ -207,7 +209,7 @@ def _update_bubble(self, *l):
self.bubble.y = self.top
def _showhide_bubble(self, instance, value):
- if value:
+ if value == 'play':
self._hide_bubble()
else:
self._show_bubble()
@@ -298,20 +300,37 @@ class VideoPlayer(GridLayout):
1.
'''
+ state = OptionProperty('play', options=('play', 'pause', 'stop'))
+ '''String, indicates whether to play, pause, or stop the video::
+
+ # start playing the video at creation
+ video = Video(source='movie.mkv', state='play')
+
+ # create the video, and start later
+ video = Video(source='movie.mkv')
+ # and later
+ video.state = 'play'
+
+ :data:`state` is a :class:`~kivy.properties.OptionProperty`, default to
+ 'play'.
+ '''
+
play = BooleanProperty(False)
'''Boolean, indicates if the video is playing.
You can start/stop the video by setting this property::
# start playing the video at creation
- video = VideoPlayer(source='movie.mkv', play=True)
+ video = Video(source='movie.mkv', play=True)
# create the video, and start later
- video = VideoPlayer(source='movie.mkv')
+ video = Video(source='movie.mkv')
# and later
video.play = True
:data:`play` is a :class:`~kivy.properties.BooleanProperty`, default to
False.
+ .. deprecated:: 1.4.0
+ Use `state` instead.
'''
image_overlay_play = StringProperty(
@@ -332,7 +351,13 @@ class VideoPlayer(GridLayout):
'atlas://data/images/defaulttheme/media-playback-start')
'''Image filename used for the "Play" button.
- :data:`image_loading` a :class:`~kivy.properties.StringProperty`
+ :data:`image_play` a :class:`~kivy.properties.StringProperty`
+ '''
+
+ image_stop = StringProperty(
+ 'atlas://data/images/defaulttheme/media-playback-stop')
+ '''Image filename used for the "Stop" button.
+ :data:`image_stop` a :class:`~kivy.properties.StringProperty`
'''
image_pause = StringProperty(
@@ -452,16 +477,20 @@ def _load_annotations(self):
self._annotations_labels.append(
VideoPlayerAnnotation(annotation=ann))
- def on_play(self, instance, value):
+ def on_state(self, instance, value):
if self._video is None:
- self._video = Video(source=self.source, play=True,
+ self._video = Video(source=self.source, state='play',
volume=self.volume, pos_hint={'x': 0, 'y': 0},
**self.options)
self._video.bind(texture=self._play_started,
duration=self.setter('duration'),
position=self.setter('position'),
volume=self.setter('volume'))
- self._video.play = value
+ self._video.state = value
+
+ def on_play(self, instance, value):
+ value = 'play' if value else 'stop'
+ return self.on_state(instance, value)
def on_volume(self, instance, value):
if not self._video:
Please sign in to comment.
Something went wrong with that request. Please try again.