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


Python Video.unload方法代碼示例

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


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

示例1: MediaAction

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

#.........這裏部分代碼省略.........
            if self.settings.get('media_loop') == 'yes':
                self.audio.loop = True

            self.audio.volume = 0
        
        elif self.media['type'] == 'image':
            self.image = AsyncImage(source = self.sourceurl)
            self.image.allow_stretch = True

            if self.settings.get('media_preserve_aspect') == 'no':
                self.image.keep_ratio = False
            
            self.image.opacity = 0
            
    def get_current_widget_index(self):
        if self.shown:
            if self.video:
                return self.client.source.children.index(self.video)

            elif self.image:
                return self.client.source.children.index(self.image)
            
        return None
        
    def get_media_time(self):
        diff = self.client.time.now() - float(self.action['time'])

        if diff > 0 and self.settings.get('media_loop') == 'yes':
            diff = diff % self.duration
        
        if diff > self.duration: diff = self.duration
        
        return diff
    
    def get_seek_percent(self, time):
        if time == 0: return 0
        else: return 1 / (self.media['duration'] / time)
        
    def media_sync(self, dt = None):
        if self.shown and not self.media['type'] == 'image':
            if self.video: pos = self.video.position
            elif self.audio: pos = self.audio.get_pos()
                
            if self.to_sync and abs(self.get_media_time() - pos) > media_sync_tolerance:
                if self.settings.get('media_loop') == 'no' and pos > self.duration:
                    if self.video: self.to_sync.state = 'stop'
                    elif self.audio: self.audio.stop()
                else:
                    self.to_sync.seek(self.get_seek_percent(self.get_media_time()))
            
            # Automatic sync disabled until Kivy playback rate change is implemented
            #Clock.schedule_once(self.media_sync, media_sync_interval)
        
    def out_animation_end(self):
        self.shown = False
        
        if self.video:
            self.video.state = 'pause'
            self.client.remove_widget(self.video)
            self.video.unload()

        elif self.audio:
            self.audio.stop()
            self.audio.unload()

        elif self.image:
            self.client.remove_widget(self.image)
        
    def check_ready(self):
        if self.get_media_time() >= 0:
            if self.video and self.video.loaded:
                return True

            elif self.audio:
                return True
                
            elif self.image and self.image._coreimage.loaded:
                return True
        
    def on_show(self, fade_length):
        self.media_sync()

        if self.video:
            self.video.state = 'play'
            self.client.add_layer_widget(self.video, self.layer)
            self.add_anim_widget(self.video, 'opacity', 1, 0)
            self.add_anim_widget(self.video, 'volume', self.max_volume * self.minion_volume, 0)
            
        elif self.audio:
            self.audio.play()
            self.add_anim_widget(self.audio, 'volume', self.max_volume * self.minion_volume, 0)
            
        elif self.image:
            self.client.add_layer_widget(self.image, self.layer)
            self.add_anim_widget(self.image, 'opacity', 1, 0)
              
        self.do_in_animation(fade_length)
        
    def on_hide(self, fade_length):
        self.do_out_animation(fade_length)
開發者ID:cedarsuite,項目名稱:displayminion,代碼行數:104,代碼來源:MediaAction.py


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