Skip to content

Commit

Permalink
feat: show playing file in Finder
Browse files Browse the repository at this point in the history
  • Loading branch information
godly-devotion committed Mar 19, 2024
1 parent 9463a3f commit 512c617
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Front Row/FrontRowApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ struct FrontRowApp: App {
.windowStyle(.hiddenTitleBar)
.commands {
AppCommands(updater: updaterController.updater)
FileCommands(isPresentingOpenURLView: $isPresentingOpenURLView)
FileCommands(
playEngine: $playEngine,
isPresentingOpenURLView: $isPresentingOpenURLView)
ViewCommands(windowController: $windowController)
PlaybackCommands(
playEngine: $playEngine,
Expand Down
3 changes: 3 additions & 0 deletions Front Row/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -2163,6 +2163,9 @@
}
}
},
"Show in Finder" : {
"comment" : "Show the currently playing file using Finder"
},
"Step Backward 5s" : {
"localizations" : {
"ar" : {
Expand Down
15 changes: 15 additions & 0 deletions Front Row/Main Menu/FileCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
// Created by Joshua Park on 3/4/24.
//

import AVKit
import SwiftUI

struct FileCommands: Commands {
@Binding var playEngine: PlayEngine
@Binding var isPresentingOpenURLView: Bool

var body: some Commands {
Expand All @@ -33,6 +35,19 @@ struct FileCommands: Commands {
}
.keyboardShortcut("L", modifiers: [.command])
}
Section {
Button {
guard let item = PlayEngine.shared.player.currentItem else { return }
guard let asset = item.asset as? AVURLAsset else { return }
NSWorkspace.shared.activateFileViewerSelecting([asset.url])
} label: {
Text(
"Show in Finder",
comment: "Show the currently playing file in Finder"
)
}
.disabled(!playEngine.isPlayingLocalFile)
}
}
}
}
3 changes: 3 additions & 0 deletions Front Row/Support/PlayEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import SwiftUI

var isPlaying = false

var isPlayingLocalFile = false

var isMuted: Bool {
get {
access(keyPath: \.isMuted)
Expand Down Expand Up @@ -113,6 +115,7 @@ import SwiftUI

player.play()
isLoaded = true
isPlayingLocalFile = FileManager.default.fileExists(atPath: url.path(percentEncoded: false))
}

func playPause() {
Expand Down

0 comments on commit 512c617

Please sign in to comment.