Skip to content

Commit

Permalink
fix system audio, fix outline, fix preview
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyun6 committed Jan 3, 2025
1 parent e94b783 commit 1ab33b1
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 18 deletions.
8 changes: 4 additions & 4 deletions QuickRecorder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@
CODE_SIGN_ENTITLEMENTS = QuickRecorder/QuickRecorder.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 161;
CURRENT_PROJECT_VERSION = 162;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"QuickRecorder/Preview Content\"";
DEVELOPMENT_TEAM = L4T783637F;
Expand All @@ -505,7 +505,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.3;
MARKETING_VERSION = 1.6.1;
MARKETING_VERSION = 1.6.2;
PRODUCT_BUNDLE_IDENTIFIER = com.lihaoyun6.QuickRecorder;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -521,7 +521,7 @@
CODE_SIGN_ENTITLEMENTS = QuickRecorder/QuickRecorder.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 161;
CURRENT_PROJECT_VERSION = 162;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"QuickRecorder/Preview Content\"";
DEVELOPMENT_TEAM = L4T783637F;
Expand All @@ -539,7 +539,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.3;
MARKETING_VERSION = 1.6.1;
MARKETING_VERSION = 1.6.2;
PRODUCT_BUNDLE_IDENTIFIER = com.lihaoyun6.QuickRecorder;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "MissingArtwork_Music_onLight_55A54008AD1BA589AA210D2629C1DF41_0.png",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "MissingArtwork_Music_onDark_55A54008AD1BA589AA210D2629C1DF41_0.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 22 additions & 11 deletions QuickRecorder/SCContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class SCContext {
}
dispatchGroup.wait()
} else {
vW.finishWriting {}
if ud.bool(forKey: "recordMic") { vW.finishWriting {} }
}

DispatchQueue.main.async {
Expand All @@ -387,21 +387,21 @@ class SCContext {
Task {
let outPutUrl = URL(fileURLWithPath: String(filePath.dropLast(4)) + ".mp3")
do {
let title = "Recording Completed".local
let body = String(format: "File saved to: %@".local, outPutUrl.path.removingPercentEncoding!)
let id = "quickrecorder.completed.\(UUID().uuidString)"
try await m4a2mp3(inputUrl: URL(fileURLWithPath: filePath1), outputUrl: outPutUrl)
try? fd.removeItem(atPath: filePath1)
showNotification(title: title, body: body, id: id)
if !ud.bool(forKey: "showPreview") {
let title = "Recording Completed".local
let body = String(format: "File saved to: %@".local, outPutUrl.path.removingPercentEncoding!)
let id = "quickrecorder.completed.\(UUID().uuidString)"
showNotification(title: title, body: body, id: id)
} else {
DispatchQueue.main.async { showPreview(path: outPutUrl.path, image: NSImage(named: "audioIcon")) }
}
} catch {
showNotification(title: "Failed to save file".local, body: "\(error.localizedDescription)", id: "quickrecorder.error.\(UUID().uuidString)")
}
}
} else {
let title = "Recording Completed".local
let body = String(format: "File saved to: %@".local, filePath)
let id = "quickrecorder.completed.\(UUID().uuidString)"
showNotification(title: title, body: body, id: id)
if ud.bool(forKey: "remuxAudio") && ud.bool(forKey: "recordMic") {
let fileURL = URL(fileURLWithPath: filePath)
let document = try? qmaPackageHandle.load(from: fileURL)
Expand All @@ -415,6 +415,15 @@ class SCContext {
let saveURL = fileURL.deletingPathExtension().appendingPathExtension(format)
audioPlayerManager.saveFile(saveURL, saveAsMP3: exportMP3)
}
} else {
if !ud.bool(forKey: "showPreview") {
let title = "Recording Completed".local
let body = String(format: "File saved to: %@".local, filePath)
let id = "quickrecorder.completed.\(UUID().uuidString)"
showNotification(title: title, body: body, id: id)
} else {
showPreview(path: filePath, image: NSImage(named: "qmaIcon"))
}
}
}
}
Expand Down Expand Up @@ -448,9 +457,11 @@ class SCContext {
streamType = nil
}

static func showPreview(path: String) {
static func showPreview(path: String, image: NSImage? = nil) {
if !ud.bool(forKey: "showPreview") { return }
if let frame = firstFrame?.nsImage, let screen = getScreenWithMouse() {
var frame: NSImage?
if let i = image { frame = i } else { if let f = firstFrame?.nsImage { frame = f }}
if let frame = frame, let screen = getScreenWithMouse() {
let previewWindow = NSWindow(contentRect: NSMakeRect(0, 0, 260, 150), styleMask: [.fullSizeContentView], backing: .buffered, defer: false)
let contentView = NSHostingView(rootView: PreviewView(frame: frame, filePath: path))
previewWindow.contentView = contentView
Expand Down
6 changes: 3 additions & 3 deletions QuickRecorder/ViewModel/AreaSelector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ struct AreaSelector: View {
var window = NSWindow()
let area = SCContext.screenArea!
guard let nsScreen = screen.nsScreen else { return }
let frame = NSRect(x: Int(area.origin.x + nsScreen.frame.minX - 3),
y: Int(area.origin.y + nsScreen.frame.minY - 3),
width: Int(area.width + 6), height: Int(area.height + 6))
let frame = NSRect(x: Int(area.origin.x + nsScreen.frame.minX - 4),
y: Int(area.origin.y + nsScreen.frame.minY - 4),
width: Int(area.width + 8), height: Int(area.height + 8))
window = NSWindow(contentRect: frame, styleMask: [.fullSizeContentView], backing: .buffered, defer: false)
window.hasShadow = false
window.level = .screenSaver
Expand Down

0 comments on commit 1ab33b1

Please sign in to comment.