I tinkered around with the original code and the concept of subtracting off the elapsed frames leading up to the slide. I now have something that seems to work including the clickable area and the replay button.
You will need a transparent shape over the top of the progress bar with the exact same width.
In this code - you'll need to name it progClick
You will also still need to indicate the total seconds of the slide in line two.
var thisSlideStart=cpInfoCurrentFrame;
var thisSlideSec=10;
var thisSlideFrames=thisSlideSec*30;
var pauseFrame;
window.cpAPIEventEmitter.addEventListener("CPAPI_TIME_UPDATE", function(evt) {
if (evt.cpData.frame === pauseFrame) {
cpCmndPause = 1;
pauseFrame = null;
return;
}
var pctSlide = (((evt.cpData.frame-thisSlideStart)/ thisSlideFrames) * 100).toFixed(0);
$("#slideBarc").width(pctSlide + "%");
$("#slideBarc").css("visibility", "visible");
});
window.cpAPIEventEmitter.addEventListener("CPAPI_SLIDEENTER", function(cpEvt) {
pauseFrame =
cpEvt.cpData.to === thisSlideFrames ? thisSlideFrames : cpEvt.cpData.to - 1;
$("#progClick").click(function(evt) {
var barPercent = evt.offsetX / $(this).width();
cpCmndGotoFrameAndResume = Math.floor(thisSlideFrames * barPercent)+thisSlideStart;
});
});
Your replay button just needs a single line of code to return you to the starting frame of the slide.
cpCmndGotoFrameAndResume=thisSlideStart;
Keep the names of all your objects.
Just add the transparent box for click area.
Hope this works!
@Stagprime2687219 @kimb89954555
I rewrote @Stagprime2687219's code to get the slide length dynamically. There is a ton of information in the slide enter event. Try logging cpEvt.Data in the slide enter event.
var thisSlideStart = cpInfoCurrentFrame;
var thisSlideSec;
var thisSlideFrames;
var pauseFrame;
window.cpAPIEventEmitter.addEventListener("CPAPI_TIME_UPDATE", function(evt) {
if (evt.cpData.frame === pauseFrame) {
cpCmndPause = 1;
pauseFrame = null;
return;
}
var pctSlide = (((evt.cpData.frame-thisSlideStart)/ thisSlideFrames) * 100).toFixed(0);
$("#slideBarc").width(pctSlide + "%");
$("#slideBarc").css("visibility", "visible");
});
window.cpAPIEventEmitter.addEventListener("CPAPI_SLIDEENTER", function(cpEvt) {
thisSlideFrames = cpEvt.Data.to - cpEvt.Data.from;
thisSlideSec = thisSlideFrames / 30;
pauseFrame =
cpEvt.cpData.to === thisSlideFrames ? thisSlideFrames : cpEvt.cpData.to - 1;
$("#progClick").click(function(evt) {
var barPercent = evt.offsetX / $(this).width();
cpCmndGotoFrameAndResume = Math.floor(thisSlideFrames * barPercent)+thisSlideStart;
});
});