12 Replies Latest reply on Mar 25, 2015 3:00 PM by animatorjenn

    Navigation Point and Movie Event Listeners?

    animatorjenn

      Hi - I'm working on writing a script for InDesign -

       

      What I am looking to do is to add event listeners to movies and navigation points. My goal is to make certain content visible or hidden at certain points while a movie plays.

       

      I can't find documentation of event listeners for navigation points and movies anywhere... can anyone help point me in the right direction?

       

      Basically, the code looks like:

       

       

      (where obj is an instance of a movie....)

       

      for(i=0; i<obj.navigationPoints.length; i++){

       

                     obj.navigationPoints[i].addEventListener (eventName, handler, capturePhase);

       

      }

       

      I need to know what the options are for the eventName parameter.

       

      I would also like to know what the options are when a movie is played. (I'm trying to resolve the circumstance where someone plays a video from somewhere in the middle - and I want the content to change contextually.

       

      I am looking to add this to the functionality of my epubs.

       

      Thanks

        • 1. Re: Navigation Point and Movie Event Listeners?
          Steve Werner Adobe Community Professional & MVP

          It can't be done in InDesign. If it could be done, it would be in Acrobat Pro.

           

          Please ask here:

           

          Rich Media & 3D

          • 2. Re: Navigation Point and Movie Event Listeners?
            Steve Werner Adobe Community Professional & MVP

            OK, my bad. I didn't see your final line about using it for EPUB. In EPUB, it would have to be done manually with JavaScript if it's possible.

             

            I'm moving this post to the InDesign EPUB forum.

             

            You'll need to tell your InDesign version and whether you're creating reflowable or Fixed layout EPUB files, and EPUB2 or EPUB3

            • 3. Re: Navigation Point and Movie Event Listeners?
              animatorjenn Level 1

              Thanks - yeah, I'm a JavaScript coder and am looking for the list of available events so that I can use them.

               

              I appreciate you trying to help me figure it out, Steve.

              • 4. Re: Navigation Point and Movie Event Listeners?
                animatorjenn Level 1

                Actually, I thought I was posting this in the InDesign scripting forum but maybe that isn't where I landed (I've been searching this topic like a crazy person for a few days now) - that forum would probably be the best place for this question as it is code related. If you have the power to move it there, and wouldn't mind doing so, I would be very appreciative.

                • 5. Re: Navigation Point and Movie Event Listeners?
                  Steve Werner Adobe Community Professional & MVP

                  Yes, you'll probably find more coders there. Here's the link:

                   

                  InDesign Scripting

                  • 6. Re: Navigation Point and Movie Event Listeners?
                    Laubender Adobe Community Professional & MVP

                    @animatorjenn – I dont't think you can do what you want by adding an event listener to an InDesign NavigationPoint object.
                    Even, if you could, that event could only be listened to in InDesign. Not in the exported EPUB.

                     

                    A possible workaround: Use a HTML5/CSS/JavaScript widget (perhaps by using JQuery?) by inserting HTML and exporting that together with all other page items to EPUB; I'm not sure, if this will work at all because of size of the needed code or other circumstances. Or implement that widget after the EPUB is exported.

                     

                    Uwe

                    • 7. Re: Navigation Point and Movie Event Listeners?
                      animatorjenn Level 1

                      Thanks Laubender - I wasn't aware of the boundaries of the scripting interface - I'm looking up what I can about widgets. So far, they seem pretty straightforward.

                       

                      Hopefully someone @ Adobe will hear my pleas and work on better video options and maybe even a smoother workflow for wiring up buttons for a future release.

                       

                      All the best

                      Jenn

                      • 8. Re: Navigation Point and Movie Event Listeners?
                        Laubender Adobe Community Professional & MVP

                        Jenn – oh, we already had that years ago ;-)
                        But it was all Flash(ActionScript 3-based…

                         

                        Uwe

                        • 9. Re: Navigation Point and Movie Event Listeners?
                          animatorjenn Level 1

                          Yeah - I'm sad that all of that functionality has been shelved - I'm a reformed AS3 dev. So many things were much better when you had a platform that was device agnostic. There were tradeoffs with Flash, but it was pretty handy.

                          • 10. Re: Navigation Point and Movie Event Listeners?
                            animatorjenn Level 1

                            My current path for resolving this has led me down the path of unzipping the epub file and getting to the idGeneratedScript.js file. I feel like I discovered gold.

                             

                            Should you be of a developer mindset... read on and if you see flaws and wouldn't mind let me know what I'm not seeing, that would rock. Otherwise, I'll post up what worked when I get the following working....

                             

                            THE PLAN.... (modifying the idGeneratedScript.js file.... which is zipped in the ePub file)

                             

                            IF there is a button on a page that cues a video that ALSO cues content to appear or disappear...

                             

                            • Create a function that looks for any and all Video-Player_Video-Player---Button objects on the page that trigger the function onMediaStart();
                              • Inside that onMediaStart() function, there are 3 parameters -
                                1. what video they trigger
                                2. what timecode they start at and
                                3. a delay, if any
                              • The function I'm going to create would store both the timecode values and the ID names of the buttons that called them in numerical order, in an object/pair inside of an array.
                              • Make sure that that array has a reference to the movie that the buttons refer to.

                             

                            • When a video is played, there would be a function that:
                              • Triggers a timer that looks at the current timecode vs. the array that was stored for that video.
                              • IF the timecode is >= than the value of the timecode stored in the array AND less than the next item's time value in that array - OR if there is no next item...
                                • Look at the objects that the button associated with that bit of timecode would turn on or off.

                             

                            • When a video is stopped, that timer instance would be stopped.

                             

                             

                            New question:
                            Is there any way to get inDesign to use my new idGeneratedScript.js file by default? (Will do due diligence in looking it up, but that's the next step...)

                             

                            Also - I applied to be able to use the InDesign SDK. If I am granted permission for that, I'll work on making this work so that other people can use this.

                             

                            I know just enough programming to get myself into trouble, but hey - it's neat when you get something to work the way you need it to.

                             

                             

                            • 11. Re: Navigation Point and Movie Event Listeners?
                              Laubender Adobe Community Professional & MVP

                              Hi Jenn,

                              congratulations!


                              Hm. Using idGeneratedScript.js as default?
                              Good question. In any case the generated JS file is expandable after it is written as part of the EPUB package.

                              Unpacking/repacking could be done by ExtendScript.


                              But maybe there is an easier way:

                              How about exporting another, pre-written JS file at export time providing your function(s)?

                              I did not test this, but new functions, that access HTML objects should run in the same eco-system like Adobe's own.

                               

                              So extending or using the usual functions that come with InDesign's own JavaScript for HTML should be possible.

                              The main problem is to anticipate the button objects by name or other means and to identify the right ones for video control.


                              The additional JS script could be exported together with all other page item stuff to EPUB when InDesign's export to EPUB functionality is used.

                              And that one can be scripted by ExtendScript. Also an additional js file can be written on the fly when executing the ExtendScript for export. Just an idea…

                               

                              Btw.: You do not need SDK programming for doing this.
                              Just plain ExtendScript. It is able to control the export and writing text files as well. And as we know, a JS file is nothing but a text file in disguise.
                              The same is true for additional CSS files.

                               

                              Uwe

                              • 12. Re: Navigation Point and Movie Event Listeners?
                                animatorjenn Level 1

                                Thanks Laubender . That alleviates the problem of making it easy for the guys on our training team to implement and use right out of the box.

                                 

                                With any amount of good fortune, I'll have a draft of this knocked out tonight. . And then I will post it and y'all can merrily cue all sorts of crazy things from your epub videos.

                                 

                                What I did notice in the HTML is that scripts are added before the idGeneratedScript are, so anything you write wouldn't be able to interact with any of the function calls that the buttons make to the idGeneratedScript file. But if you can add your own event listeners to buttons after the fact, it should be ok. (I will test this.)

                                 

                                THEN the only other concern is that you do a good job at killing any timers that are running on page change and any other garbage collection... and all should be alright.

                                 

                                Thanks for the support on this.

                                Jenn