xbmc / xbmc

Kodi is an award-winning free and open source home theater/media center software and entertainment hub for digital media. With its beautiful interface and powerful skinning engine, it's available for Android, BSD, Linux, macOS, iOS, tvOS and Windows.
https://kodi.tv/
Other
18.25k stars 6.28k forks source link

Extend exit or escape key #19469

Open albfan opened 3 years ago

albfan commented 3 years ago

fore you create a new problem report: https://kodi.wiki/view/HOW-TO:Submit_a_bug_report -->

Bug report

Describe the bug

Trying to create a addon to run a game emulator https://github.com/xbmc/repo-plugins/pull/3510

Didn't find a way to use kodi.gameclient, so xbmcplugin.setResolvedUrl replies with "no available emulators error". To solve that (not sure if there's a better approach) a subprocess is used.

I miss that we can extend escape/exit button (I'm using hdmi-cec so I'm pressing exit from a remote control) to kill the subprocess and stop the emulation

The use case is I'm using a media center so there's no accesible keyboard to kill emulator or a mouse to close a window.

Expected Behavior

Given a subprocess running:

import subprocess

p = subprocess.Popen([emulator_prog, arg], stdout = subprocess.PIPE, stderr = subprocess.STDOUT)

def on_exit(state):
   if state == xbmc.PLAYING and p:
      p.terminate()

Actual Behavior

On play a game, Kodi keeps the loading animation and emulator run on subprocess is running above kodi Pressing exit on remote control, kodi returns to game list selection, but subprocess is not killed

To Reproduce

Steps to reproduce the behavior:

Launch a subprocess and try to kill it on escape or exit

Debuglog

N/A

Screenshots

N/A

Additional context or screenshots (if appropriate)

N/A

Your Environment

Used Operating system:

zach-morris commented 3 years ago

I think your method and expectation here are a little incorrect. subprocess and xbmc.play have nothing to do with each other. Take a look at the methods used in the addon here

If the goal is to kill the subprocess with Kodi (which I don't think you'd want - the subprocess should be killed by the spawned program directly), you can use a modal dialog similar to the one used in the link above and have the user press a button on the modal to trigger subprocess to end.

albfan commented 3 years ago

Hi @zach-morris, thanks for review. I'm not sure what a dialogprogress is,so I tried to install your plugin using your repository, but it fails due to missing dependencies:

Captura de pantalla de 2021-03-26 08-20-35

So just guessing, a dialog would be something permanently shown on screen where you can cancel. Loose part of the screen for this, looks unnecessary. Listen to exit key to kill the process looks easier and more intuitive for me.

If you can share a screencast or screenshots of that dialog process that would be great to understand how that works.

Current approach for Ruyjinx emulator is that Ryujinx stop itself, so you return to kodi as that was the last app with focus. But then a first key press on exit needs to be done to kill the infinite loop.

github-actions[bot] commented 1 month ago

This issue is now marked stale because it has been open over a year without activity. Remove the stale label or add a comment to reset the stale state.