Continuing timeline from external javascript


(James Morgan) #1

I’m embedding an animation within a webview in an app and I have existing player controls that I’m using outside of my hype document. I’m having issues getting my timeline to resume playback after being paused, then going to a specific time.
Here’s the code I’m using to go to a point on the timeline, which works:
HYPE.documents[‘NPM Family Intro ENG’].goToTimeInTimelineNamed(60, ‘Main Timeline’, HYPE.documents[‘NPM Family Intro ENG’])

Here’s what I’ve been using to try and resume the play after I’ve executed the above function:
HYPE.documents[‘NPM Family Intro ENG’].hypeDocument.continueTimelineNamed(‘Main Timeline’, HYPE.documents[‘NPM Family Intro ENG’], HYPE.documents[‘NPM Family Intro ENG’].hypeDocument.kDirectionForward, false)
I’ve also tried:
HYPE.documents[‘NPM Family Intro ENG’].hypeDocument.continueTimelineNamed(‘Main Timeline’, hypeDocument.kDirectionForward, false)

I’m sure this is super simple, but I’m at a loss here. Thanks in advance for your help.


(James Morgan) #2

bump


#3

First things first … the reason for lack of replies is that it’s the weekend so no need to bump. :wink: Perhaps, a note to say that it’s quite urgent within the first post may have gathered a few replies but as I said it’s the weekend and generally it’s quieter on the forums.

That being said, you also may want to highlight your code by clicking the button in the toolbar above this text box. This will format the code so it’s easier to see like this…

HYPE.documents['NPM Family Intro ENG'].goToTimeInTimelineNamed(60, 'Main Timeline', HYPE.documents['NPM Family Intro ENG'])

On to the possible solution.

Basically, when accessing a Hype document from outside it’s scope you would replace every instance of hypeDocument with HYPE.documents['My Document Name'] as you have done (in places).

So to issue a “continue timeline” command you would use the API’s

// hypeDocument.continueTimelineNamed(timelineName, direction, canRestartTimeline)
hypeDocument.continueTimelineNamed('timelineName', hypeDocument.kDirectionForward, false)

So, this would become

HYPE.documents['My Document Name'].continueTimelineNamed('timelineName', HYPE.documents['My Document Name'].kDirectionForward, false)

Now, in your code above you have

HYPE.documents['NPM Family Intro ENG'].goToTimeInTimelineNamed(60, 'Main Timeline', HYPE.documents['NPM Family Intro ENG'])

and this is 95% correct but you do not need the last ‘HYPE.documents’ call as the API method is

hypeDocument.goToTimeInTimelineNamed(timeInSeconds, timelineName)

and in the next one you have

HYPE.documents['NPM Family Intro ENG'].hypeDocument.continueTimelineNamed('Main Timeline', HYPE.documents['NPM Family Intro ENG'], HYPE.documents['NPM Family Intro ENG'].hypeDocument.kDirectionForward, false)

which is a whole heap of wrong. As stated above you only need to replace the hypeDocument with HYPE.documents[‘my Doc’]

So, your code should really read

HYPE.documents['NPM Family Intro ENG'].goToTimeInTimelineNamed(60, 'Main Timeline')

// and 

HYPE.documents['NPM Family Intro ENG'].continueTimelineNamed('Main Timeline', HYPE.documents['NPM Family Intro ENG'].kDirectionForward, false)

If you also omit the direction the default will be forward so you don’t have to include that if you don’t want.


(James Morgan) #4

Hi,

I really appreciate your response and your tips that I’ll take in to account next time. Formatting the code as you suggested works perfectly. Thanks so much!

James


(James Morgan) #5

Spoke a little too soon. Any idea why the continue playback might work on iOS within a webview, but not on Android? I’m not seeing any errors thrown up in chrome://inspect. The go to timecode seems to be functioning correctly.


(James Morgan) #6

Was down to the platform I’m using not allowing me to fire to calls in succession.