iina / iina

The modern video player for macOS.
https://iina.io
GNU General Public License v3.0
37.07k stars 2.53k forks source link

pass arguments to open IINA #4995

Open brysi-ux opened 2 weeks ago

brysi-ux commented 2 weeks ago

Running this command twice will open multiple IINA application bundles at a desired start time:

/Applications/IINA.app/Contents/MacOS/iina-cli "$file" -- --start="$time" --no-resume-playback --player-operation-mode=pseudo-gui

Running this command twice will open multiple IINA windows in the same application bundle:

open -a /Applications/IINA.app "$file"

Anyone know how to open multiple windows in the same bundle while passing the start and no-resume-playback arguments to them succesfully?

Running:

open -a /Applications/IINA.app "$file" --args -- --start="$time" --no-resume-playback

or:

open -a /Applications/IINA.app/Contents/MacOS/iina-cli "$file" --args -- --start="$time" --no-resume-playback

opens multiple IINA windows, however the start time does not pass succesfully.

It seems you used to be able to pass arguments to open mpv 4354 but the option was removed to improve bundle handling

I know Apple Script could be used to manually click the IINA jump command and enter a start time once the window is opened, but I'm trying to find a bash solution due to the minor delay when using GUI scripting.

ShlomoCode commented 2 weeks ago

According to https://github.com/mpv-player/mpv/issues/4354#issuecomment-296448420 it seems that you should call IINA directly and not through the open command

low-batt commented 2 weeks ago

On this:

but I'm trying to find a bash solution due to the minor delay when using GUI scripting

As discussed in Automate tasks using AppleScript and Terminal on Mac, you can run AppleScript directly from Terminal using osascript. Run the following in Terminal to learn more about osascript:

man osascript

Another way to control IINA from the Terminal is to use mpv's JSON IPC interface. See this comment for an example of how to configure IINA to enable the IPC interface. This example shows me commanding IINA to seek to a specific time:

low-batt@gag ~$ echo '{ "command": ["seek", "5:00", "absolute"] }' | socat - /tmp/mpv-socket | jq
{
  "data": null,
  "request_id": 0,
  "error": "success"
}
low-batt@gag ~$ 
brysi-ux commented 1 week ago

Thank you for the information about the JSON interface, I was unaware of this.