holdestmade 11 Posted March 8, 2018 Share Posted March 8, 2018 I am currently using this API in Eventghost to generate now playing info to send my RTI remote processor. Using websocket, I get events when playback has started and stopped with the necessary data but get no events when paused, am I missing something ? Do I have to use the HTTP method to monitor 'IsPaused' ? Thanks Link to comment Share on other sites More sharing options...
holdestmade 11 Posted March 8, 2018 Author Share Posted March 8, 2018 Sorry, wish I'd searched first, found another almost identical thread. Link to comment Share on other sites More sharing options...
Luke 37067 Posted March 8, 2018 Share Posted March 8, 2018 Yes you have to send a message first to start receiving this info. I'm guessing you found it in the other thread. Link to comment Share on other sites More sharing options...
holdestmade 11 Posted March 8, 2018 Author Share Posted March 8, 2018 (edited) No, never found out, how do you send a message with python websocket and what format, I have tried a few things but go nowhere. I'm using ws.send is that suitable ? this is an extract from my script that works, except for the send: Thanks try: ws = EmbyClient('ws://192.168.x.x:8096?api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&DeviceId=xxxxxxxxxxxxxxxxxxxxxx') ws.connect() ws.send('{MessageType: "Playstate", Data: "Command"}') eg.PrintNotice("Connected to EMBY Server") except: ws.close() Edited March 8, 2018 by holdestmade Link to comment Share on other sites More sharing options...
holdestmade 11 Posted March 12, 2018 Author Share Posted March 12, 2018 I just can't seem to figure out how to get Paused and Unpaused events with the web socket connection, PlayStart and PlayStopped works fine, anyone give me a pointer or example using python scripts Cheers Link to comment Share on other sites More sharing options...
Luke 37067 Posted March 12, 2018 Share Posted March 12, 2018 Currently those events generate a lot of traffic so what you need to do is first send a message over the socket to indicate that you want to receive notifications: https://github.com/MediaBrowser/emby-webcomponents/blob/master/sessionplayer.js#L136 And then this is how you can stop them: https://github.com/MediaBrowser/emby-webcomponents/blob/master/sessionplayer.js#L82 Link to comment Share on other sites More sharing options...
chef 3745 Posted March 13, 2018 Share Posted March 13, 2018 (edited) I just can't seem to figure out how to get Paused and Unpaused events with the web socket connection, PlayStart and PlayStopped works fine, anyone give me a pointer or example using python scripts Cheers There aren't any Playback paused events. You can request playback progress and keep the current value in a variable and then check the variable against new info coming in. If the value is the same, then the state is paused and if it is higher then the saved variable then it is playing again. Add a small buffer to the saved variable, so that the progress count doesn't trigger false unpaused changes. Edited March 13, 2018 by chef Link to comment Share on other sites More sharing options...
holdestmade 11 Posted March 13, 2018 Author Share Posted March 13, 2018 Thanks @@chef and @@Luke, I'll give it a try Link to comment Share on other sites More sharing options...
holdestmade 11 Posted March 14, 2018 Author Share Posted March 14, 2018 (edited) So finally sorted is using the post above from @@mezz64. Quote For the benefit of someone else looking for this information I finally figured out the correct syntax for the websocket message to ask the server to provide session updates on an interval. The 1500 is the interval in milliseconds.{"MessageType":"SessionsStart", "Data": "0,1500"}{"MessageType":"SessionsStop", "Data": ""} Used the following when I get a PlaybackStarted message: ws.send(json.dumps({"MessageType":"SessionsStart", "Data": "0,1500"})) and this when I get a PlaybackStopped message: ws.send(json.dumps({"MessageType":"SessionsStop", "Data": ""})) Thanks all for your help Edited March 14, 2018 by holdestmade Link to comment Share on other sites More sharing options...
Luke 37067 Posted March 14, 2018 Share Posted March 14, 2018 Thanks for the feedback. Link to comment Share on other sites More sharing options...
holdestmade 11 Posted March 15, 2018 Author Share Posted March 15, 2018 Spoke too soon ! Updated to 3.3.1.0 from 3.2.x.x last night and now not getting any playback events, only system ones. ie Organize new media files etc. This is in my log whenever I try a connection, anything changed your end ? Not changed anything here. Thanks 2018-03-15 11:19:37.030 Info HttpServer: WS ws://192.168.1.52:8096/?api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&DeviceId=xxxxxxxx. UserAgent: 2018-03-15 11:19:37.049 Error SessionManager: Error in event handler *** Error Report *** Version: 3.3.1.0 Command line: C:\Users\MEDIA\AppData\Roaming\Emby-Server\system\EmbyServer.dll -service Operating system: Microsoft Windows NT 6.2.9200.0 64-Bit OS: True 64-Bit Process: True User Interactive: True Processor count: 2 Program data path: C:\Users\MEDIA\AppData\Roaming\Emby-Server Application directory: C:\Users\MEDIA\AppData\Roaming\Emby-Server\system System.NullReferenceException: Object reference not set to an instance of an object. at Messages.Api.MessageService.SessionManager_SessionStarted(Object sender, SessionEventArgs e) at System.EventHandler`1.Invoke(Object sender, TEventArgs e) at MediaBrowser.Common.Events.EventHelper.<>c__DisplayClass1_0`1.<QueueEventIfNotNull>b__0() System.NullReferenceException at Messages.Api.MessageService.SessionManager_SessionStarted(Object sender, SessionEventArgs e) at System.EventHandler`1.Invoke(Object sender, TEventArgs e) at MediaBrowser.Common.Events.EventHelper.<>c__DisplayClass1_0`1.<QueueEventIfNotNull>b__0() Link to comment Share on other sites More sharing options...
holdestmade 11 Posted March 15, 2018 Author Share Posted March 15, 2018 (edited) Here are my logs. One without my client running and one with my client starting at 2018-03-15 12:26:18.140 Thanks server log with my client running.txt server log without my client running.txt Edited March 15, 2018 by holdestmade Link to comment Share on other sites More sharing options...
Luke 37067 Posted March 15, 2018 Share Posted March 15, 2018 Remove the messenger plugin Link to comment Share on other sites More sharing options...
holdestmade 11 Posted March 15, 2018 Author Share Posted March 15, 2018 Thanks, tried that and also removed the Trailers plugin as I installed that last night. Still not working. Strange because all the other API functions work, ie messages, notifications etc just not playback Cheers Link to comment Share on other sites More sharing options...
Luke 37067 Posted March 15, 2018 Share Posted March 15, 2018 Ok, problem is, it clearly IS working or you would not be able to use any emby remote control features. For instance, I just used Chrome to control firefox and it worked just fine. Someone is going to have to go through your code to find what's missing. I'm afraid I do not have the bandwidth to personally do this for you, but you could compare to the source file I linked you to above. Link to comment Share on other sites More sharing options...
holdestmade 11 Posted March 15, 2018 Author Share Posted March 15, 2018 Ok thanks I'll have a dig about if you've not changed anything that end. Like I say, strange, it was working great and I have not changed my code. Link to comment Share on other sites More sharing options...
holdestmade 11 Posted March 16, 2018 Author Share Posted March 16, 2018 So, got it to work again with a slightly different method, I used this command on connect to the websocket and that generates events whilst playing and stops when playing stops. Not as neat as before as there is an event generated every second whilst playing but it works. Bonus is I can extract pause, and progress easier this way {"MessageType":"SessionsStart", "Data": "0,1000"} Link to comment Share on other sites More sharing options...
Luke 37067 Posted March 17, 2018 Share Posted March 17, 2018 Thanks for the info. Link to comment Share on other sites More sharing options...
nahovevyse 1 Posted March 19, 2019 Share Posted March 19, 2019 (edited) No, never found out, how do you send a message with python websocket and what format, I have tried a few things but go nowhere. I'm using ws.send is that suitable ? this is an extract from my script that works, except for the send: Thanks try: ws = EmbyClient('ws://192.168.x.x:8096?api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&DeviceId=xxxxxxxxxxxxxxxxxxxxxx') ws.connect() ws.send('{MessageType: "Playstate", Data: "Command"}') eg.PrintNotice("Connected to EMBY Server") except: ws.close() What's the import for "EmbyClient"? How did you figure out this -> {"MessageType":"SessionsStart", "Data": "0,1000"} I have installed pyEmby via pip but didn't find the import for EmbyClient. Thanks for your time Edited March 19, 2019 by nahovevyse Link to comment Share on other sites More sharing options...
nahovevyse 1 Posted March 19, 2019 Share Posted March 19, 2019 So, got it to work again with a slightly different method, I used this command on connect to the websocket and that generates events whilst playing and stops when playing stops. Not as neat as before as there is an event generated every second whilst playing but it works. Bonus is I can extract pause, and progress easier this way {"MessageType":"SessionsStart", "Data": "0,1000"} Can we plz have the code which you used to get socket response.. the full code I will really appreciate your help on this problem Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now