Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Hide/Show embedded Video in PDF using JavaScript

New Here ,
Jul 10, 2018 Jul 10, 2018

Hi

I am looking for a way to hide and show a video in PDF using JavaScript. Anyone tried something similiar?

Best

Jonas

TOPICS
Create PDFs
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2018 Jul 10, 2018

Do you mean play and stop playing it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2018 Jul 10, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2018 Jul 10, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2018 Jul 10, 2018

Thanks, sounds good and how would you do it? With Javascript? How can I target the Video.

Much appreciated

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2018 Jul 10, 2018

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2018 Jul 10, 2018

how was your approach? Can you share the JS and actions you set for the button?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2018 Jul 10, 2018

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2018 Jul 10, 2018

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2018 Jul 10, 2018

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2018 Jul 10, 2018
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines