Folder starts playing in background

Hi,
I have a Python script that lists a couple of directories and finds out if they contain photos or videos. When the user pushes a button I connected to the Pi 3 for this purpose, the scripts starts playing the next folder. This worked beautifully, but now some folders start playing in the background, so all I see is the menu. When I hit return or tab, I can see the video playing. The weird thing is, that this only happens with folders that have multiple videos in them. Here is part of my script:

Code:
    try:

        gekozenKanaal_pad  = directorieslist[keuze][0]
        gekozenKanaal_type  = directorieslist[keuze][1]

        if gekozenKanaal_type == "video":

            xbmc.log(gekozenKanaal_pad + ' openen...')

            xbmc.executebuiltin(''.join(["Video\'s",'Notification("' + basename(normpath(gekozenKanaal_pad)) + '",7000)']))
            xbmc.executebuiltin('xbmc.PlayMedia("' + gekozenKanaal_pad + '","isdir")')
            xbmc.executebuiltin('xbmc.PlayerControl(repeatall)')
            xbmc.executebuiltin("Action(Fullscreen)")
            return

        elif gekozenKanaal_type == "photo":

            xbmc.log(gekozenKanaal_pad + ' openen...')

            xbmc.executebuiltin(''.join(['Notification("Foto\'s","' + basename(normpath(gekozenKanaal_pad)) + '",7000)']))
            xbmc.executebuiltin('xbmc.SlideShow("' + gekozenKanaal_pad + '", [random])')
            xbmc.executebuiltin("Action(Fullscreen)")
            return

    except IndexError:

        xbmc.log('Niet gelukt kanaal ' + str(keuze) + ' te openen')

        xbmc.executebuiltin(''.join(['Notification("Testbeeld","Kanaal ' + str(keuze) + ' is niet beschikbaar.",7000)']))

I changed a couple of things last two weeks (had to change the code a little after changing from a rotary switch to a momentary switch for instance), so I can’t really tell when this started or what caused it. Works like this with both OSMC skin and Confluence.

Do you have any idea why this happens, and what I could do to solve it? Thanks!