I am running the OSMC on a raspberry pi. I have set up file sharing using smb and the source of my pictures are on a shared folder in my LAN.
As I run the slideshow, I realised that pictures added into the shared folder does not appear on the slideshow. How do I scan and refresh the library so that the slideshows include the latest added pictures while running?
With the Watchdog add on I can refresh the folder as I exit the slideshow, but I would like the slideshow to update in real time. Is this possible?
Starting the script from the favourites menu runs a slideshow of images from the folder. The code checks for changes in the directory every minute and restarts the slideshow if anything changes, effectively functioning as an âauto refreshâ. This works as expected.
Unfortunately I havenât found a way to stop the script from running. If you exit the slideshow, the Python code keeps running in the background and will restart the slideshow if the folder contents change. Not ideal.
Perhaps the above is useful for someone.
If anyone can suggest a straightforward way to have the script stop running once the slideshow has ended Iâd appreciate any pointers. Iâm sure itâs possible, but it is probably beyond my skill levelâŚ
Edit for future reference: Perhaps look at using xbmc.getCondVisibility(Slideshow.IsActive) ?
SlideShow.IsActive is absolutely the way to check whether the slideshow is running. You should also check to see if Kodi is shutting down as otherwise your script can block its exit. Something like the following (and totally untested):
import xbmc
from os import listdir
monitor = xbmc.Monitor()
picfolder = "/home/osmc/images"
l1 = listdir(picfolder)
while not monitor.abortRequested():
if xbmc.getCondVisibility('Slideshow.IsActive'):
l2 = listdir(picfolder)
if l1 != l2:
xbmc.executebuiltin('SlideShow(%s)' %(picfolder))
l1 = l2
if monitor.waitForAbort(60):
# Abort was requested while waiting for 60 seconds. We should exit
break
If I start a slideshow from within my Python script, then enter a checking loop to see if it is still running, then the value of xbmc.getCondVisibility('Slideshow.IsActive') is always1 - even if I subsequently stop the slideshow from within Kodi using the remote control.
Form this and other testing, it appears (to me anyway) that the value of Slideshow.IsActive gets set to 1 when a slideshow is started, but doesnât get reset to 0 when it is terminated. I am a novice at this, so I may be wrong. Sounds like I now need input from the Kodi teamâŚ
Whilst ActionA is absolutely correct that this is a Kodi issue and needs to be reported on their forums so it can be fixed, whilst youâre waiting a fix (and you really REALLY need to report this to those who are responsible for fixing it) you could potentially use Window.IsActive(slideshow) until your report results in a fix.
FWIW, hereâs my code. It appears to work as expected, from a local folder anyway.
import xbmc
from os import listdir
from time import sleep
xbmc.log('[refresh-slideshow] Starting')
monitor = xbmc.Monitor()
picfolder = "/home/osmc/images"
# 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')
Iâm having the same issue and thanks to you guys I could solve it. So itâs restarting the slideshow and showing new pics.
However, I have one thing that could be improved and I donât know how to do it. As the slideshow gets restarted, itâll show pictures again and again, even if they were shown a couple of seconds before. Shuffle mode helps a bit but some pics are shown more often than others.
Do you have an idea how to âprioritizeâ pics that werenât shown yet, so that they get shown first?