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

how do I tell embedded sound to stop playing on certain page of pdf?

New Here ,
Mar 30, 2016 Mar 30, 2016

I am making an e-book and want to have songs play to accompany certain pages of the book.

The problem is that if the song doesn't finish playing it continues onto the next page where a new song is supposed to start - so they play over each other.

Is there a way to fix this?

TOPICS
Acrobat SDK and JavaScript
2.1K
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
Engaged ,
Mar 31, 2016 Mar 31, 2016

Just set the sound object to "Disable When: The page containing the content is closed." in the properties panel.

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 ,
Mar 31, 2016 Mar 31, 2016

the only problem is some sounds are meant to continue over multiple pages

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
Engaged ,
Mar 31, 2016 Mar 31, 2016

Ok - So testing for understanding...

You'd like the currently playing sound to stop playing when it reaches the end of the sound file or when the user gets to a page that has it's own sound annotation on it?

How are the sounds get started playing?

J-

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 ,
Mar 31, 2016 Mar 31, 2016

Yes, exactly.

The sounds start playing when the user opens to the page with the sound media player on it .

In adobe acrobat I went to tools - content - multimedia - sound - then drew a box and chose the mp3 I wanted to upload.

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
Engaged ,
Apr 01, 2016 Apr 01, 2016

Ok - I haven't actually tested this code but I think I got it right. If you can send me the file in question, I can check it.

Anyway. Since  the user can activate a rich media annotation in a variety of ways and you can't reliably get a handle to which ones one active, you need to turn every one of them in the document off before starting the one on the page you want.

Add this code to the "Page Open" script for each page with a sound. The code will go through the document page by page looking for sound annotations and turning them off when not on the active page. Then it will turn on the sound on the current page.

// iterate through all the pages in the document and deactivate any playing sound files

for (var i=0;i < this.numPages;i++) {

  // chech that we're not on the current page

  if (i != this.pageNum) {

  // check if the page has a richMediaAnnotation

  if (typeof this.getAnnotsRichMedia(i) !== "undefined") {

  // assuming there is only one sound file

  if (this.getAnnotsRichMedia(i)[0].activated == true) {

  this.getAnnotsRichMedia(i)[0].activated = false;

  }

  }

  }

}

// Activate the sound on the page the user is on.

this.getAnnotsRichMedia(this.pageNum)[0].activated == true;

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 ,
Apr 01, 2016 Apr 01, 2016

Okay - looks  promising! I just tried figuring out how to put in the code myself and I couldn't do it.

I think it would be better if you could try it - if you have time!

Here is a link to download my e-book

https://www.dropbox.com/s/0n295jrglwj0a00/E-Book.pdf.zip?dl=0

Also here is my email

abbyl17@gmail.com

Thanks so much for all of your help!

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 ,
Apr 01, 2016 Apr 01, 2016

actually use this pdf

Dropbox - E-Book.pdf 2.zip

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
Engaged ,
Apr 05, 2016 Apr 05, 2016
LATEST

Ok - I'll take a look and see what I can do.

J-

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