我使用Raspberry Pi来显示存储在文件夹中的图片的幻灯片。
但是,如果我在幻灯片放映期间将图片添加到文件夹,则新图片不会添加到幻灯片中。
如何在不中断幻灯片放映的情况下实现此行为?
答案 0 :(得分:0)
向Kodi添加自动启动脚本:当Kodi启动时它会自动运行幻灯片,如果文件夹内容发生变化,则会刷新幻灯片。
此脚本来自此答案:https://discourse.osmc.tv/t/refresh-picture-library/4867/13
# ~/.kodi/userdata/autoexec.py
# On Kodi startup, automatically start a Slideshow
# Refresh the slideshow if the content of the folder has been updated
import xbmc
from os import listdir
from time import sleep
xbmc.log('[refresh-slideshow] Starting')
monitor = xbmc.Monitor()
picfolder = "/PATH/TO/FOLDER"
# Generate list of images and start slideshow
l1 = listdir(picfolder)
xbmc.executebuiltin('SlideShow(%s)' %(picfolder))
xbmc.log('[refresh-slideshow] Slideshow started, monitoring')
# Wait for slideshow to start
sleep(5)
# Monitor during slideshow
while not monitor.abortRequested():
# If slideshow is still running, compare directory contents
if xbmc.getCondVisibility('Window.IsActive(slideshow)'):
l2 = listdir(picfolder)
# Restart slideshow if directory contents have changed
if l1 != l2:
xbmc.log('[refresh-slideshow] Folder contents changed, restarting slideshow')
xbmc.executebuiltin('SlideShow(%s)' %(picfolder))
l1 = l2
# If slideshow is no longer running (user has exited), exit script
else:
break
# Wait for 60 seconds, break if abort is requested
if monitor.waitForAbort(60):
break
xbmc.log('[refresh-slideshow] Finished, exiting')
答案 1 :(得分:0)
YTD_Special =
CALCULATE(
[Total],
FILTER(
ALL(FactTable),
FactTable[Date] >= DATE(YEAR(VALUES('Cut off date'[End of YTD])), 1, 1) &&
FactTable[Date] <= VALUES('Cut off date'[End of YTD])
)
)
threading
import xbmc, xbmcgui, threading
class MyMonitor(xbmc.Monitor):
def __init__(self, *args, **kwargs):
self.action = kwargs['action']
# do some action here.......
def onScreensaverDeactivated(self):
self.action()
class ImgVideoUpdate(threading.Thread):
def __init__(self, *args, **kwargs):
self._get_items = kwargs['data']
threading.Thread.__init__(self)
self.stop = False
self.check_update = 50 # set thread to update images(in seconds)
self.Monitor = MyMonitor(action=self._exit)
def run(self):
while (not self.Monitor.abortRequested()) and (not self.stop):
count = 0
while count != self.check_update: # check for new images every 50seconds
xbmc.sleep(200)
count += 1
if self.Monitor.abortRequested() or self.stop:
return
self._get_items()
类中初始化ImgVideoUpdate
ScreensaverWindow
注意:希望这会有所帮助。如果您遇到任何问题,请告诉我。