Jump to content

Emby for Kodi - playback problems in add on mode


fr0z3n
Go to solution Solved by deaconf19,

Recommended Posts

fr0z3n

Hi, 

Since the other thread was locked due to inactivity I assume Im going to repost this issue again since I am still experiencing it. 

On my android box, when emby for kodi is configured in addon mode, playback sometimes does not work. Exact details in the op here ( I am getting the exact same problem) 

The only thing I can add, is that when the addon is in native/direct mode (ie not addon mode) the issue does not happen. 

This leads me to agree and conclude with TeamB that It's something to do with the Web server that addon mode relies on, not starting consistently or otherwise being faulty, as opined here:

Just wondering if this could be looked into as a bug in emby for kodi. 

As mentioned, I don't get the issue in native mode. I also don't get the issue with Embycon. But I'm really keen on Emby for Kodi due to its speed being internal db. And I can't use native mode as I need transcoding and external access to the emby libraries. 

Thanks

Edited by fr0z3n
Link to comment
Share on other sites

Hi there, can you please attach a Kodi log from when this happened as well as the emby server log? Thanks.

Link to comment
Share on other sites

fr0z3n

Hi Luke 

Same issue as OP in linked post below. He/she posted both logs so can I refer you to them? I have the exact same thing in my log with the same experience. There is much discussion on that thread with evidence, logs and discussion. 

https://emby.media/community/index.php?/topic/78113-playback-fails-frequently-with-emby-for-kodi/

There is also discussion on this post which I started last year but was closed after some time. I also sent multiple logs to you and Angel last year in PM's following discussion on this thread:

https://emby.media/community/index.php?/topic/77587-playback-failed-one-or-more-items-failed-to-play-occurs-randomly-and-inconsistently/

I'm happy to keep producing logs, posting and PM'ing but its sort of feeling like a dead end

I don't know if a dev can fix the problem but if the problem could at least be noted as a bug and put in some bug backlog so when a developer can be assigned to look at it the affected users can assist in testing and troubleshooting. 

It's been happening since Leia and it's *most likely* something to do with the Web server not working properly in addon mode since the issue does not occur in native mode. 

Thanks as always appreciate your support

Edited by fr0z3n
Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...
quickmic

@fr0z3n

Sounds like a really tricky problem. One thing comes to mind when I'm reading all logs and comments in the threads.

Have you checked if port 57578 is maybe otherwise used?

Linux command would be "netstat -tulpn" to check

If Kodi is stopped, there should not be any service on Port 57578.

Edited by quickmic
Link to comment
Share on other sites

@quickmic

Thanks for your reply. Yeah I'm sure it's a tricky problem. 

The box is an android box so not sure i dont think i run that command. But I am sure the port is free because playback eventually works its just hit and miss. 

My testing shows it only happens when the playback mode in kodi is on add on mode playback as opposed to direct mode.

Further to this, it's not all devices where it happens. In my experience it's only low powered devices (eg android devices lower specced than nvidia shields, in my case a Vodafone tv) 

I know it has something to do with how add on mode playback works. When a file is played in add on mode it spawns like a web server instance where the stream is proxied through (as opposed to direct mode where it plays the file back direct from the smb directory). I think because it's a low powered device it's almost like the Web server fails to start and then times out. But in direct mode it's instant to play back since it is straight network file playing. 

Edited by fr0z3n
Link to comment
Share on other sites

quickmic

Excactly, it seems the (proxy) webserver is the core of the issue. If the port is used by another application or kodi plugin, it could result according to your observations.

Actually I don't think it's the port, but in such cases we must rule out everything.

Do you have access via ssh/telnet to you Android box?

If not, can you manipulate kodi plugin files? Then we switch to a different port as a test.

Link to comment
Share on other sites

quickmic

Well, it's just a try! I still don't think this will fix the problem, but you never know:

Please take a backup first!!

 

There are a couple of files to be modified:

Search for "57578" and replace ALL with with e.g. "43021"

/home/quickmic/.kodi/addons/plugin.video.emby/resources/lib/hooks/webservice.py

/home/quickmic/.kodi/addons/plugin.video.emby/resources/lib/entrypoint/default.py

/home/quickmic/.kodi/addons/plugin.video.emby/resources/lib/entrypoint/context.py

/home/quickmic/.kodi/userdata/addon_data/plugin.video.emby/emby/objects/play/strm.py

/home/quickmic/.kodi/userdata/addon_data/plugin.video.emby/emby/objects/core/music.py

/home/quickmic/.kodi/userdata/addon_data/plugin.video.emby/emby/objects/core/musicvideos.py

/home/quickmic/.kodi/userdata/addon_data/plugin.video.emby/emby/objects/core/movies.py

/home/quickmic/.kodi/userdata/addon_data/plugin.video.emby/emby/objects/core/tvshows.py

 

Additionally in file:

/home/quickmic/.kodi/addons/plugin.video.emby/resources/lib/hooks/webservice.py

search for "xbmc.sleep(200) # Let Kodi catch up" (two times in that file)

and replace it with "xbmc.sleep(2000) # Let Kodi catch up"

 

btw, does the issue only appear on Android boxes?

 

Link to comment
Share on other sites

Thanks yeah will give it a go. 

Will backup etc in case things break. 

The issue doesn't only appear on Android devices. For example I've seen it happen on my Celeron NUC running Libre elec for example. But definently doesn't happen as often. Maybe 1 in 30 times on the NUC vs 1 in 5-10 times on the particular android box. But what I noticed too is that it almost never happens on first playback attempt after a fresh kodi boot. It's only on subsequent playback attempts. I find that interesting. 

Im nearly certain is has something to do with the low powered spec'ed nature of particular boxes like low spec'ed android boxes and precious playback attempts corrupting the next attempt. Something like that. 

Will give your suggestions a go though thanks. 

Edited by fr0z3n
Link to comment
Share on other sites

quickmic

I'll try with a raspberry 2. Yesterday I tested with raspberry 1, but that thing is so slow and has so less Ram, Kodi is unusable.

 

Link to comment
Share on other sites

quickmic

I'm testing with raspi 2 disabled all core beside one and underclocked to 250MHZ.

Beside it's awful slow, it's still relatively stable. A few timeouts, but actually nothing really matching with the reported issues 😞

Edited by quickmic
Link to comment
Share on other sites

quickmic

Is this the issue?

 

This happens quite often with setup 1 core 700MHZ, and sometimes 2 cores 700MHZ and mostly never above that -> CPU load.

It's also better, if I give Kodi some time to load the artwork and almost never happens playing via widgets (recently added etc) directly from homescreen. If I browse via lists, it happens very often with low end setup.

Edited by quickmic
Link to comment
Share on other sites

First of all, thanks for your interest in the issue. The issue in your video is 100% the problem I experience on my "low powered Android box".

The specs on the android box where it occurs for me are below.

Quad-core 1.5 GHz Amlogic S905D

2GB RAM

To clarify as well, I find the issue is more frequent when I playback from widgets on home screen with aeon nox. I find the library playback is a bit more stable. But could be placebo. Now that you can replicate it will be curious to see if you can troubleshoot it a bit further than I could.

Edited by fr0z3n
  • Like 1
Link to comment
Share on other sites

quickmic

At least I've a testcase and can work with that. Could be a coincidence, anyway it's a bug.

btw, I also had a one time only case, that I got the error-msg and more or less that moment the stream was about to start.

Unfortunately, I was not able to reproduce that one. The other in the video is quite easy to reproduce.

Link to comment
Share on other sites

Yeah i get the same thing, the error happens after a few seconds (the error more or less pops up when the stream should start playing) 

What's interesting was 9-12 months ago on slightly older kodi and emby versions, the stream would actually start playing and the error would appear on top of the stream. So the stream is playing with the error dialogue on top of the playing stream. Then when you clicked OK on the error pop up then playback would stop. 

In more recent versions of kodi / emby, the error pops up but playback never starts. Issues been around for years but in recent months with kodi and emby updates the issue has changed to what you experienced, where the error pops up but playback never starts. 

Will PM you shortly with some videos of what I used to get and what I get now so it's clearer. 

Thanks again! 

Link to comment
Share on other sites

Yeah I'll try again but my testing previously suggested it was happening in the default skin too unfortunately. Good test though. Will update. 

  • Like 1
Link to comment
Share on other sites

quickmic

Finally, I think I found something, please try:

This file:

/home/osmc/.kodi/userdata/addon_data/plugin.video.emby/emby/objects/play/plugin.py

search for:

xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem())

replace with:

xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem())

 

Please also make sure, autoplay next Episode etc. is disabled.

 

If you see a message: A patch was applied on Kodi boot, then the modification was overwritten. In that case, modify again and restart Kodi.

 

Edited by quickmic
Link to comment
Share on other sites

Hey hey that's working really well so far! 

I tested about 10 playback attempts and didn't experience the issue once. 

Later tonight I'll do more in depth testing by changing it back to False, stop/restart kodi, verifying the issue happens and then change to True and verify issue stops happening, and do this a couple of times to verify it isn't placebo. 

But initial signs are really positive. 

Just for my curiosity how did you arrive at this one config file and what's the true / false thing we're actually changing; what does it actually do. 

Thanks so much champion! 

Edited by fr0z3n
  • Like 1
Link to comment
Share on other sites

quickmic

@fr0z3n

https://codedocs.xyz/xbmc/xbmc/group__python__xbmcplugin.html#gaa03ad528583db7d5277eae3977acde0f

Changing that parameter is not a clean solution. The original code (with "False" parameter) is actually the fallback in case something goes wrong.

 

Example from:

https://www.programcreek.com/python/example/84531/xbmcplugin.setResolvedUrl

 

def resolve_url(self, stream_url):
        '''
        Tell XBMC that you have resolved a URL (or not!).
        
        This method should be called as follows:
        
        #. The user selects a list item that has previously had ``isPlayable``
           set (this is true for items added with :meth:`add_item`, 
           :meth:`add_music_item` or :meth:`add_music_item`)
        #. Your code resolves the item requested by the user to a media URL
        #. Your addon calls this method with the resolved URL
        
        Args:
            stream_url (str or ``False``): If a string, tell XBMC that the 
            media URL ha been successfully resolved to stream_url. If ``False`` 
            or an empty string tell XBMC the resolving failed and pop up an 
            error messsage.
        '''
        if stream_url:
            self.log_debug('resolved to: %s' % stream_url)
            xbmcplugin.setResolvedUrl(self.handle, True, 
                                      xbmcgui.ListItem(path=stream_url))
        else:
            self.show_error_dialog(['sorry, failed to resolve URL :('])
            xbmcplugin.setResolvedUrl(self.handle, False, xbmcgui.ListItem()) 

 

I haven't reviewed the xbmc source yet, seem the initial call should also address the actual item to be played. This is not the case yet, that's why additional changes are possibly required.

The fallback code with "False" parameter seems to "reload/browse" the playlist and plays an item flagged with "isPlayable".

 

 

First, I was also focused on URL creation and wasted hours. Sooner or later I realized, this section just works perfect.

Then I disabled all unnecessary functions in the code till only the core (player) was left and injected a lot of sleep commands in case of timing issue. -> Nothing

Next I identified and tested the last working version. btw. it's 4.0.5 and the kodi-emby-objects file from that time period.

Finally I began comparing codes...

 

 

 

 

Edited by quickmic
Link to comment
Share on other sites

Hey @quickmic

This is great work thanks. 

I have some interesting findings that might help. 

1. With your workaround + the "automatically playback next episode / show" setting disabled, playback from both aeon nox home screen widgets + normal list views seems 100% ok. 

2. With your work around + the "automatically playback next episode / show" setting enabled, playback from aeon nox home widgets is fine but normal list view playback never opens the stream. Interesting - but expected based on your advice to turn this off? 

I need to some more testing with the config file back to the default value of False and verify the issue once again starts happening. Since its sort of random I'll need to use the box normally over a week or 2 with both False and True values and see if the error pops up and when. This will sort of prove changing the value from False to True has had an impact. 

I'll be watching the thread closely and see what other users report with your workaround as well. I'm not sure if Angel is still around but she'd be curious to know these findings too as she's been helping troubleshoot this issue on and off over the past 12 months.

Thanks! 

Edited by fr0z3n
  • Like 1
Link to comment
Share on other sites

quickmic
8 hours ago, fr0z3n said:

2. With your work around + the "automatically playback next episode / show" setting enabled, playback from aeon nox home widgets is fine but normal list view playback never opens the stream. Interesting - but expected based on your advice to turn this off? 

 

 

Yes, based on my observations.

Possible fix:

xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=listitem.getPath()))

This is not tested yet, I keep you updated.

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