Precise stepping and seeking with AVFoundation is - in my experience - a very difficult to solve problem.
I had to use AVSampleCursor to build a table of frame times and seek(to:toleranceBefore:toleranceAfter:) to get working results.
Post
Replies
Boosts
Views
Activity
Thanks! Finally some info about the future of Swift Playgrounds on iPad. I was starting to get worried!
Could this be a problem with the ARC memory management of Swift? Most probable you have to use a @autoreleasepool at the right level to get rid of of autoreleased objects during your loop.
Apple still needs to Update Swift Playgrounds App to Swift 6 and iPadOS 18 APIs.
And it is about time!
It is particularly important to them to drive all navigation from state as described here:
https://swiftpackageindex.com/pointfreeco/swiftui-navigation/main/documentation/swiftuinavigation/whatisnavigation#State-driven-navigation
Have you considered the navigation library from the people at point.free?
https://github.com/pointfreeco/swiftui-navigation
They have corresponding videos about the subject
https://www.pointfree.co/collections/swiftui/navigation
some of them are free:
https://www.pointfree.co/episodes/free
Leave the @preconcurrency attribute in and ignore the warning (for now). I heard it is a bug in some version if the compiler betas.
Have you tried the same with Xcode 16.0 Release Candidate (Sep 9th)? It should aready have a newer compiler than Xcode 16.1 (Aug 12th).
This works in my code:
try await PHPhotoLibrary.shared().performChanges{@Sendable in
...
}
but be sure to only capture sendable values in the closure.
If someone later finds this, the following worked for me
performChanges{@Sendable in ... }
I had the same problem again later with PHImageManager.requestAVAsset{}, the solution is the same.
I had a similar problem in recording video from the camera. I had to add the AVCaptureMovieFileOutput to the capture session right after setting up the AVCaptureDevice. When the user pressed the record button at a later time it worked without black frames.
But when I did set up the AVCaptureMovieFileOutput only after the user pressed record I got black frames at the start of the recorded movie.
Does anyone know what is the problem here?
This is „expected behaviour“: https://samwize.com/2024/05/08/do-not-init-state-externally-in-swiftui-view/
This still does not seem to work in iPadOS 18 beta 1. What am I doing wrong?
Perhaps I misunderstand your question, but the way I see it:
There is nothing „silly“ about this behaviour, because the "background" is part of and encoded into the video. Is there even a standard for "transparent video“? How should the video player know which part of the video you consider "background".
If you meant to remove the "black bars" of letterboxed widescreen videos they may also be part of the video or if not, make sure you size the video player to the correct aspect ratio to prevent it from padding your video. (I have not tested this).
Adiitionally: Don't confuse running the body with "view creation". Running the body does not really show anything yet.
Have a look at the following article: https://www.massicotte.org/isolation-intuition about Swift Isolation Intuition.
Perhaps it will help you understand where Swift runs your code.