Skip to content

Commit

Permalink
Handle folder filtering in IINA instead of sending to mpv, and interc…
Browse files Browse the repository at this point in the history
…ept mpv shuffle arg & convert it to playlist-shuffle command. Fixes regression where folder filtering was broken, while still supporting shuffle via cmd-line
  • Loading branch information
svobs committed Aug 8, 2023
1 parent 1af17db commit 956a789
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions iina/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, SPUUpdaterDelegate {
var iinaArgFilenames: [String] = []
var dropNextArg = false

Logger.log("Got arguments \(arguments)")
Logger.log("Command-line args: \(arguments)")
for arg in arguments {
if dropNextArg {
dropNextArg = false
Expand All @@ -238,9 +238,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, SPUUpdaterDelegate {
}
}

Logger.log("IINA arguments: \(iinaArgs)")
Logger.log("Filenames from arguments: \(iinaArgFilenames)")
commandLineStatus.parseArguments(iinaArgs)
Logger.log("Filenames from args: \(iinaArgFilenames)")
Logger.log("Derived mpv properties from args: \(commandLineStatus.mpvArguments)")

print("IINA \(version) Build \(build)")

Expand Down Expand Up @@ -330,6 +330,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, SPUUpdaterDelegate {
}

if let pc = lastPlayerCore {
if commandLineStatus.shufflePlaylist {
pc.toggleShuffle()
}

if commandLineStatus.enterMusicMode {
if commandLineStatus.enterPIP {
// PiP is not supported in music mode. Combining these options is not permitted and is
Expand Down Expand Up @@ -880,6 +884,7 @@ struct CommandLineStatus {
var openSeparateWindows = false
var enterMusicMode = false
var enterPIP = false
var shufflePlaylist = false
var mpvArguments: [(String, String)] = []
var iinaArguments: [(String, String)] = []
var filenames: [String] = []
Expand All @@ -895,10 +900,20 @@ struct CommandLineStatus {
let strippedName = String(name.dropFirst(4))
if strippedName == "-" {
isStdin = true
} else if splitted.count <= 1 {
mpvArguments.append((strippedName, "yes"))
} else {
mpvArguments.append((strippedName, String(splitted[1])))
let argPair: (String, String)
if splitted.count <= 1 {
argPair = (strippedName, "yes")
} else {
argPair = (strippedName, String(splitted[1]))
}

if argPair.0 == "shuffle" && argPair.1 == "yes" {
Logger.log("Found shuffle request in command-line args. Will convert it to \"playlist-shuffle\" command")
shufflePlaylist = true
} else {
mpvArguments.append(argPair)
}
}
} else {
// other args
Expand Down

0 comments on commit 956a789

Please sign in to comment.