Go to end of a slide by script, get slide duration

Hello,

I’m trying to implement a script which depending on a variable would on slide Load():
(a) or play from the beginning of the slide
(b) or go to the end of the slide

is there a way to find in JS the duration of a specific slide or of a specific object?
Thanks a lot,
Michael

Hi Michael,

There’s no public function to get current slide duration.
We’ll consider adding it in future releases.

However, you can use any number that larger than the slide duration to go to the end of the slide.
For example:

prez.slideTime(Infinity);

Please note that the slide must be paused at the end (by an interaction or Auto-Advance property), otherwise it will jump to the next slide immediately.

Regards

Hi Toan Le,

Thanks for your prompt answer but sadly this does not seem to work.

It freezes for cca. 2 seconds when load() then the timeline effectively goes to the end of the slide but I can only see a grey screen - none of the objects are displayed - regardless of the fact that they are set to show till end of slide and that auto advance is unchecked (also tested with a paused object at the end and it didn’t work either - still get a grey screen).

Is there a way to find the duration of an object (which I could last the duration of the slide)?
Is there a way to find the start time of an object (which I could place at the end)?
Is there a way to get the start time of the next slide from which I could deduct the start time of the current slide?
Or I guess I could cycle through all the slides on presentation start and take down the start time of each as variables… and use that to calculate by duration?

Any thought?

Thanks,
Michael

Hi Michael,

I’m sorry I wasn’t aware that you want to use the script in slide On Load event.
If so, you must check if the slide is not at the end yet, otherwise infinite recursion will occur.
Please try again with the following script:

var newTime;
if (true)   // update your condition here
    newTime = Infinity;
else
    newTime = 0;
var currentTime = prez.slideTime();
if (!prez.jumpingToEnds)
    prez.jumpingToEnds = [];
if (isFinite(newTime)) {
    prez.jumpingToEnds[prez.currentSlideIndex() - 1] = false;
    if (newTime != currentTime)
        prez.slideTime(newTime);
} else {
    if (!prez.jumpingToEnds[prez.currentSlideIndex() - 1]) {
        prez.jumpingToEnds[prez.currentSlideIndex() - 1] = true;
        prez.slideTime(newTime);
        prez.jumpingToEnds[prez.currentSlideIndex() - 1] = false;
    }
}

P/S: object/slide start time and duration are internal data, there’s no way to get them in current version.

Regards

Hi Toan Le,
This works perfectly! Thanks a lot,
Great response time and service like usual.
Michael