Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when kodi is not playing video any longer #298

Merged
merged 6 commits into from
May 10, 2023
Merged

Fix error when kodi is not playing video any longer #298

merged 6 commits into from
May 10, 2023

Conversation

AnonTester
Copy link
Contributor

Fixes timing issue that sometimes pops up when stopping or forward skipping at end of movie/show just as UpNext is starting up resulting in error:

error : EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <class 'RuntimeError'>
Error Contents: Kodi is not playing any file
Traceback (most recent call last):
File "/home/kodi/.kodi/addons/service.upnext/resources/lib/service_entry.py", line 8, in
UpNextMonitor().run()
File "/home/kodi/.kodi/addons/service.upnext/resources/lib/monitor.py", line 109, in run
self.playback_manager.launch_up_next()
File "/home/kodi/.kodi/addons/service.upnext/resources/lib/playbackmanager.py", line 44, in launch_up_next
episode, source = self.play_item.get_next()
File "/home/kodi/.kodi/addons/service.upnext/resources/lib/playitem.py", line 61, in get_next
current_file = self.player.getPlayingFile()
RuntimeError: Kodi is not playing any file
-->End of Python script error report<--

@MoojMidge
Copy link
Collaborator

Thanks for this.

Properly handling the RuntimeError raised by xbmc.Player methods when playback ends is something that could be done in a more general manner, but it is a little bit more involved than using try/catch for each individual method call.

In this particular instance however, catching the exception is probably not quite the right fix. The actual code in get_next that triggers the error should probably be changed to use the filename of the currently tracked video instead, as this avoids the potential for Unicode decode errors in Kodi 18, (using Python 2) and also allows the rest of the code to terminate normally if playback has stopped.

current_file = self.player.getPlayingFile()

    current_file = self.player.get_last_file()

Also there is no need to update the changelog and bump the version number, as that is done as part of a separate PR in order to trigger the release workflow.

@MoojMidge
Copy link
Collaborator

@AnonTester - did you want to update this?

@AnonTester
Copy link
Contributor Author

@MoojMidge adjusted to remove version and changelog and changing the try/catch which works for me with your suggestion instead.

@AnonTester AnonTester changed the title v1.1.9 Fix error when kodi is not playing video any longer Fix error when kodi is not playing video any longer May 9, 2023
@MoojMidge
Copy link
Collaborator

Hmm looks like this uncovered a previous old issue - player.Player was renamed to player.UpNextPlayer but a number of the imports were not updated. Now importing player.Player actually imports xbmc.player rather than the new class.

@sonarcloud
Copy link

sonarcloud bot commented May 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@MoojMidge MoojMidge merged commit 30b647b into im85288:master May 10, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants