本文整理汇总了Python中playlist.Playlist.play方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.play方法的具体用法?Python Playlist.play怎么用?Python Playlist.play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类playlist.Playlist
的用法示例。
在下文中一共展示了Playlist.play方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PluginInterface
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import play [as 别名]
class PluginInterface(plugin.DaemonPlugin):
"""
A plugin to start a screensaver when freevo has been inactive in a menu
for a long time. There are 4 basic types and one of the types has two
subtypes. The types are xscreensaver, ssr, fxd, and script. The fxd type
has two subtypes: one for movies and one for slideshows. The
xsccreensaver type will only work if you are using an Xserver.
Here is an example xscreensaver type. You must provide the paths to
your xscreensaver and xscreensaver-command programs.
| plugin.activate('freevoscreensaver', \
| args=('xscreensaver','/usr/bin/xscreensaver','/usr/bin/xscreensaver-command',))
Here is a script type example. Basically you write a start and stop
script you wish to use for a screensaver. This is a catchall for people
wanting a very specific saver with a specific config.
| plugin.activate('freevoscreensaver', \
| args=('script','/usr/local/bin/screensaverstart','/usr/local/bin/screensaverstop',))
Shown below is and example of a ssr type of screensaver. It takes an ssr
file which refers to a bunch of pictures and displays them repeatedly.
| plugin.activate('freevoscreensaver', args=('ssr','/usr/local/freevo_data/Images/blah.ssr',))
Here is an image type fxd. Very similar to the ssr but taking the fxd
playlist approach to showing the images. This way you can set random if
you want it for example.
| plugin.activate('freevoscreensaver', args=('fxd','/usr/local/freevo_data/Images/saver.fxd','image',))
A video version of the fxd type screensaver. It repeatedly shows a movie
in a loop with no sound.
| plugin.activate('freevoscreensaver', args=('fxd','/usr/local/freevo_data/Movies/saver.fxd','video',))
"""
def __init__(self, sstype, ssarg1, ssarg2=None):
plugin.DaemonPlugin.__init__(self)
self.plugin_name = 'SCREENSAVER'
self.event_listener = TRUE
self.poll_menu_only = TRUE
self.last_event = 0
self.screensaver_showing = FALSE
self.vitem = None
self.pl = None
self.menuw = None
self.poll_interval = config.SSAVER_POLL
self.saver_delay = config.SSAVER_DELAY
self.saver_type = sstype
self.arg1 = ssarg1
self.arg2 = ssarg2
self.osd = osd.get_singleton()
def config(self):
return [ ('SSAVER_DELAY', 300, '# of seconds to wait to start saver.'),
('SSAVER_POLL', 600, '# of seconds to wait between polling.') ]
def eventhandler(self, event=None, menuw=None, arg=None):
"""
eventhandler to handle the events. Always return false since we
are just a listener and really can't send back true.
"""
logger.log( 9, 'Saver saw %s', event.name)
if menuw:
self.menuw = menuw
if event.name == 'SCREENSAVER_START':
self.start_saver()
return FALSE
if event.name == 'SCREENSAVER_STOP' and self.screensaver_showing :
self.stop_saver()
return FALSE
# gotta ignore these or video screensavers shutoff before they begin
if event.name == 'VIDEO_START' or event.name == 'PLAY_START' or \
event.name == 'VIDEO_END' or event.name == 'PLAY_END':
return FALSE
if self.screensaver_showing :
self.stop_saver()
if plugin.isevent(event) != 'IDENTIFY_MEDIA':
self.last_event = time.time()
return FALSE
def poll(self):
logger.debug('Saver got polled %f', time.time())
if not self.screensaver_showing and (time.time() - self.last_event) > self.saver_delay :
rc.post_event(em.Event('SCREENSAVER_START'))
def start_saver (self):
logger.debug('start screensaver')
self.screensaver_showing = TRUE
if self.saver_type == 'xscreensaver':
os.system('%s -no-splash &' % self.arg1)
os.system('sleep 5 ; %s -activate' % self.arg2)
elif self.saver_type == 'script':
os.system('%s' % self.arg1)
elif self.saver_type == 'ssr':
self.pl = Playlist('ScreenSaver', playlist=self.arg1, display_type='image', repeat=True)
self.pl.play(menuw=self.menuw)
#.........这里部分代码省略.........