Post

Replies

Boosts

Views

Activity

Reply to FYI: Playing a movie using AVPlayer in Big Sur
Belated follow-up to my own question. The following code works, and is not much different than that already posted. So my problem must have been in the storyboard. import AVKit // macOS & iOS class ViewController_myProduction: NSViewController { @IBOutlet var myMOV: AVPlayerView! override func viewDidLoad() { super.viewDidLoad() let playerView = AVPlayerView() playerView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(playerView) if #available(macOS 11.0, *) { playerView.leadingAnchor.constraint (equalTo: view.safeAreaLayoutGuide.leadingAnchor ).isActive = true playerView.trailingAnchor.constraint (equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true playerView.topAnchor.constraint (equalTo: view.safeAreaLayoutGuide.topAnchor ).isActive = true playerView.bottomAnchor.constraint (equalTo: view.safeAreaLayoutGuide.bottomAnchor ).isActive = true } else { // Fallback on earlier versions } playerView.controlsStyle = .floating playerView.showsFrameSteppingButtons = true playerView.showsFullScreenToggleButton = true guard let path = Bundle.main.url(forResource: "myProduction", withExtension: "mov") else { return } let player = AVPlayer(url: path) playerView.player = player playerView.player?.play() } } note to self: code-block + Edit:"Paste and Match Style"
Jan ’22
Reply to Delegation in Swift
Sorry, robnotyou, I should have posted the link: https://developer.apple.com/forums/thread/694710 to my previous post where Claude31 contributed heavily. In it Clause31 creates example program with a progressBar within the VC class and thus progressBar.doubleValue is recognized. But in my actual app "remote func" is not in the VC class nor any other class but is just in a separate file, alone, by itself at 800 lines of code. I don't want to fatten my already bloated VC file. The remote function runs many iterations thus the need for a progress indicator. A delegate (if I understand correctly) will update the progressBar.doubleValue even though the delegate itself is changed in the remote func. I hope that is clearer. I may be asking for something that can't be done. I have dabbled in SwiftUI and what I am asking for in Swift is something analogous to an EnvironmentVariable update scheme, i.e., when the other file changes a value it is reflected in the VC. wherever it is needed.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’21
Reply to Missing Fundamental something
I understand about multiple issues. I'll try to keep them separate in the future. Thanks. You looked into this pretty deeply, and it reminds me of a mathematicians proof. They can be more litigious than lawyers, and necessarily so. I didn't submit my case well. I just find it curious that if you run the min/max code on ranges =[ 1...4 ,0...0 ,1...6 ,3...5 ,0...0 ,2...4 ,3...7 ] you get a min=1 and max=7, and that is what I expect when looking at the data. But now swap the first and second entries so that: ranges = [ 0...0 ,1...4 ,1...6 ,3...5 ,0...0 ,2...4 ,3...7 ] the result is min=0 and max=0 It is the same data, just rearranged. The results are dramatically different. The reason for it still eludes me. Filtering is a good way to go. Thanks.
Topic: Media Technologies SubTopic: Audio Tags:
Oct ’21
Reply to Missing Fundamental something
As for the second problem... Try this on your Playground: import UIKit let ranges = [ 1...4 ,0...0 ,0...1 ,3...5 ,0...0 ,2...4 ,3...7 ] let ordinateMinimum = CGFloat(ranges.min(by: {$0 != 0...0 && $1 != 0...0 && $0.lowerBound < $1.lowerBound})!.lowerBound) let ordinateMaximum = CGFloat(ranges.max(by: {$0 != 0...0 && $1 != 0...0 && $0.upperBound < $1.upperBound})!.upperBound) print("ordinateMinimum: \(ordinateMinimum)\nordinateMaximum: \(ordinateMaximum)") Now if you erase the first entry 1...4 so that 0...0 is the first entry, you will get a totally different and WRONG answer! Curious.
Topic: Media Technologies SubTopic: Audio Tags:
Oct ’21
Reply to Missing Fundamental something
Thanks for the reply Claude31. **What do you get exactly ? Nothing ? some drawing, partly outside ?** Just a grey window. No indication of drawing anywhere. **add path.stroke() after shapeLayer.strikeColor = ...** When added I get the error: "Value of type 'CGMutablePath' has no member 'stroke'" You also mention in code: // ranges.append(0...0) // inexplicably FAILS! @ ordinateMinimum/ordinateMaximum if replaces "if N == 1" below Where does this fail ? ranges.append(0...0) does not fail where do you compute ordinateMinimum/ordinateMaximum ? When the following lines are executed, the result is ordinateMinimum = 0 AND ordinateMaximum = 0 which then results in ordinateScale = inf ordinateMinimum = CGFloat(ranges.min(by: {$0 != 0...0 && $1 != 0...0 && $0.lowerBound < $1.lowerBound})!.lowerBound) ordinateMaximum = CGFloat(ranges.max(by: {$0 != 0...0 && $1 != 0...0 && $0.upperBound < $1.upperBound})!.upperBound) ordinateScale = analysisView.frame.height/(ordinateMaximum - ordinateMinimum)
Topic: Media Technologies SubTopic: Audio Tags:
Oct ’21
Reply to FYI: Playing a movie using AVPlayer in Big Sur
Belated follow-up to my own question. The following code works, and is not much different than that already posted. So my problem must have been in the storyboard. import AVKit // macOS & iOS class ViewController_myProduction: NSViewController { @IBOutlet var myMOV: AVPlayerView! override func viewDidLoad() { super.viewDidLoad() let playerView = AVPlayerView() playerView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(playerView) if #available(macOS 11.0, *) { playerView.leadingAnchor.constraint (equalTo: view.safeAreaLayoutGuide.leadingAnchor ).isActive = true playerView.trailingAnchor.constraint (equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true playerView.topAnchor.constraint (equalTo: view.safeAreaLayoutGuide.topAnchor ).isActive = true playerView.bottomAnchor.constraint (equalTo: view.safeAreaLayoutGuide.bottomAnchor ).isActive = true } else { // Fallback on earlier versions } playerView.controlsStyle = .floating playerView.showsFrameSteppingButtons = true playerView.showsFullScreenToggleButton = true guard let path = Bundle.main.url(forResource: "myProduction", withExtension: "mov") else { return } let player = AVPlayer(url: path) playerView.player = player playerView.player?.play() } } note to self: code-block + Edit:"Paste and Match Style"
Replies
Boosts
Views
Activity
Jan ’22
Reply to Delegation in Swift
Sorry, robnotyou, I should have posted the link: https://developer.apple.com/forums/thread/694710 to my previous post where Claude31 contributed heavily. In it Clause31 creates example program with a progressBar within the VC class and thus progressBar.doubleValue is recognized. But in my actual app "remote func" is not in the VC class nor any other class but is just in a separate file, alone, by itself at 800 lines of code. I don't want to fatten my already bloated VC file. The remote function runs many iterations thus the need for a progress indicator. A delegate (if I understand correctly) will update the progressBar.doubleValue even though the delegate itself is changed in the remote func. I hope that is clearer. I may be asking for something that can't be done. I have dabbled in SwiftUI and what I am asking for in Swift is something analogous to an EnvironmentVariable update scheme, i.e., when the other file changes a value it is reflected in the VC. wherever it is needed.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to ProgressBar with DispatchQueue
Claude31, first, thank you for the example of a progress bar with DispatchQueue. I can now advance. I have closed this thread and opened another with this delegation subject, since it is another issue deserving credit.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to ProgressBar with DispatchQueue
Yeah you are right mikander... and I forgot I did that. So yes I used a macOS playground. Then, there is no simulator for macOS. Hmm.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to ProgressBar with DispatchQueue
It appears playground doesn't do macOS. When I go to Xcode/Preferences/Components the only entries are iOS, tvOS, and watchOS. So AppKit is not recognized.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Missing Fundamental something
I understand about multiple issues. I'll try to keep them separate in the future. Thanks. You looked into this pretty deeply, and it reminds me of a mathematicians proof. They can be more litigious than lawyers, and necessarily so. I didn't submit my case well. I just find it curious that if you run the min/max code on ranges =[ 1...4 ,0...0 ,1...6 ,3...5 ,0...0 ,2...4 ,3...7 ] you get a min=1 and max=7, and that is what I expect when looking at the data. But now swap the first and second entries so that: ranges = [ 0...0 ,1...4 ,1...6 ,3...5 ,0...0 ,2...4 ,3...7 ] the result is min=0 and max=0 It is the same data, just rearranged. The results are dramatically different. The reason for it still eludes me. Filtering is a good way to go. Thanks.
Topic: Media Technologies SubTopic: Audio Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Missing Fundamental something
As for the second problem... Try this on your Playground: import UIKit let ranges = [ 1...4 ,0...0 ,0...1 ,3...5 ,0...0 ,2...4 ,3...7 ] let ordinateMinimum = CGFloat(ranges.min(by: {$0 != 0...0 && $1 != 0...0 && $0.lowerBound < $1.lowerBound})!.lowerBound) let ordinateMaximum = CGFloat(ranges.max(by: {$0 != 0...0 && $1 != 0...0 && $0.upperBound < $1.upperBound})!.upperBound) print("ordinateMinimum: \(ordinateMinimum)\nordinateMaximum: \(ordinateMaximum)") Now if you erase the first entry 1...4 so that 0...0 is the first entry, you will get a totally different and WRONG answer! Curious.
Topic: Media Technologies SubTopic: Audio Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Missing Fundamental something
Thanks for the reply Claude31. **What do you get exactly ? Nothing ? some drawing, partly outside ?** Just a grey window. No indication of drawing anywhere. **add path.stroke() after shapeLayer.strikeColor = ...** When added I get the error: "Value of type 'CGMutablePath' has no member 'stroke'" You also mention in code: // ranges.append(0...0) // inexplicably FAILS! @ ordinateMinimum/ordinateMaximum if replaces "if N == 1" below Where does this fail ? ranges.append(0...0) does not fail where do you compute ordinateMinimum/ordinateMaximum ? When the following lines are executed, the result is ordinateMinimum = 0 AND ordinateMaximum = 0 which then results in ordinateScale = inf ordinateMinimum = CGFloat(ranges.min(by: {$0 != 0...0 && $1 != 0...0 && $0.lowerBound < $1.lowerBound})!.lowerBound) ordinateMaximum = CGFloat(ranges.max(by: {$0 != 0...0 && $1 != 0...0 && $0.upperBound < $1.upperBound})!.upperBound) ordinateScale = analysisView.frame.height/(ordinateMaximum - ordinateMinimum)
Topic: Media Technologies SubTopic: Audio Tags:
Replies
Boosts
Views
Activity
Oct ’21