Skip to main content
Karim MK
Known Participant
April 21, 2021
Answered

Event video

  • April 21, 2021
  • 2 replies
  • 479 views

Hi,

I have added a an event video to my project, and I would like that when the user starts the project that the video start automatically but when he goes further with project and goes back to the slide where the video is that the video doesn't start automatically and let the use start it himself.

Could you help me please ?

 

Thanks ,

Karim

This topic has been closed for replies.
Correct answer TLCMediaDesign

Create a variable in Captivate called videoPlayed and set it to 0.

 

Then on enter of the first slide in the project execute this Javascript;

 

window.cpAPIEventEmitter.addEventListener("CPAPI_SLIDEENTER", function( e )
{
setTimeout( function()
{
var vid = document.getElementsByTagName( "video" )[ 0 ];

if ( vid !== undefined )
{
if ( window.videoPlayed === 1 )
{
vid.pause();
var btn = document.getElementById( "btnPlay" + e.Data.videos[ 0 ]);
btn.classList.remove( "paused" );
}
else
{
window.videoPlayed = 1;
}
}
}, 500);
});

 

2 replies

TLCMediaDesign
TLCMediaDesignCorrect answer
Inspiring
April 21, 2021

Create a variable in Captivate called videoPlayed and set it to 0.

 

Then on enter of the first slide in the project execute this Javascript;

 

window.cpAPIEventEmitter.addEventListener("CPAPI_SLIDEENTER", function( e )
{
setTimeout( function()
{
var vid = document.getElementsByTagName( "video" )[ 0 ];

if ( vid !== undefined )
{
if ( window.videoPlayed === 1 )
{
vid.pause();
var btn = document.getElementById( "btnPlay" + e.Data.videos[ 0 ]);
btn.classList.remove( "paused" );
}
else
{
window.videoPlayed = 1;
}
}
}, 500);
});

 

Karim MK
Karim MKAuthor
Known Participant
April 21, 2021

@TLCMediaDesign Thank you for your help, it works but when I came back on the main slide where the video is, the video starts and stops after I think 0,3 sec

TLCMediaDesign
Inspiring
April 21, 2021

Change the 500 near the end of the script to 100.

 

There needs to be enough time for the video element to be rendered in the browser so I use the timeout.

Lilybiri
Legend
April 21, 2021

With slide video this could be done with Captivate functionality. However since event video plays independently of Captivate, you'll need JavaScript< Hope for the JS experts to co;e in qnd help you with code snippets.