Control video on parent page from child page


(chans) #1

I have a video (videoid) on Hype parent page and an iframe (mini website inside with button1).

I run this code on parent page and it is ok, work perfectly, videoid play well.
hypeDocument.getElementById(‘videoid’).play();

But when I run this code on child page, it does not work.
parent.hypeDocument.getElementById(‘videoid’).play();

Anyone help me?
Thank you.


#2

Possible duplicate of this post:

Try not to create more than one post for the same thing!

It’s difficult to understand what you have when you say “Hype parent page”. Do you mean you have a HTML page with more than one Hype document or you have a Hype document with an iframe in it?

IF it’s the later, then I showed you the technique of accessing an iframe (widget) within Hype in the other post. If it’s the former then Hype has a way of being accessed outside the document (i.e from a separate part of the HTML by using

HYPE.documents["documentName"];

http://tumult.com/hype/documentation/3.0/#invoking-api-from-outside-oftumult-hype

Is this another Hype document or just HTML?


(chans) #3

Sorry, Iam just a little girl 9 years old from japan.
My english is not well.
I mean Hype document with an iframe in it.
I mean i cant call parent.hypeDocument.getElementById(‘videoid’).play(); via button on iframe.
Thank you


(Jonathan Deutsch) #4

You can probably just call parent.getElementById("videoid").play(). If it is a regular HTML5 video (like that which is made by dragging a .mp4 into Hype), then you don’t need to use the hypeDocument API version.

If you do need to use the HypeDocument API, then you would need to replace hypeDocument with HYPE.documents["documentName"] as @DBear mentioned.


(chans) #5

Thank jonathan.
I tried that way but it did not work.
parent.getElementById(‘videoid’).play();
Nothing happend when I click on playvideo button.
Help me please
testvideo2.zip (1.5 MB)


(Jonathan Deutsch) #6

Whoops, my bad… the call should be:

parent.document.getElementById("videoid").play()

(I missed the .document) It works for me if I fix this.


(Jonathan Deutsch) #7

Also note that you cannot open the .html file in the Finder; if it uses a file:/// URL it will not work. It must be live/on a web server.