fixed button to start/stop stream being behind the stream

the button has reactive text
the stream animates in and out when start/stopping
This commit is contained in:
neon443 committed 2026-07-21 19:47:20 +01:00
1 parent a2c3fd9fa3
commit 40402a91cc
16 files changed
+52 -46

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@
VERSION = 0.1
BUILD = 2
BUILD = 3
// Configuration settings file format documentation can be found at:
// https://developer.apple.com/documentation/xcode/adding-a-build-configuration-file-to-your-project
@@ -1,51 +1,61 @@
{
"images" : [
{
"filename" : "[email protected] 1 copy 6.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "[email protected] 1 copy 5.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "[email protected] 1 copy 4.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "[email protected] 1 copy 3.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "[email protected] 1 copy 2.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "[email protected] 1 copy 1.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "[email protected] 1 copy.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "[email protected] 1.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "Scream.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

+2 -2
View File
@@ -476,7 +476,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = "${BUILD}";
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = 8JGND254B7;
ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES;
@@ -521,7 +521,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = "${BUILD}";
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = 8JGND254B7;
ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES;
+21 -13
View File
@@ -10,33 +10,41 @@ import Cocoa
@main
class AppDelegate: NSObject, NSApplicationDelegate {
let sr = ScreenRecorder()
lazy var preview = CaptureVideoPreview(layer: sr.contentLayer)
let button = NSButton(title: "Start Stream", target: self, action: #selector(Button))
var isRunning = false
// let udpclient = UDPClientImplementation(port: 03067)
// let udpserver = UDPServerImplementation(host: "localhost", port: 03067, initialMessage: "kys")
@IBOutlet var window: NSWindow!
@IBAction func Button(_ sender: Any) {
isRunning.toggle()
print(isRunning, "\(isRunning ? "Stop" : "Start") Stream")
self.button.title = "\(isRunning ? "Stop" : "Start") Stream"
preview.layer?.opacity = isRunning ? 1 : 0
Task {
await sr.start()
if isRunning {
await sr.start()
} else {
await sr.stop()
}
}
}
// @IBAction func Button2(_ sender: Any) {
// udpclient.start()
// udpserver.start()
// }
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
let preview = CaptureVideoPreview(layer: sr.contentLayer)
preview.frame.size = window.contentView!.frame.size
window.contentView?.addSubview(preview)
Button(self)
// Button2(self)
window.contentView?.addSubview(button)
preview.translatesAutoresizingMaskIntoConstraints = false
preview.leadingAnchor.constraint(equalTo: window.contentView!.leadingAnchor).isActive = true
preview.trailingAnchor.constraint(equalTo: window.contentView!.trailingAnchor).isActive = true
preview.topAnchor.constraint(equalTo: window.contentView!.topAnchor).isActive = true
preview.bottomAnchor.constraint(equalTo: window.contentView!.bottomAnchor).isActive = true
}
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
func applicationWillTerminate(_ aNotification: Notification) { }
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
+15 -14
View File
@@ -89,17 +89,18 @@ class ScreenRecorder: NSObject {
}
}
extension ScreenRecorder: SCContentSharingPickerObserver {
@available(macOS 14, *)
func contentSharingPicker(_ picker: SCContentSharingPicker, didCancelFor stream: SCStream?) {
print("canceleed picker")
}
@available(macOS 14, *)
func contentSharingPicker(_ picker: SCContentSharingPicker, didUpdateWith filter: SCContentFilter, for stream: SCStream?) {
print(picker.description)
}
func contentSharingPickerStartDidFailWithError(_ error: any Error) {
print(error.localizedDescription)
}
}
//extension ScreenRecorder: SCContentSharingPickerObserver {
// if #available(macOS 14, *) {
// func contentSharingPicker(_ picker: SCContentSharingPicker, didCancelFor stream: SCStream?) {
// print("canceleed picker")
// }
// // @available(macOS 14, *)
// func contentSharingPicker(_ picker: SCContentSharingPicker, didUpdateWith filter: SCContentFilter, for stream: SCStream?) {
// print(picker.description)
// }
// }
//
// func contentSharingPickerStartDidFailWithError(_ error: any Error) {
// print(error.localizedDescription)
// }
//}
+3 -16
View File
@@ -203,29 +203,16 @@
<window title="Scream" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
<rect key="contentRect" x="335" y="390" width="800" height="470"/>
<rect key="screenRect" x="0.0" y="0.0" width="3200" height="1775"/>
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
<rect key="frame" x="0.0" y="0.0" width="800" height="470"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8In-w0-vJZ">
<rect key="frame" x="180" y="163" width="121" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="stream screen" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="ycE-q8-8mw">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="Button:" target="Voe-Tx-rLC" id="9Qu-NJ-TM0"/>
</connections>
</button>
</subviews>
</view>
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="top-28-M4D"/>
</connections>
<point key="canvasLocation" x="200" y="400"/>
<point key="canvasLocation" x="360" y="455"/>
</window>
</objects>
</document>
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.