Jump to content

Emby plugin add nugget package


Hydro

Recommended Posts

Hi

 

I'm working on a little plugin for emby that send informations about sessions when something is played / stop...

 

So I get an object SessionInfo, i want to turn it into a string to send it with http request.

 

I try to add newton json from nugget but when I try my plugin on Emby i've got :

 

 

 

2016-09-01 13:48:24.4244 Error SessionManager: Error in event handler
    *** Error Report ***
    Version: 3.1.6087.25762
    Command line: C:\Users\Alpha\AppData\Roaming\Emby-Server\System\MediaBrowser.ServerApplication.exe
    Operating system: Microsoft Windows NT 6.2.9200.0
    Processor count: 4
    64-Bit OS: True
    64-Bit Process: True
    Program data path: C:\Users\Alpha\AppData\Roaming\Emby-Server
    Application Path: C:\Users\Alpha\AppData\Roaming\Emby-Server\System\MediaBrowser.ServerApplication.exe
    Impossible de charger le fichier ou l'assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' ou une de ses d�pendances. Le fichier sp�cifi� est introuvable.
    System.IO.FileNotFoundException
     � MiOSEmbyZWaveControllerCS.EmbyEventArgs.SessionHasStarted(Object sender, SessionEventArgs e)
     � System.EventHandler`1.Invoke(Object sender, TEventArgs e)
     � MediaBrowser.Common.Events.EventHelper.<>c__DisplayClass6`1.<QueueEventIfNotNull>b__4()

 

Is it because Emby plugin are class file ?

 

Thank :)

Link to comment
Share on other sites

It is probably because you added a dependency to your assembly that doesn't exist in the runtime environment.

 

The good news is that you don't need the dependency.  We have a json serializer available to you in the system.  Just include IJsonSerializer in your entry point constructor.

Link to comment
Share on other sites

Hi

 

I've got a little problem with jsonserializer.

        public static void EnableEvents()
        {
            SessionManager.PlaybackStart += PlaybackStarted;
            SessionManager.PlaybackStopped += PlaybackStopped;
            SessionManager.SessionStarted += SessionHasStarted;
            SessionManager.SessionEnded += SessionHasEnded;
            SessionManager.PlaybackProgress += CurrentPlaybackProgress;
        }


        public static void PlaybackStarted(object sender, PlaybackProgressEventArgs e)
        {
            foreach (SessionInfo session in SessionManager.Sessions)
            {             
                if (session.DeviceId == e.DeviceId)
                {
                    string SessionData = JSonSerializer.SerializeToString(session);
                    var parameters = new Dictionary<string, string>
                    {
                        {"Name", session.Id},
                        {"Value", SessionData},
                    };
                   try
                   {
                        ApiClient.SendInfo(parameters);
                    }
                    catch (Exception ex)
                    {
                       throw new Exception(ex.ToString());
                    }
                }
            }

        }

If I put "string SessionData = JSonSerializer.SerializeToString(session);" emby crash every time.

 

 

2016-09-03 17:32:45.9515 Error SessionManager: Error in event handler

*** Error Report ***
Version: 3.1.6089.13542
Command line: C:\Users\Alpha\AppData\Roaming\Emby-Server\System\MediaBrowser.ServerApplication.exe
Operating system: Microsoft Windows NT 6.2.9200.0
Processor count: 4
64-Bit OS: True
64-Bit Process: True
Program data path: C:\Users\Alpha\AppData\Roaming\Emby-Server
Application Path: C:\Users\Alpha\AppData\Roaming\Emby-Server\System\MediaBrowser.ServerApplication.exe
La référence d'objet n'est pas définie à une instance d'un objet.
System.NullReferenceException
  à MiOSEmbyZWaveControllerCS.EmbyEventArgs.SessionHasStarted(Object sender, SessionEventArgs e)
  à System.EventHandler`1.Invoke(Object sender, TEventArgs e)
  à MediaBrowser.Common.Events.EventHelper.<>c__DisplayClass6`1.<QueueEventIfNotNull>b__4()

 

Any idea what it's crashing every time ?

 

Is there another way to get sessioninfo without looping through all sessions ?

 

Thank

Link to comment
Share on other sites

The object you're trying to serialize was not intended to be serialized. if you're doing this just to send back data through a custom api, the regular api already has this.

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...