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 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