2021-12-05, 07:39
Part 1:
I'm doing some work with subtitles using JSON in Windows Kodi 19.3 and have run across some strange problems. My test files for this thread are .mkv files with embeded "S_TEXT/UTF8" subs per MediaInfo. I'm able to switch between them using Player.SetSubtitle:
https://kodi.wiki/view/JSON-RPC_API/v12#...etSubtitle
However, when subs are off, and I turn them on, it takes about 10 seconds for them to appear. When I turn them off, they disappear for about 10 seconds and then come back on. During this time, if I use the OSD to inspect subtitles, "Enable subtitles" is toggled on the whole time, and it never toggles off after I've turned off subtitles. OTOH, when I use the "showsubtitles" action, they go on and off immediately, and the correct state is reflected in "Enable subtitles". I also get the subtitles notification when I use "showsubtitles", which I don't get when I use SetSubtitle. (The notification absence may be expected. I haven't yet investigated it.)
My commands look like the following, and they're formatted to be run from Windows cmd. They all return "OK" results immediately after being run.
1. Turn on subtitles
2. Turn off subtitles
Part 2:
After discovering that "on" and "off" are legal values for the "subtitle" parameter, I tried getting rid of the "enable" parameter and running two Player.SetSubtitle commands in a row, the first one with a sub index, the second with "on" or "off", e.g.
1. Turn on subtitles
2. Turn off subtitles
This fixes the weird behavior I experienced with turning subs off, but I still get the 10 second delay after turning them on.
Conclusions:
1. It seems there is a 10 second delay before subtitles can be shown after calling Player.SetSubtitle with an index for its "subtitle" parameter. However, if I immediately do a skip-back, subs are shown immediately.
2. I'm not sure what the Player.SetSubtitle "enable" parameter is for. It doesn't help the delay when set to "true", and it causes the weird behavior described in Part 1 when set to "false" and a second call with "subtitle" set to "off" isn't made.
Question:
How do I get rid of the 10 second delay for displaying subtitles after using an index for the Player.SetSubtitle "subtitle" parameter?
I'm doing some work with subtitles using JSON in Windows Kodi 19.3 and have run across some strange problems. My test files for this thread are .mkv files with embeded "S_TEXT/UTF8" subs per MediaInfo. I'm able to switch between them using Player.SetSubtitle:
https://kodi.wiki/view/JSON-RPC_API/v12#...etSubtitle
However, when subs are off, and I turn them on, it takes about 10 seconds for them to appear. When I turn them off, they disappear for about 10 seconds and then come back on. During this time, if I use the OSD to inspect subtitles, "Enable subtitles" is toggled on the whole time, and it never toggles off after I've turned off subtitles. OTOH, when I use the "showsubtitles" action, they go on and off immediately, and the correct state is reflected in "Enable subtitles". I also get the subtitles notification when I use "showsubtitles", which I don't get when I use SetSubtitle. (The notification absence may be expected. I haven't yet investigated it.)
My commands look like the following, and they're formatted to be run from Windows cmd. They all return "OK" results immediately after being run.
1. Turn on subtitles
Code:
curl -s --data-binary "{\"jsonrpc\":\"2.0\", \"method\":\"Player.SetSubtitle\", \"params\": {\"subtitle\": 0, \"enable\": true, \"playerid\": 1 }, \"id\": 1}" -H "content-type: application/json;" http://myip/jsonrpc
2. Turn off subtitles
Code:
curl -s --data-binary "{\"jsonrpc\":\"2.0\", \"method\":\"Player.SetSubtitle\", \"params\": {\"subtitle\": 0, \"enable\": false, \"playerid\": 1 }, \"id\": 1}" -H "content-type: application/json;" http://myip/jsonrpc
Part 2:
After discovering that "on" and "off" are legal values for the "subtitle" parameter, I tried getting rid of the "enable" parameter and running two Player.SetSubtitle commands in a row, the first one with a sub index, the second with "on" or "off", e.g.
1. Turn on subtitles
Code:
curl -s --data-binary "{\"jsonrpc\":\"2.0\", \"method\":\"Player.SetSubtitle\", \"params\": {\"subtitle\": 0, \"playerid\": 1 }, \"id\": 1}" -H "content-type: application/json;" http://myip/jsonrpc
curl -s --data-binary "{\"jsonrpc\":\"2.0\", \"method\":\"Player.SetSubtitle\", \"params\": {\"subtitle\": \"on\", \"playerid\": 1 }, \"id\": 1}" -H "content-type: application/json;" http://myip/jsonrpc
2. Turn off subtitles
Code:
curl -s --data-binary "{\"jsonrpc\":\"2.0\", \"method\":\"Player.SetSubtitle\", \"params\": {\"subtitle\": 0, \"playerid\": 1 }, \"id\": 1}" -H "content-type: application/json;" http://myip/jsonrpc
curl -s --data-binary "{\"jsonrpc\":\"2.0\", \"method\":\"Player.SetSubtitle\", \"params\": {\"subtitle\": \"off\", \"playerid\": 1 }, \"id\": 1}" -H "content-type: application/json;" http://myip/jsonrpc
This fixes the weird behavior I experienced with turning subs off, but I still get the 10 second delay after turning them on.
Conclusions:
1. It seems there is a 10 second delay before subtitles can be shown after calling Player.SetSubtitle with an index for its "subtitle" parameter. However, if I immediately do a skip-back, subs are shown immediately.
2. I'm not sure what the Player.SetSubtitle "enable" parameter is for. It doesn't help the delay when set to "true", and it causes the weird behavior described in Part 1 when set to "false" and a second call with "subtitle" set to "off" isn't made.
Question:
How do I get rid of the 10 second delay for displaying subtitles after using an index for the Player.SetSubtitle "subtitle" parameter?