Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
How can I load a playlist of pictures by JSON-RPC API and run it?
#1
Hi, I'm able to upload a picture, can I upload multiple pictures?
I've tried this this but I don't see, maybe I've to add a command to start playing?

Code:
return {
    payload:
    {
        "method": "Playlist.Add",
        "args": {
            "item":
                [{
                    "file": "http://192.168.101.100/1.jpg"
                },
                { "file": "http://192.168.101.100/2.jpg"
                },
                {
                    "file": "http://192.168.101.100/3.jpg"
                }],
            "playlistid": 1
    }
       
}};
Reply
#2
It looks it's not possible to create playlists with pictures on Kodi,
but, if I load a folder, it will show me all pictures inside with slideshow (pressing space).

So there is any way to load a folder by API? I've tried to load multiple files on player but it's not possible, then a folder but I got an error too:
Code:
return {
    payload:
    {
        "method": "Player.Open",
        "args": {
            "item":
                {
                    "folder": "smb://192.168.101.100/log"
                }
        }
}};
Reply
#3
You can add pictures to a playlist and play them for sure. The current iOS Remote App version does exactly that. For this you need to set playlistid to 2 (the id for the picture player). And you first need to create the playlist via Playlist.Add and then start its playback via Player.Open with parameters playlistid/pos.

But: This has a downside. For large amount of pictures (tested with tens of thousands of pictures) this is quite slow compared to just starting a slideshow for a complete folder. For this you need to look for Player.Open with the parameters path/random/recursive.
Reply
#4
I've found the way, it's not folder but directory to use.
I'm a bit disconcerted that to solve my problems I've to search on google, forums and external stuff, instead of find some simple guides with examples on Kodi.

Code:
return {
    payload:
    {
        "method": "Player.Open",
        "args": {
            "item":
                {
                    "directory": "smb://192.168.101.100/log"
                }
        }
}};

if may somebody cares, if I start a video while slideshow is running, it goes in background and when the next slide (picture) appearing the background video is interrupted with the popup error. This is a bug of Kodi
Reply
#5
Doing it like that causes issues when playing a folder with pictures and videos mixed. In this case the pictures and videos are both added to the video playlist, and when attempting to play it the pictures are skipped until a video is reached. On the other side using Playlist.Add with playlistid 2 just will add the pictures and skip videos in the same folder. Only using Player.Open with path/random/recursive works properly. I was just going through this myself.

Edit: btw, you are aware of https://kodi.wiki/view/JSON-RPC_API/v13 ?
Reply
#6
thanks for replying, to avoid any possible confusion I?m just talking about images, open a image only directory will produce the same order, even if the random button is activated, I suppose it is a bug.
No playlist, just open the folder as described with code before, and I noticed that start slideshow from inferface directly also has no randomize, so it's not working at all Sad
Do you now another way to give a random order? How JSON-RPC_API/v13  anc help me in such issue? THere is something I can send to activate the random order while they are playng?

Telling you the truth, I don't like this guide, I can't figere out how can I use the code they wrote, it's different from the one that I use and works, I don't understand nothing there, sincerely. More, I've found there command Input.Action which doesn't work, while Input.ExecuteAction (which is not described) works.
Reply
#7
(2024-07-10, 17:13)GiovanniG11 Wrote: thanks for replying, to avoid any possible confusion I?m just talking about images, open a image only directory will produce the same order, even if the random button is activated, I suppose it is a bug.
No playlist, just open the folder as described with code before, and I noticed that start slideshow from inferface directly also has no randomize, so it's not working at all Sad
Do you now another way to give a random order? How JSON-RPC_API/v13  anc help me in such issue? THere is something I can send to activate the random order while they are playng?

Telling you the truth, I don't like this guide, I can't figere out how can I use the code they wrote, it's different from the one that I use and works, I don't understand nothing there, sincerely. More, I've found there command Input.Action which doesn't work, while Input.ExecuteAction (which is not described) works.

In the Mezzmo Kodi addon I wrote my own slideshow viewer which can handle manual slides, timed slowshows and more.  Here's the code.   It creates a background window to catch keystrokes for forward, back, pause, resume etc.  Loading the slides themselves is in lines 849-905 for the timed slideshow  It loads a list of images in this case a list of URLs called piclist) and directly displays the images.  It doesn't use JSON RPC. 

I did previously use JSON RPC to load the list and cycle through the images.  Here's the code:


JSON RPC slideshow:
def ShowSlides(piclist, slidetime, ssmode):                      # Slidehow viewer

    try:    
        kbmonitor = KodiMonitor()                   
        slideIdx = 0   
        #xbmc.log('Mezzmo picture url is: ' + str(playitem) , xbmc.LOGINFO)

        xbmc.executebuiltin('Dialog.Close(all, true)')
        while slideIdx < len(piclist):           
            if kbmonitor.flag == 'play':  
                playitem = picURL(piclist[slideIdx]['url'])      # Verify proper file name
                #xbmc.log('Mezzmo picture index is: ' + str(playitem) , xbmc.LOGINFO)
                json_query = xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Player.Open",        \
                "params":{"item":{"file":%s }},"id":1}' % (playitem))           
                #xbmc.log('Mezzmo picture dictionary list  is: ' + str(piclist) , xbmc.LOGINFO)
                slideIdx += 1
            xbmc.sleep(slidetime * 1000)
            if slideIdx == len(piclist) and ssmode == 'yes':     # Continuous slideshow
                slideIdx = 0
            #xbmc.log('Mezzmo monitor data is: ' + (kbmonitor.flag) , xbmc.LOGINFO)
            if kbmonitor.flag == 'stop':
                del kbmonitor
                xbmc.executebuiltin('Dialog.Close(all, true)')
                return
                break
            if kbmonitor.flag == 'pause':
                slideIdx = slideIdx

        xbmc.executebuiltin('Action(ParentDir)')
        del kbmonitor

    except Exception as e:  
        printexception()
        mgenlog = 'Mezzmo error displaying slides.'
        xbmc.log(mgenlog, xbmc.LOGINFO)
        mgenlogUpdate(mgenlog)

The kbmonitor stuff can be deleted because that was for stop, pause and resume.  If you want that class code I can provide it.  To randomize the slides you can just randomize the slideIdx number prior to the JSON RPC call.

I hope this helps.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#8
Thank you Jeff a lot for your kind help!
You know javascript much better than me )) it looks your script loads after some time the pictures it founds on server, honestly I would take advance of the zoom & pan feature of Kodi slideshow and I gues sit's possible only when I start the slideshow and let it load the next files. I just need to enable somehow the randomize mode, do you know how? Enable the button in codi unfortunately isnt' enough (while other buttos do have effect when I open directory by JSON).
Thank you!
Reply
#9
I've found the way, it randomizes on loading and it will play then files in that same order, shuffle will be better (if I'll find), but that solves for now my problem:
Code:
return { payload: { "method": "Player.Open", "args": { "item": { "path": "smb://192.168.101.100/log", "random":true, "recursive":true } } }};
Reply

Logout Mark Read Team Forum Stats Members Help
How can I load a playlist of pictures by JSON-RPC API and run it?0