Different Slideshow Instances? (Builtins.cpp / GUIWindowPictures.cpp)
#1
I've made an autoexec.py to run a Slideshow from a directory with picture+video.
This was my code

Code:
import xbmc
xbmc.executebuiltin('XBMC.Slideshow('/storage/pictures/slideshow/')')

However videos weren't played (!), but if I did

Code:
import xbmc
xbmc.executebuiltin("ActivateWindow(Pictures,/storage/pictures/slideshow/)")
xbmc.executebuiltin("Action(Play)")

it worked.
I wonder if there's a better way to do it without reproducing the user flow to start the slideshow, and trying to evade the Pictures Menu GUI.

Looking at the code I see that Slideshow is called differently in both.

https://github.com/xbmc/xbmc/blob/master...s.cpp#L849
https://github.com/xbmc/xbmc/blob/master...s.cpp#L430

If I'm not wrong, it should say CGUIWindowSlideShow instead of CGUIWindow in Builtins.cpp
Reply
#2
CGUIWindow is ok there because OnMessage() is a virtual method so pWindow->OnMessage(msg) will actually result in a call to CGUIWindowSlideShow.

The actual difference is the implementation at https://github.com/xbmc/xbmc/blob/master...s.cpp#L428 and at https://github.com/xbmc/xbmc/blob/master...w.cpp#L951. The one originating from builtin doesn't set the extensions and therefore the slideshow will only look for files with extensions matching pictures (jpg, png, ...).

It might be fixable by changing https://github.com/xbmc/xbmc/blob/master....cpp#L1266 to use the same logic as https://github.com/xbmc/xbmc/blob/master...es.cpp#L76 to determine the list of possible extensions.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#3
thanks for clarifying! I see the difference.
Reply
#4
For example, I'm using Kodi to play Slideshow (pictures and video) from startup, and need to check if media has changed and reload Slideshow. I'm trying to avoid showing the menu, so I thought if Slideshow Builtin would handle videos, I would be able to do this in my autoexec.py,

Code:
import xbmc
from time import sleep
from os import listdir

minutes = 5
mediafolder = "/storage/pictures/slideshow"

l1 = []
while 1:
    l2 = listdir(mediafolder)
    if (l1 != l2):
        xbmc.executebuiltin('XBMC.Slideshow(mediafolder)')
        l1 = l2
    sleep(minutes * 60)

However, I'm not sure an infinite loop inside the autoexec.py script would be a great idea.
Do you think I could try something else?
Reply
#5
Maybe a service addon which at least checks whether it should stop or not?
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#6
The Slideshow should never stop, visually.

So, considering extensions are set for the Slideshow Builtin in order to play videos, do you think my autoexec.py script is stable enough to run 24/7? I mean, I'm worried about that infinite loop and deadlocks or something. Plus, autoexec.py was intented to be a script that runs something at startup and finishes its process.
Reply
#7
Yes with a service addon (which is constantly running in the background) you can do exactly the same as you are doing now but you get to check a boolean value which tells you when Kodi is shutting down so you can terminate your script gracefully.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#8
Ok, I'll see if I can read tutorials about how to write Service Addons. I wish someone else would be interested in it, as it seems to be a nice feature and I hardly understands my autoexec.py script.
Would you recommend me something to read?
Reply
#9
Unfortuantely I don't have any clue about python myself, I only know what possibilities Kodi offers.

I'll try to look into the extension issue with the slideshow.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#10
Thanks! I guess the only way to start a Slideshow inside an Addon or Script is by using the Builtin Slideshow function...

Meanwhile, I've started reading about Service Addons here, and I though I could use a Monitor() instance to exit gracefully. However, I'm still not sure if I could think autoexec.py as a Service Addon.

Code:
import xbmc
import time
from os import listdir

minutes = 5
mediafolder = "/storage/pictures/slideshow"

monitor = xbmc.Monitor()

templist = []

while True:
    # Sleep/wait for abort for 5 minutes
    if monitor.waitForAbort(minutes * 60):
        # Abort was requested while waiting. We should exit
        break

    # Read media folder for changes
    newlist = listdir(mediafolder)

    if (templist != newlist):
        # If there are changes, execute Slideshow again (without videos currently)
        xbmc.executebuiltin('XBMC.Slideshow(mediafolder)')

        # Save list
        templist = newlist
Reply
#11
See PR6350.

autoexec.py is a different concept and has nothing to do with addons. If you write a service addon you need to install it in Kodi and then it will automatically be started after Kodi has been started.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#12
Man, thanks. Really thanks ! Smile I wish it helps another people, not only me. I wasn't able to do it. I hope the Kodi developer's community would consider it. It does have sense as you explained it.

I know autoexec.py has nothing to do with addons, but I was wondering if it could work as it. Anyway, I opened a new thread on the Python Add-on Development forum on that.
Reply

Logout Mark Read Team Forum Stats Members Help
Different Slideshow Instances? (Builtins.cpp / GUIWindowPictures.cpp)0