Go back 10 seconds button in AP6

Dear all,
I turn again to your expertise for a Javascript item.
I’m trying to come up with a code (for AP6) to make a button which on click would move the user 10 seconds back on the current slide. If time on current slide is less than 10 seconds it would restart slide from 0.

I’m trying with:
Prez.Restart(Prez.Session.SlideIndex,0)

but I can’t seem to find the Time() information _ I saw it is .time() in AP7 and tried Prez.Time() and Prez.Session.Time() but it did not work.

Goal is to have something like
if(slide.time < 10000)
Prez.Restart(Prez.Session.SlideIndex,0)
else
Prez.Restart(Prez.Session.SlideIndex,slide.time - 10000)

any clue how to get the time information and if the above could work with that?

FYI - this is again linked to SCORM test mode - as you cannot manage the timeline/go back - we need something so that the user can rehear something he missed.

Best regards,
Michael

Hi Michael,

The following script should work:

var time = Prez.GetSlide().ts - 10000;
if (time < 0)
  time = 0;
// Prez.Session.SlideIndex is zero based, but Prez.ShowSlide requires 1 based index, so add 1
Prez.ShowSlide(Prez.Session.SlideIndex + 1, time);

Regards

Hi Toanis,
This seems to be working perfectly - thank you so much
Have a great day,
Regards,
Michael

Hi Toanis,
I’m trying to convert this code to AP7 JS but I’m struggling with the
“Prez.GetSlide().ts” part…
I tried . prez.currentSlide().time() and various other combinations but to no avail.
Can this still be done in AP7?

as a side note - I managed to convert most other items from AP6 to 7.
But found 2 issues/confusing points in the manual:
Page 213 : pause(paused) is in fact pause(!paused) or even pause(!prez.paused)
Page 213: restart(slideIndex, time) starts in fact from index 0 [at least with a presentation created initially in AP6 and now saved in AP7] at not at index 1.

thanks,

Hi Michael,

  • The code should be:

var slideTS = prez.time() - prez.currentSlide().timeline().startTime();

  • Page 213: I rewrite for clarification:

prez.pause(theWantedState)

  • Restart: It is a bug and we will fix it in the next update.

Regards,

Hi,
great - that works - thanks!

Hello all,

can I use the same code in AP8?
We also need a button where you can go back for 10 secons so the user can resee something he missed or miss understood in the video.

Thank you for your help and best regards,
Selina

Hi Selina,

The API in version 8 is compatible with version 7, so it is fine. Please take a look at pages 249 - 254 in User Manual for details.

Regards,

Hi Dao Viet Phuong,

could you please help me with the code. I’ve tried my best, but I am not on the subject. I tried the following:

var slideTS = prez.time() - prez.currentSlide().timeline().startTime();
if (slideTS < 0)
slideTS = 0;
Prez.ShowSlideAt(Prez.Session.SlideIndex + 1, slideTS);

And where do I have to introduce the backwardtime of 10000?

A further question, is it possible to implement this skill into the toolbar you can see in the video down below?

Thank you very much for your help!
Best wishes
Selina

Hi Selina,

The complete script for version 7 and version 8 are:

var time = prez.slideTime() - 10000;
if (time < 0)
  time = 0;
prez.slideTime(time);

Regards

Hi Toan,
this seems to be working perfectly, thank you very much!
Have a great day and best wishes
Selina