Copy link to clipboard
Copied
Hi
I am looking for a way to hide and show a video in PDF using JavaScript. Anyone tried something similiar?
Best
Jonas
Copy link to clipboard
Copied
Do you mean play and stop playing it?
Copy link to clipboard
Copied
no, that would not be a problem.
I am looking for a way to hide or show a embedded Video. When you click on a button within the PDF the video disappears and when you click on another button the video shows up again.
Copy link to clipboard
Copied
You can change the rect property of the Rich Media Annotation object so that it's practically invisible and then back to its original size. That's the only way I can see to do it.
Copy link to clipboard
Copied
Thanks, sounds good and how would you do it? With Javascript? How can I target the Video.
Much appreciated
Copy link to clipboard
Copied
Actually, I tried it and for some reason it doesn't seem to work. When I change the rect property of the annotation it doesn't make any difference...
Copy link to clipboard
Copied
how was your approach? Can you share the JS and actions you set for the button?
Copy link to clipboard
Copied
This is the code I (tried) to use:
var videoAnnot = this.getAnnotsRichMedia(0)[0];
var r = videoAnnot.rect;
if (r[0]==0 && r[1]==0 && r[2]==0 && r[3]==0)
r = [103.44267272949219,721.2828369140625,281.0313720703125,639.4658203125]; // paste the real values between the square brackets;
else r = [0,0,0,0];
videoAnnot.rect = r;
Copy link to clipboard
Copied
Ok, Thanks for the code.
I think the problem is, that you don't have a "name/id" to target the Video/Media file directly.
Did you create a button and set it to OnClick and when you click on the button execute you JavaScript?
Copy link to clipboard
Copied
Also would it be easier, to have one button how shrinks all videos to size 0 and a button which enlarges all videos back to original size?
Copy link to clipboard
Copied
I tried it both ways and neither worked.
And yes, I did add a button that executes this code on the MouseUp event. I also tried running it from the JS Console, and neither worked.
If you come up with a different solution I'll be happy to hear it.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more