Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

avfoundation - AVPlayerItem kills views controlled by NSViewAnimation

Short version (TLDR): making an AVPlayerView visible oddly causes some other animated views in the common-hosted NSWindow to randomly go blank.

I have two or more concurrent AVPlayer objects running, playing movies. In a small, on-screen monitor, I use an AVPlayerView to tap the contents of each of these AVPlayer instances.

Using a single AVPlayerView and swapping in the player property is problematic as all the running videos lag slightly during this assignment. Even attempting a dispatch_async back to the main thread to do the assignment didn't fix the issue.

My solution has been to instantiate 2 or 3 AVPlayerView instances and add them as hidden subViews to an overarching view. And here's the trick: Only one of these views is visible at at time. Doing this seems to avoid the lag issue when I switch to making another AVPlayerView the lone visible view, with all its siblings hidden. It's important to mention that none of these views are initially visible as the parent NSViewController isn't visible.

But here's the oddity: When I make the overarching view visible (which is under the auspices of that NSViewController), an unrelated NSTableView cell goes blank in my window. The only thing common between these views is the parent NSWindow. I'm using an animator on NSTableViewCell but its NSTextField content is visually static at the time. Assigning the value of this NSTextField either statically or via Cocoa bindings makes no difference. Other non-animated cells in the table don't share the same disappearing fate.

I have a suspicion that AVPlayerView is always automatically layer-backed. Currently none of the views in my window are explicitly layer-backed. I tried mixing toggling these on/off through the view hierarchy in IB, with no change in my results.

For what its worth, I do receive the error:GVA warning: addNewReferenceEntry_MMCO mmcoFunc1 not found requested 5, curr = 8 during the appearance of the hosting NSViewController.

This is a strange thing -- not sure why this is happening. Running Xcode 10.3 (10G8) on OSX 10.14.6. I have heard that AVPlayerViews have issues on Xcode 10.2.x.

question from:https://stackoverflow.com/questions/65909380/avplayeritem-kills-views-controlled-by-nsviewanimation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...