mergAVPlayerCreateFromURL in IDE

Sean Cole (Pi) sean at pidigital.co.uk
Fri Feb 23 06:09:18 EST 2018


The reason for using this as opposed to the engine/mobile controls is CODE
ONCE. mergAV works for both Mac AND iOS which are the two platforms my
client requires it for. According to the dictionary, the player object is
only for Mac, Windows and Linux still. So I would have to set up a heap of
conditionals for iOS and then Mac. But, seeing as this bug won't get fixed
anytime soon and my client is waiting for this new feature to be added I'm
going to have to go down this route anyway. This is the issue I face all
too often with LiveCode. Hunting for hours for the reason why something
small doesn't do what it's supposed to (this has taken 8hrs to track down!
😡) and then coming to the realisation that the bug fix cycle is too damned
long compared to the quick turnarounds I have with my clients (often
between a few days to a couple of weeks) so end up spending more time
coming up with workarounds.

Here's a recipe:


   1. New stack and card with a single button.
   2. mouseUp handler in button to call showMedia
   3. Card script contain:

local sPlayerID

on showMedia

    put 0,0,512,384 into tRect

    put mergAVPlayerCreateFromURL("
https://livecode.pidigital.co.uk/HappyClip.mp4") into sPlayerID

    mergAVPlayerSet sPlayerID, "visible", "true"

    mergAVPlayerSet sPlayerID, "rect", tRect

    mergAVPlayerSet sPlayerID,"visible","true"

    mergAVPlayerSet sPlayerID, "rect", tRect

    put mergAVPlayerGet(sPlayerID,"rect") into tRect2

    put mergAVPlayerGet(sPlayerID,"rate") into tRate

    put mergAVPlayerGet(sPlayerID,"visible") into tVis

    put mergAVPlayerGet(sPlayerID,"duration") into tDuration

    put mergAVPlayerGet(sPlayerID,"current time") into tCurr

    put (sPlayerID &cr& gMedia &cr& tRect &cr& tRect2 &cr& tVis &cr& tRate &
cr& tDuration &cr& tCurr)

    mergAVPlayerDo sPlayerID, "play"

end showMedia


on AVPlayerItemDidPlayToEndTimeNotification pPlayerID

    mergAVPlayerRelease pPlayerID

end AVPlayerItemDidPlayToEndTimeNotification


Notice what happens when you delete the last line that sets the Rect.
Setting the Visible property has no effect but the order of Visible and
Rect setters have an effect on the Rect value. On an iOS device and the
simulator, it works fine either way. Mac and IDE it does not.


Have fun. I'll copy paste this into a bug report. Then get on to making the
workaround so my client can finally get what he could have had yesterday!
#LCneverFitForPurpose




Sean Cole
*Pi Digital *


On 23 February 2018 at 03:07, Monte Goulding via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Hmm… that seems unpleasant. Unfortunately it probably hasn’t been used
> much before on mac so if you can post a bug report with your issues that
> would be good. What was the reason you are using mergAVPlayer instead of
> the engine player/mobile control options?
>
> Cheers
>
> Monte
>
> > On 23 Feb 2018, at 1:34 pm, Sean Cole (Pi) via use-livecode <
> use-livecode at lists.runrev.com> wrote:
> >
> > Ok, weird. So, after working out that mergAVPlayerCreateFromURL needs to
> > use a 'put' command as a function, the video would play but not be
> > visible despite that property being set to true. Further investigation
> > showed that the rect when set to 0,0,1024,768 would read back (using
> > mergAVPlayerGet) as 0,-768,1024,768. If I set it to 0,0,512,384, it
> returns
> > 0,-384,512,384. Setting to 0,200,512,384 returns 0,-384,512,184.
> >
> >
> > Sean Cole
> > *Pi Digital Productions Ltd*
> > www.pidigital.co.uk
> > +44(1634)402193
> > +44(7702)116447
> > 'Don't try to think outside the box. Just remember the truth: There is no
> > box!'
> > 'For then you realise it is not the box you are trying to look outside
> of,
> > but it is yourself!'
> >
> > eMail Ts & Cs <http://pidigital.co.uk/emailTCs.rtf>   Pi Digital
> > Productions Ltd is a UK registered limited company, no. 5255609
> >
> > On 22 February 2018 at 22:14, Monte Goulding via use-livecode <
> > use-livecode at lists.runrev.com> wrote:
> >
> >>
> >> Yes it should work on Mac in the IDE. I don’t know if it has ever been
> >> used much because player objects make more sense on desktop. Looks like
> you
> >> need to set the visible to true after creating it but on iOS that
> probably
> >> isn’t required...
> >>
> >> Cheers
> >>
> >> Monte
> >>
> >>> On 23 Feb 2018, at 3:20 am, Sean Cole (Pi) via use-livecode <
> >> use-livecode at lists.runrev.com> wrote:
> >>>
> >>> Hi,
> >>>
> >>> Is there any way to get mergAVPlayerCreateFromURL to work within the
> >> IDE? I
> >>> would like to test it without building a standalone for bug locating.
> >>>
> >>> Thanks
> >>> Sean Cole
> >>> *Pi Digital *
> >>> _______________________________________________
> >>> use-livecode mailing list
> >>> use-livecode at lists.runrev.com
> >>> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >>> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>
> >>
> >> _______________________________________________
> >> use-livecode mailing list
> >> use-livecode at lists.runrev.com
> >> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >> http://lists.runrev.com/mailman/listinfo/use-livecode
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list