How to play video/picture combined slideshow via Python/json-rpc similar to GUI?
#1
Does anyone know if there is a way to replicate the way you can play a combined video and photo slideshow in the GUI using the "Start slideshow here" option from the pop-up menu?

The GUI is able to create and play a picture playlist that contains both photos and videos, but I have not been able to do this via the Python modules / Addons or via json-rpc. The details of what I've tried are in this thread here: http://forum.xbmc.org/showthread.php?tid...pid1444104. I've also tried launching a slideshow using the XBMC.SlideShow(directory) built-in, but it also behaves differently to the GUI and skips videos in the directory.

I've spent a few minutes looking at GUIWindowPictures.cpp, but without walking through the code in more detail it's not immediately obvious what the GUI is doing differently to the interfaces. I thought I'd ask if anyone has any insights / perspectives on this functionality before I spend too much time on the code. If anyone can point me in the right direction, I'd be hugely appreciative.
Reply
#2
So I've found out that adding "media":"files" to a Player.Open "item": directory request using Tolriq's media type fix (https://github.com/Tolriq/xbmc/commit/30...3fbc52e95d) does allow all files (photos and videos) to get into the playlist. However, Playlist Player returns an error that the pictures are unplayable items:

Code:
05:27:18 T:140735301009792   ERROR: Playlist Player: skipping unplayable item: 3, path [/Users/xbmc_test/IMG_2319.jpg]
Reply
#3
Must be a bug caused by this commit by Ulion: https://github.com/xbmc/xbmc/pull/2244
Reply
#4
When the JSON-RPC (and probably also the Python) API got support for Playlist there were no mixed playlists in XBMC. Every playlist could either contain only video files, only music files or only pictures. In the meantime this has changed a bit in XBMC itself to support videos during a slideshow (but not the other way around AFAIK) but the APIs haven't been adjusted yet.
Last time I tried video playback during a slideshow there were still a lot of quirks and odd things happening so maybe it's safer to wait until the feature is more stable before supporting it in an API that allows applications outside of XBMC to mess around with the playlist etc.
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
#5
When did you try it last time? I tried it when ulion did the slideshow refactor (not sure if this PR was merged finally) - and it looked good during my tests.
AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
Reply
#6
(2013-06-18, 07:53)Montellese Wrote: When the JSON-RPC (and probably also the Python) API got support for Playlist there were no mixed playlists in XBMC. Every playlist could either contain only video files, only music files or only pictures. In the meantime this has changed a bit in XBMC itself to support videos during a slideshow (but not the other way around AFAIK) but the APIs haven't been adjusted yet.
Last time I tried video playback during a slideshow there were still a lot of quirks and odd things happening so maybe it's safer to wait until the feature is more stable before supporting it in an API that allows applications outside of XBMC to mess around with the playlist etc.


Hi Montellese,

Thanks for your note and explanation. As you describe, when I investigated further I found that json-rpc seems to be ok playing a picture / video slideshow via Player.Open (under Gotham with Tolriq's fix…but not in Frodo) so long as it has a picture playlist that contains both file types.

I've verified by starting a slideshow from the GUI which generates a picture playlist containing both videos and photos. Then I stop the slideshow, and switch to json-rpc. From json-rpc, I can access the playlist the GUI created via Playlist.GetItems and I can start it again using Player.Open.

The difference then currently seems to be that json-rpc prohibits adding videos to a picture playlist. Another interesting side-effect of this situation is the way the Player.Open "directory" method handles various situations:

* Using Player.Open "directory" method with "media" = "video" loads only the videos into the video playlist (as expected).

* Using the Player.Open "directory" method with "media" = "pictures" loads only the pictures into the pictures playlist.

* Using the Player.Open "directory" method with "media" = "files" or "media" = "programs" loads all the files into the video playlist, but the video player (of course) skips over the images.

If the "media" = "files" method where to instead default to the "pictures" playlist instead of the "video" playlist, or if the PlayList.Add were to accept an explicit Add request with a video file (and perhaps optionally it's media type as video) I think the result would be a user experience that mirrored the GUI.

I hear you on the remote access concern, but there is currently no other way to build apps that combine picture+video slideshow capabilities--and I think there are some really interesting things that can be done in this area. One solution to the remote concern might be to add the capabilities to the Python Addon interface...but my sense is that json-rpc is currently richer and being more actively developed.

From my cursory glance it seems like a change to the PLAYLIST_PICTURE case in CPlaylistOperations::Add would be what's needed? I have a strong interest in this video+picture slideshow capability, but I'm sure there are other implications I may not be aware of that folks who're actively working on the codebase might share? I'd love to hear what people think about enhancing the capabilities of the interfaces to mirror the GUI. I'm happy to help if pointed in the right direction.


https://github.com/xbmc/xbmc/blob/c78ba0...ations.cpp

Code:
JSONRPC_STATUS CPlaylistOperations::Add(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  int playlist = GetPlaylist(parameterObject["playlistid"]);
  CFileItemList list;
  CVariant params = parameterObject;

  if (!CheckMediaParameter(playlist, parameterObject))
    return InvalidParams;

  CGUIWindowSlideShow *slideshow = NULL;
  switch (playlist)
  {
    case PLAYLIST_VIDEO:
    case PLAYLIST_MUSIC:
      if (playlist == PLAYLIST_VIDEO)
        params["item"]["media"] = "video";
      else if (playlist == PLAYLIST_MUSIC)
        params["item"]["media"] = "music";

      if (!FillFileItemList(params["item"], list))
        return InvalidParams;

      CApplicationMessenger::Get().PlayListPlayerAdd(playlist, list);
      
      break;

    case PLAYLIST_PICTURE:
      slideshow = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
      if (!slideshow)
        return FailedToExecute;
      if (!parameterObject["item"].isMember("media"))
        params["item"]["media"] = "pictures";
      if (!FillFileItemList(params["item"], list))
        return InvalidParams;

      for (int index = 0; index < list.Size(); index++)
      {
        CPictureInfoTag picture = CPictureInfoTag();
        if (!picture.Load(list[index]->GetPath()))
          continue;

        *list[index]->GetPictureInfoTag() = picture;
        slideshow->Add(list[index].get());
      }
      break;
  }
  
  NotifyAll();
  return ACK;
}
Reply
#7
I have a fix that is working for me under Frodo. In line 550 of interfaces/PlayerOperations.cpp in the CPlayerOperations::Open method I've allowed IsVideo() in addition to IsPicture() to proceed as a slideshow (see below). This allows a Player.Open call with "item" as "directory" to do a slideshow that includes both pictures and videos.

In my testing, I've seen no other side effects. Does anyone know of any other concerns/considerations I should be aware of in running with this change? Is there any interest in having this change back in master so others can benefit?

I haven't tested under Gotham, but this particular code block seems unchanged between Frodo and Gotham.

New Code
Code:
bool slideshow = true;
      for (int index = 0; index < list.Size(); index++)
      {
        if (!list[index]->IsPicture() && !list[index]->IsVideo())
        {
          slideshow = false;
          break;
        }
      }

Old Code

Code:
bool slideshow = true;
      for (int index = 0; index < list.Size(); index++)
      {
        if (!list[index]->IsPicture())
        {
          slideshow = false;
          break;
        }
      }
Reply
#8
If others are interested, someone else has found a workaround that doesn't require code changes. You can get a slideshow that contains both videos and pictures in a directory to play via Python addon using the following builtin calls:

Code:
xbmc.executebuiltin("ActivateWindow(Pictures,/path/to/files/)")
xbmc.executebuiltin("Action(Play)")

Here's the thread with the details: http://forum.xbmc.org/showthread.php?tid...pid1451987

It would be great if the GUI and interfaces were more uniformly implemented, so hopefully we can get changes similar to mine above into master.
Reply
#9
Quote:I have a fix that is working for me under Frodo. In line 550 of interfaces/PlayerOperations.cpp in the CPlayerOperations::Open method I've allowed IsVideo() in addition to IsPicture() to proceed as a slideshow (see below). This allows a Player.Open call with "item" as "directory" to do a slideshow that includes both pictures and videos.

I'm using Frodo but cant find 'interfaces/PlayerOperations.cpp'. Is it only found in pre-compile?
Reply
#10
(2013-06-29, 08:23)klestor Wrote:
Quote:I have a fix that is working for me under Frodo. In line 550 of interfaces/PlayerOperations.cpp in the CPlayerOperations::Open method I've allowed IsVideo() in addition to IsPicture() to proceed as a slideshow (see below). This allows a Player.Open call with "item" as "directory" to do a slideshow that includes both pictures and videos.

I'm using Frodo but cant find 'interfaces/PlayerOperations.cpp'. Is it only found in pre-compile?

Sorry. I gave the wrong path. Here's the link to the file in master on Github and you can change the branch to see the code for Frodo:

https://github.com/xbmc/xbmc/blob/master...ations.cpp
Reply
#11
Quick update on this issue and some problems I've run into using the built-ins. They work fine for very small playlists...like 5 or 10 files....but for larger playlists XBMC appears to spiral into an out of memory state and then reboot (similar to what is described in this thread: http://forum.stmlabs.com/showthread.php?tid=8442).

Particularly interesting is this happens not only with the built-ins, but also in the GUI if you select "start slideshow from here" in a directory that contains a large number of files. This happens on Ubuntu 12.04, Raspbmc and OpenElec.

However, this does not happen under Ubuntu 12.04 when playing the same directory using my change in PlayerOperations.cpp by using a Player.Open json-rpc call using the "directory" parameter. I will compile for Raspberry Pi and report back whether this is also stable for handling slideshows with a large number of videos and pictures.
Reply
#12
Nice catch.. Could you also try to start a slideshow with a background music? In GUI this works (although not very user friendly).

And I also think instant (= on file change) refreshing (adding / deleting this new content) those playlists usedby the buildin could be very usefull. Esspecially for screensavers.
Reply
#13
So what works on Ubuntu (not surprisingly) does not work so well on Raspberry Pi. Using my change to Player.Open I experienced out of memory crashing situations similar to using the built-in when trying to play large picture+video slideshows.

It seems like the above methods send data to XBMC faster than it can handle it. Accordingly, I've changed tack and have now modified PlaylistOperations.cpp to make the Playlist.Add method accept video as well as pictures in a picture playlist. Spacing out my playlist add requests and blocking on actually trying to play the list until it is created has allowed me to run with playlists of hundreds (and will soon be testing thousands) of items.

My changes are here: https://github.com/andyjagoe/xbmc/blob/F...ations.cpp

I like the idea of background music...though I'm not sure how this would work since video already has audio and I don't think videos and audio files can play at the same time. I totally agree that instant refreshing of playlists would be a huge improvement. I have not looked into why they are so unimaginably slow to manipulate on xbmc currently. It should be possible to create a playlist from a list of files in milliseconds...
Reply
#14
Now, music and pictures can run simultaneously. Allowing json with your same solution to play pictures and music could do just that if it also kills the audio when switching to video. And resumes on the next picture.. The combo of music with video is indeed a different story.

Did you use valgrind for the mem. problems?
Reply
#15
Also I would focus on gotham becase since frodo lots of changes went in for pictures.

About the speed: my guess its due to vfs.
Reply

Logout Mark Read Team Forum Stats Members Help
How to play video/picture combined slideshow via Python/json-rpc similar to GUI?1