Re: AVSimplePlayer in Swift?
Re: AVSimplePlayer in Swift?
- Subject: Re: AVSimplePlayer in Swift?
- From: Charles Jenkins <email@hidden>
- Date: Mon, 09 Jan 2017 07:58:50 -0500
I will post code later today. In the meantime, I think I know what’s
happening, but not yet why. In short, the IB message is worthless, and KVO
is actually working. Ironically, proved that to myself by ditching it
altogether and switching currentTime back to using a local (non-computed)
property and didSet, but this time, in didSet I imitated the code in the
ObjC setCurrentTime() a little more closely.
What I found is if I comment out my call to player.seek(), the video plays
through and all the controls work (except of course no scrubbing). The
count of seconds reported by the periodic time observer (hereafter, PTO)
always increases.
But if I uncomment the player.seek() line, the video seems to be frozen on
the first frame and all the PTO requests are to seek back to 0.0.
I think what happens is, the video actually is playing, but the PTO checks
when it’s at 0.0, the player internally moves on, and then my KVO or didSet
requests a seek back to 0.0. And the process repeats ad infinitum. The PTO
is always a tiny bit behind where the video actually is, so it just keeps
requesting seeks backward.
It appears that if my setter for currentTime does the same thing as the
ObjC one, I’m toast.
On Sun, Jan 8, 2017 at 5:13 PM, Charles Srstka <email@hidden>
wrote:
> On Jan 8, 2017, at 1:12 PM, Quincey Morris <quinceymorris@
> rivergatesoftware.com> wrote:
>
>
> On Jan 8, 2017, at 05:49 , Charles Jenkins <email@hidden> wrote:
>
>
> changing to CDouble didn’t help
>
>
> This is one of those cases where I regretted pressing “Send” just 2
> minutes later. What I wrote was a thought process that didn’t make complete
> sense.
>
> There are 4 possibilities and you’ll need to narrow it down to one:
>
> 1. The property type is incorrect. You could try changing it to an
> explicit NSNumber, which is the type that the binding actually requires.
>
>
> This is not the problem; KVO works just fine with a property typed as
> Double as long as the property is marked ‘dynamic', which my sample code
> demonstrates (for some reason, the mailing list software separated the
> “.zip” from the rest of the link, so just add “.zip” to the end manually to
> download it).
>
> 2. The property accessors are not using the correct calling convention
> (@objc). If they’re in a view controller subclass (which is an @objc)
> object, they’ll normally be @objc, but there are some situations (e.g.
> declaring them private) that may make them native Swift. Leaving off the
> “dynamic” would come under this case too, but this was covered already.
>
>
> 3. The property declaration is fine, but IB is broken and doesn’t
> recognize the property as compatible. It may simply fail to set up the
> binding properly, even though it would work if it did. You could try
> leaving it unbound, and set up the binding at run time.
>
> 4. The property is fine, and something else is wrong.
>
> Finally, I’d note that the discussion in this thread had jumped back and
> forth between bindings and KVO. I’ve lost track of whether you’re saying
> that KVO isn’t working here (Charles posted sample code that he said
> works), or whether bindings aren’t working here.
>
>
> I think that seeing a simplified version of the code that isn’t working
> would be the easiest way to debug this at this point. OP, would you mind
> posting it?
>
> Charles
>
>
--
Charles
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden