Jump to content

Emby.ApiClient C# Sample Not Working


footose

Recommended Posts

I can't seem to get sample provided in the ReadMe to compile. Any help would be appreciated. I think it may be outdated ...

 

 

 

Errors:

 

Error 1 'MediaBrowser.ApiInteraction.ApiClient' does not contain a constructor that takes 5 arguments C:\Projects\Form1.cs 45 26
 
Error 2 The name 'AuthenticateUserAsync' does not exist in the current context C:\Projects\Form1.cs 47 36
 
Error 3 The name 'passwordHash' does not exist in the current context C:\Projects\Form1.cs 47 70
 
Error 4 An object reference is required for the non-static field, method, or property 'MediaBrowser.ApiInteraction.ApiClient.ReportCapabilities(MediaBrowser.Model.Session.ClientCapabilities, System.Threading.CancellationToken)' C:\Projects\Form1.cs 50 19
 
Error 5 An object reference is required for the non-static field, method, or property 'MediaBrowser.ApiInteraction.ApiClient.RemoteLoggedOut' C:\Projects\Form1.cs 53 13
 
Error 6 The name 'ApiClient_RemoteLoggedOut' does not exist in the current context C:\Projects\Form1.cs 53 42
 
Error 7 'MediaBrowser.ApiInteraction.ApiClient' does not contain a definition for 'UserId' and no extension method 'UserId' accepting a first argument of type 'MediaBrowser.ApiInteraction.ApiClient' could be found (are you missing a using directive or an assembly reference?) C:\Projects\Form1.cs 58 33
 
 
Link to comment
Share on other sites

Redshirt

The readme probably is out of date. Try instead using the ConnectionManager as described in the multi-server portion of ReadMe. Calling Connect() will find the server on the network and the task will return an instantiated and configured ApiClient. 

  • Like 1
Link to comment
Share on other sites

Thanks for the help so far. Gave it a shot .. looks like that is also not updated ... and not complete...

 

I managed to hack together a connector making a new Interface for the CredentialProvider .. (there isn't any documentation on it) but still can't connect. Sample in the Readme is very incomplete.

 

Someone should def update the ReadMe, or might scare dev's away (I got bored pretty quick) .. or even may want to provide a sample application or unit tests so that they have to pass when its released.

Edited by footose
Link to comment
Share on other sites

Redshirt

I just tested the ConnectionManager example as described in the ReadMe and it works as expected. The only thing missing from the ReadMe is a concrete example of a credential provider, but the comments in the example code state that any dev will need to provide there own. An example of one is in Emby Theater. https://github.com/MediaBrowser/Emby.Theater/blob/master/MediaBrowser.UI/CredentialProvider.cs.

 

If you still can't connect you may want to replace NullLogger with your own ILogger implementation so you can at least get feedback to the console.

Link to comment
Share on other sites

I just tested the ConnectionManager example as described in the ReadMe and it works as expected. The only thing missing from the ReadMe is a concrete example of a credential provider, but the comments in the example code state that any dev will need to provide there own. An example of one is in Emby Theater. https://github.com/MediaBrowser/Emby.Theater/blob/master/MediaBrowser.UI/CredentialProvider.cs.

 

If you still can't connect you may want to replace NullLogger with your own ILogger implementation so you can at least get feedback to the console.

 

Thank you for testing it. I'll also go through it when i have a chance and see if anything needs to be updated.

Link to comment
Share on other sites

Redshirt

np. I should mention I only tested far enough to make sure I got the initial ConnectionResult. I don't have anything in C# that I can test the full user authentication process.

Link to comment
Share on other sites

maybe i will move the theater credential provider into the sample as well. it's nearly 2016 and we're seeing this with both users and developers - everything has to just work automatically without having to read anything or people will just sound the alarm and run away :)

Link to comment
Share on other sites

I understand you can't update every document, but man, your comment itself would scare dev's away and was a little rude.

 

If you're going to include samples, make them work - otherwise don't include them - then the dev's can rely on the documents and then your comment above become valid.

 

Saying that I didn't read the documents is the reason I couldn't get it to work is not true. I couldn't get samples to work because they use functions that don't exist or were changed. They weren't even depreciated. 

 

You imply I'm lazy for not reading the documents, yet you didn't update the ReadME file to reflect your changes - it's a bit contradictory. I really just wanted to write a plugin / app for this project and contribute to the community - which I really don't have too do - but thought would be fun. I'm a supporting (donating) member. Now I don't feel like even looking at this code.

 

I'd be happy to help you update the ReadME's if you like.

Edited by footose
Link to comment
Share on other sites

Redshirt

Luke, the one thing that I can see that should probably be added to the ApiClient readme, is any mention of downloading the MediaBrowser.ApiClient nuget package instead of having to compile the source. It was against the NuGet package that I did my testing yesterday.

  • Like 1
Link to comment
Share on other sites

i haven't had a chance to go through the sample yet, sorry. But it sounds like the nuget package will be easier than source.

Link to comment
Share on other sites

  • 2 weeks later...
GlennNZ

Hi

Thanks for Emby and awating new releases, and in anticipation of these releases in a spare few hours thought would look at potentially adding an Emby Api connection for a app I'm developing/supporting (poorly)

 

But after having a look at api.client and code - have to { softly} repeat the concerns here that the readme is outdated/quite hard to get functional code. (when it should not be that hard)

 

Used Nuget - install okay.

Most of the service apps examples - no longer apply.

Most of the server example classes etc have moved.

 

and the lack of CredentialProvider example (thanks for the home-theatre link - but cutting that out is no small work)

 

A few working examples would go a huge way.

 

All in all it does create some major difficulty/and more importantly time getting the basic connection to the server to move on with implentation steps.

As mentioned above, boredom occurs quickly when this takes a few hours.

 

Clearly the major work is done - its just illustrating the usage now.

 

(My two cents!)

 

maybe i will move the theater credential provider into the sample as well. it's nearly 2016 and we're seeing this with both users and developers - everything has to just work automatically without having to read anything or people will just sound the alarm and run away :)

You're not wrong! (having just reread thread)

 

Glenn

Edited by GlennNZ
Link to comment
Share on other sites

  • 2 months later...
edejaeger

Hi guys !

 

I was quite motivated authoring a NT service to automatically synchronize my WPL playlists with Emby's, but I am a little bit scared reading your posts.

 

Could someone tell me if I can consider starting my C# project or not ?

 

 

Many thanks by advanced.

 

B.R.

 

Eric D. J.

Link to comment
Share on other sites

  • 6 months later...
erichzann

maybe i will move the theater credential provider into the sample as well. it's nearly 2016 and we're seeing this with both users and developers - everything has to just work automatically without having to read anything or people will just sound the alarm and run away :)

 

Hi @@Luke would you be able to point me to that sample credential provider. It would be incredibly useful.

 

 

I have the ConnectionManager instance working and after running:

 

 

var address = "http://192.168.1.3:8096";       //local server address

 

var result = await connectionManager.Connect(address, token);

 

Console.WriteLine(result.State);

 

 

I'm getting the return value as 'unavailable'. Does that mean the server is not located or just not authenticated.

 

Thanks in advance

Edited by erichzann
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...