Jump to content

Emby Server api


PrincessClevage

Recommended Posts

PrincessClevage

To report what?

Report on current state individual for each client for example I currently have 4 clients registered and only two active ( Xbox and iPad) and I want to poll active state of only these two active session every 30 sec and check to see if other two clients are active every 120secs. Another scenario would be I only wat to poll my Xbox client and I will not perform any automation on another clients thus reducing resources used by 3/4. When I refer to polling I believe the current state is presented e.g playing Batman returns 1:20 on Xbox. My understanding of current api is that every poll for current state returns all clients state Edited by PrincessClevage
Link to comment
Share on other sites

Yes. If you're speaking on behalf of a developer it would probably be best for me to interact with them directly. Thanks.

Link to comment
Share on other sites

Luke, I'm the developer of the Emby plugin for Vera (and also the Reactor plugin for Vera and a dozen others). I think PrincessClevage framed the question correctly, but since that original post I've found something more useful in the ActiveWithinSeconds query parameter to /Sessions. I found that by Googling around and tripping on it; I didn't see it mentioned in the docs. The remote control docs seem to be a bit behind and missing details; I've filled many holes using swagger that I would not have resolved with the docs alone. Big system, clearly; I'm sure it's a scramble to stay on top of the docs. I can't use any of the existing API libraries (Vera uses Lua 5.1). except as reference source code.

 

But the current integration is working, and pretty well. I'd like the UI to be more responsive and keep system load down, but at the moment it's polling (HTTP Sessions requests) at intervals, so the UI responsiveness is limited to the poll interval, and CPU hit is a function of interval as well. Since Veras are small-processor (MIPS) devices with little RAM, I try to keep unnecessary work down by deciding if a session is "active" or "idle" (determined by the existence of NowPlaying in the session's data plus a small time delay between states to allow for client UI activity or media changes) and choosing the polling interval accordingly--more frequent when active, less frequent when idle. This works OK except for a lag when a previously-idle player becomes active--it takes up to the full length of the longer idle polling interval before change that is detected. But I think that's a minor inconvenience, as I don't consider this integration to be a UI replacement for a client/session's UI. To me, this interface is more about control (e.g. support the ability to mute a player when the doorbell is ringing) and not about mirroring the UI displays of the clients. Vera's UI can't keep up with a play clock anyway.

 

To solve that lag, however, I'm guessing you would suggest WebSockets and SessionsStart as an alternative, and I've already got that implemented and it would indeed work nicely, if not for the fact that the Vera plugin environment (called Luup) is single-threaded, and therefore blocking on a socket recv() or select() to wait for data is fatal (they haven't gone deep enough in their own environment to make those calls yield). That means I'm back to polling, now on the socket, so the benefits aren't realized and I've got that added memory consumption of the code to implement the protocol vs just making HTTP requests (built-in). So at the moment, polling by HTTP request is as good as it gets, but I've still got a few tricks up my sleeve to try.

 

My other current mission is implementing a lightweight media browser in the UI. So far that hasn't generated any questions.

 

One question for a long-term feature thought: is there a way to direct a session to play a media file by pathname or URL, rather than just what is in the media library? I'm thinking I'd like to use the clients as TTS targets/annunciators, which would be very useful in the Vera/HA environment. If one of many remote APIs is used to generate an MP3 containing speech, how might I go about having a client stream that MP3, without having to first add it to the media library?

Link to comment
Share on other sites

Ok I understand. So if you want to work with a single device, then why not specify a DeviceId param to the /Sessions endpoint?

 

 

 

 

One question for a long-term feature thought: is there a way to direct a session to play a media file by pathname or URL, rather than just what is in the media library?

 

We don't have this right now as everything is ID based. It's something I'd like to add though.

Link to comment
Share on other sites

Luke, thanks for taking the time to reply. I could do single-session polling, but it takes longer to set up the request, make it, and collect the response than it does to parse a response and update the client "device" on the Vera side. I can rip pretty quickly through the multi-session response and get work done, and I think that going to multiple single-session requests would actually take longer in most cases. This challenge is really a Vera thing. If it were a true multi-tasking system, I would have no problem blocking on the WebSocket socket and waiting for the server's update (SessionsStart), which I would much prefer. But it's not, so what works and the efficiency of what works is a bit of a balancing act, and I'm forced to approach things in a way I would not under better circumstances. That said, I think what's running now works pretty well, and isn't a high cost to even old, low-end Veras.

 

Playing from a path/URI would be really useful, so please count my vote for that one! For the moment, I think the Vera HA fans will be pleased that messaging works, and a "There's someone at the door!" message popping up during their movie will geek a lot of people out (as simple but useful things often do).

Edited by rigpapa
Link to comment
Share on other sites

PrincessClevage

Luke would it be possible to call to start a radio station on client device xyz, so far I can start audio by calling the name of the song and setting media to audio but what would be correct call for plugin Tunein with the station “the very best of art bell”

For example?

Link to comment
Share on other sites

You can use the search api to try to find the content, then once you find it, then use the remote control api to play it.

Link to comment
Share on other sites

rigpapa

PrincessClevage, to embellish a bit on Luke's reply, when you find any content using the browser (e.g. Chrome) client, the "id" of that content is usually evident in the URL. On the Vera side, you can pass that id to the PlayMedia action on the session device, leaving title and media type blank, and it should fire right up.

Link to comment
Share on other sites

PrincessClevage

I have even managed to auto display my cameras (using Chefs surveillance app for emby) if there is motion detection when armed and playing state is active on my Main HTPC. Might be a long shot but Is there any way to temp store previous playing media name and resume it when camera stream is stopped ? Emby keeps records of resume state in its database I assume but not sure if this is exposed through the api

Link to comment
Share on other sites

rigpapa

Luke, it appears that when I send a "stop" to a client, the current queue is cleared and there is no way to resume it. Is that right?

 

If there is no resume, is there an API where I can see the session's queue so that I could copy/checkpoint it? I already get the data for the one currently-playing media item, but if the user is playing an entire album, or several, how might I know?

Link to comment
Share on other sites

rigpapa

Well, I'm primarily keeping it to the basic two: music and movies. Let's say the Sessions/Playing API is called several times with PlayLast, to accumulate a list of tracks to play. How can I see that list (esp. if we didn't create it, it was done done by client)? Or if the user plays an album.?

Link to comment
Share on other sites

Currently the playlist of a remote device is not exposed through the api, but as soon we get the 3.6 release out it's something I will be looking to finally implement. Thanks.

Link to comment
Share on other sites

PrincessClevage

Currently the playlist of a remote device is not exposed through the api, but as soon we get the 3.6 release out it's something I will be looking to finally implement. Thanks.

Is resume state of movie or music available through the api?
Link to comment
Share on other sites

rigpapa

Yup, I did exactly this. I just save the last NowPlayingItemId and position as the updates come in. That lets me restart the last media item I was aware of, but if that item was part of an album, playlist, etc., I would have no awareness of it, so I can only play the one item and anything that would have followed can't be played. So, either a full resume of the client's "queue" or access to the current playlist queue (ideally, BOTH) would be great. I imagine you are a very busy fellow.

Edited by rigpapa
Link to comment
Share on other sites

PrincessClevage

There isn't actually an api to resume, you would just use the api to play and then pass the position to start from:

 

https://github.com/MediaBrowser/Emby/wiki/Remote-control

 

But I think having a dedicated resume api makes sense, so i can look at adding that. thanks.

Hi Luke,

Do you think adding the resume ability to the api will make it into the upcoming new release of Emby?

Link to comment
Share on other sites

PrincessClevage

With the Vera to emby plugin that Rigpapa has implemented and in combination with Chefs Surveillance plugin I have camera feed auto displayed on my emby client (if it is active) and the camera is armed and triggered. I am now attempting to auto resume previous state (testing by playing movies and then triggering the armed camera) after closing the Camera feed (called Garage in my case). When you look into adding resume function into the api might it be possible to build in “resume previous state” to make it easier to resume previous played media if needed?

Link to comment
Share on other sites

  • 3 weeks later...
PrincessClevage

With the Vera to emby plugin that Rigpapa has implemented and in combination with Chefs Surveillance plugin I have camera feed auto displayed on my emby client (if it is active) and the camera is armed and triggered. I am now attempting to auto resume previous state (testing by playing movies and then triggering the armed camera) after closing the Camera feed (called Garage in my case). When you look into adding resume function into the api might it be possible to build in “resume previous state” to make it easier to resume previous played media if needed?

Hi Luke,

Curious if something like this made it into the recent server release/updates?

Link to comment
Share on other sites

  • 4 weeks later...
PrincessClevage

Haven't had a chance to look at this yet, but hopefully soon. Thanks.

Hi Luke,

Curious if you have had a chance to look at adding this into the api?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...