當前位置: 首頁>>代碼示例>>Python>>正文


Python Video.bind方法代碼示例

本文整理匯總了Python中kivy.uix.video.Video.bind方法的典型用法代碼示例。如果您正苦於以下問題:Python Video.bind方法的具體用法?Python Video.bind怎麽用?Python Video.bind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kivy.uix.video.Video的用法示例。


在下文中一共展示了Video.bind方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_video_unload

# 需要導入模塊: from kivy.uix.video import Video [as 別名]
# 或者: from kivy.uix.video.Video import bind [as 別名]
 def test_video_unload(self):
     # fix issue https://github.com/kivy/kivy/issues/2275
     # AttributeError: 'NoneType' object has no attribute 'texture'
     from kivy.uix.video import Video
     from kivy.clock import Clock
     from kivy.base import runTouchApp, stopTouchApp
     from os.path import join, dirname
     here = dirname(__file__)
     source = join(here, "..", "..", "examples", "widgets", "softboy.avi")
     video = Video(source=source, play=True)
     Clock.schedule_once(lambda x: stopTouchApp(), 1)
     def unload_video(video, position):
         if position > 0.01:
             video.unload()
             Clock.schedule_once(lambda x: stopTouchApp(), 0.1)
     video.bind(position=unload_video)
     runTouchApp(video)
開發者ID:4johndoe,項目名稱:kivy,代碼行數:19,代碼來源:test_video.py

示例2: VideoPlayer

# 需要導入模塊: from kivy.uix.video import Video [as 別名]
# 或者: from kivy.uix.video.Video import bind [as 別名]

#.........這裏部分代碼省略.........
        if not thumbnail:
            filename = self.source.rsplit('.', 1)
            thumbnail = filename[0] + '.png'
        self._image = VideoPlayerPreview(source=thumbnail, video=self)
        self.container.add_widget(self._image)

    def _load_annotations(self):
        if not self.container:
            return
        self._annotations_labels = []
        annotations = self.annotations
        if not annotations:
            filename = self.source.rsplit('.', 1)
            annotations = filename[0] + '.jsa'
        if exists(annotations):
            with open(annotations, 'r') as fd:
                self._annotations = load(fd)
        if self._annotations:
            for ann in self._annotations:
                self._annotations_labels.append(
                    VideoPlayerAnnotation(annotation=ann))

    def on_state(self, instance, value):
        if self._video is not None:
            self._video.state = value

    def _set_state(self, instance, value):
        self.state = value

    def _do_video_load(self, *largs):
        self._video = Video(source=self.source, state=self.state,
                            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'),
                         state=self._set_state)

    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:
            return
        self._video.volume = value

    def on_position(self, instance, value):
        labels = self._annotations_labels
        if not labels:
            return
        for label in labels:
            start = label.start
            duration = label.duration
            if start > value or (start + duration) < value:
                if label.parent:
                    label.parent.remove_widget(label)
            elif label.parent is None:
                self.container.add_widget(label)

    def seek(self, percent):
        '''Change the position to a percentage of the duration. Percentage must
        be a value between 0-1.

        .. warning::
開發者ID:Kovak,項目名稱:kivy,代碼行數:70,代碼來源:videoplayer.py

示例3: Karaotool

# 需要導入模塊: from kivy.uix.video import Video [as 別名]
# 或者: from kivy.uix.video.Video import bind [as 別名]
class Karaotool(FloatLayout):
    
    def __init__(self, **kwargs):
        super(Karaotool, self).__init__(**kwargs)
        
        self.source = kwargs.get('source', None)
        
        
        if self.source == None:
            self.selecttextfile = Popup(title='Select the lirycs')
            self.selecttextfile.content = BoxLayout(orientation='vertical')
            self.selecttextfile.content.add_widget(Button(text='Seleccionar archivo') )
            self.selecttextfile.content.add_widget(Button(text='Insertar texto') )
            self.selecttextfile.open()
            
        else:
        
            self.base_filename = os.path.splitext(self.source)[0]
           
            with open(self.base_filename + '.kot') as f:    #open karaotool text file
                self.content = f.readlines()
        
        self.line = 0;
        
        
        self.video = Video(source=self.source, state='play', allow_stretch=True, keep_ratio=False)
        
        self.video.bind(on_loaded=self.on_loaded)
        
        self.kar_english = LabelShadow(text='KARAOKELAND', 
                                    size_hint_y=None,
                                    color=(0,0,0,1),
                                    font_size=32 )
                                
                                
        self.add_widget(self.video)
        self.add_widget(self.kar_english)    
        
        #si existe el archivo con los tiempos
        if os.path.exists(self.base_filename + '.kos'):            
                
            self.kar_spanish = LabelShadow(text='KARAOKELAND ESP', 
                                        size_hint_y=1,
                                        color=(0,0,0,1),
                                        font_size=32 ) 
                                        
            self.add_widget(self.kar_spanish)
            
            self.fsteps = open(self.base_filename + '.kos') #steps
            self.steps = self.fsteps.readlines()
            
            try:
                self.efsteps = open(self.base_filename + '.koe') #subtitulos en lenguaje traducido
                self.esteps = self.efsteps.readlines()
            except:
                pass
            
            #Clock.schedule_interval(self.stepchecker, .1)
            
            
            self.video.bind(position=self.on_position)
            
            self.cursteptime = self.steps[self.line]
            
        else:
            
            self.btn_stepline = Button(text='Iniciar !', 
                                        #size_hint=(1,None),
                                        on_press=self.nextline
                                        )
            self.add_widget(self.btn_stepline, index=len(self.children) )
            
            
            #open for steps creation
            self.fsteps = open(self.base_filename + '.kos', 'w+')  #karaotool steps
            
            
    def on_loaded(self, w):
        print("Iniciando video")
        
    def on_position(self, w, val):
        
        if val > float(self.cursteptime):

            try:
                
                if hasattr(self, "old_kar_english"):
                    self.remove_widget(self.old_kar_english)
                    
                self.old_kar_english = self.kar_english
                    
                #subir titulo
                Animation(y=self.old_kar_english.y+50, opacity=.5, duration=.5).start(self.old_kar_english)
                #self.kar_english.y += 80
                
                        
                self.kar_english = LabelShadow(text=self.content[self.line], 
                                            size_hint_y=None,
                                            color=(0,0,0,1),
                                            font_size=32 )
#.........這裏部分代碼省略.........
開發者ID:oukiar,項目名稱:karaolang,代碼行數:103,代碼來源:main.py


注:本文中的kivy.uix.video.Video.bind方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。