Jump to content

Xbox smart glass API csharp and emby plugin idea


chef

Recommended Posts

I was looking around GitHub recently and stumbled upon a netstandard library which controls Xbox through smart glass.

 

https://github.com/OpenXbox/xbox-smartglass-csharp

 

After fiddling with it for a couple days I was finally able to build the libraries.

 

So technically, and finally I have added these .dlls to an emby plugin.

 

But, alas I haven't quite got everything working together properly... It's taking me a while to completely understand what I'm supposed to do.

 

But I am confident that I can make a plug-in that controls Xbox.

 

This means starting the emby app from dashboard, shutting down the Xbox, and turning it on (turning it on is actually easy because you just have to send bits of data to the IP and it starts up from sleep).

 

I thought about creating a netstandard 2.0;net472 version if the library but building the project just wants to fail, so I'm back to the drawing board.

 

This is when I decided to piggy back on the emby netstandard 2.0 plug-in framework.

 

Maybe the plug-in should create API endpoints?

 

Maybe there is a way to host a virtual device for emby theater which is always on and cast-able, which triggers the Xbox to turn on, and open the emby app?

 

I dunno.

 

First thing first is get the smart glass library working properly.

 

I'm up for any ideas, if anyone wants to chime in.

Edited by chef
Link to comment
Share on other sites

jachin99

I have been looking at the python implementation but a server plugin would be cool especially if you could include game streaming, which I believe that project allows. 

  • Like 1
Link to comment
Share on other sites

I have been looking at the python implementation but a server plugin would be cool especially if you could include game streaming, which I believe that project allows.

Yes that part if the library is called Smartglass.Nano

 

I wonder if I'm good enough of a coder to do that?

Link to comment
Share on other sites

OH YEAH! got it working! the Xbox one smart glass libraries are awesome. I can now completely control the xbox one.

 

The best part is that I can get Alexa to start Emby on my xbox one, then use the Alexa skill to control Emby!

 

This just got a whole lot more interesting.

  • Like 1
Link to comment
Share on other sites

Holy mackerel! We can stream games...

 

I wonder if can we stream Xbox one games to an emby channel?

 

But first, I gotta figure out how to get a list of games and apps from the console.

 

But holy macaroni, I've been waiting for something like this forever!!

Link to comment
Share on other sites

@@Luke,

 

Each Xbox One app has a {titleid} attached to it, and I'm pretty sure that these IDs are the same across the board.

 

Meaning that my xbox one emby theater app would have the same ID as yours.

 

If that is true, would you guys be alright with sharing the apps title id here on this thread?

Edited by chef
Link to comment
Share on other sites

that means you wouldn't be able to submit to the store,r ight?

 

Oh I didn't know that it was sensitive.

 

Smart glass uses it start apps on the console.

 

I think I can figure out another way to run apps.

Edited by chef
Link to comment
Share on other sites

Oh this isn't in the Smartglass docs, but it is super important to implement. this finds the consoles live ID! Thank goodness.

 

And if you know the Name you gave your Xbox One, you can conditionally find the console name and then request the LiveId.

 

this will make device searching and connection much faster, with less user input and explaining for configuration in an emby plug-in.

 

But, the console would have to be on during first run of the plugin setup.

var discovered = await SmartGlass.Device.DiscoverAsync();
if (discovered.Count < 1)
{
    // No consoles discovered
    return;
}

// Enumerate first console
SmartGlass.Device device = discovered[0];
var liveId = device.Certificate.SubjectDN.GetValueList()[0];

var liveId;
foreach(var device in discovered)

{
   if(device.Name == "THE_CONSOLE_YOU_WANT")
   {
       liveId = device.Certificate.SubjectDN.GetValueList()[0];
   }
}

Edited by chef
Link to comment
Share on other sites

The API sends event codes consistently. In order to wrap the code further, I'll wait and parse code until emby shows up and target the ACKMessages. Once it's been found, the emby configuration will kick in and save.

Link to comment
Share on other sites

  • 2 weeks later...

So back over here to this thread! I have been able to narrow my results and have found the title.Id for Emby theater.

 

I have been successful in creating an alexa controller for Xbox One.

Link to comment
Share on other sites

WilhelmStroker

I use the official skill to yell stop, pause and play to my xbox which works well. Is yours any different or better?

  • Like 1
Link to comment
Share on other sites

I use the official skill to yell stop, pause and play to my xbox which works well. Is yours any different or better?

Well, not any different really.

 

 

But these commands will actually startup emby theater on your Xbox one. Turn off and on your Xbox one with Alexa.

 

Here in Canada you can't do that yet because Amazon has to translate everything en Francais...

So we get everything late...

Edited by chef
Link to comment
Share on other sites

Okay, because I don't know where else to post my findings. What I have created is an OWIN  .NetCore based web service (Cross-platform).

 

What's cool about it is that it allows Alexa to control Xbox One.

 

Alexa has access to endpoints which switches Xbox One to Emby Theater, Netflix, The Xbox Dashboard.

 

Any playback/browsing options are then handed over to the Emby API when Emby is open.

 

It is pretty seamless so far.

 

Does it have anything to do, specifically with Emby?  No not really, other then starting up Emby Theater and handing control over to it's API.

 

Still a very cool project, and learning a lot of behind the scenes stuff regarding the Xbox One.

 

Not sure If I want to create a Plugin specifically for emby server or if it should stay standalone OWIN API app.

 

If it was an emby plugin, it could persist in the background as an emby api endpoint, and alexa could contact it.

 

If the endpoint was created, then the offical Alexa-Emby Skill could contact it for control.

 

And also, Google Home could also contact it for Xbox One control as well.

 

Still not sure.

 

 

Note: Luke mentioned it might not be allowed in the Emby store. I'm not sure if that is because it would host private information, like the title-Id for the emby theater app? Or if it is because of the libraries that are used to gain access to Xbox?

 

 

Also, Note: Accessing Smartglass is super finicky. The Client connection is nowhere as solid as the Emby Api Client. The Emby Client will persist until the end of time, the SmartGlassClient will lose connection for no reason.

 

I had to create a custom "heartbeat" function just to monitor it. Geesh!

Edited by chef
Link to comment
Share on other sites

WilhelmStroker

Well, not any different really.

But these commands will actually startup emby theater on your Xbox one. Turn off and on your Xbox one with Alexa.

Here in Canada you can't do that yet because Amazon has to translate everything en Francais...

So we get everything late...

Ah I'm in the UK so we're behind the US but obviously ahead of Canada. Cool stuff, great job.
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...