当前位置: 首页>>代码示例>>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;未经允许,请勿转载。