Skip to main content
Karim MK
Known Participant
Apr 21, 2021 10:51 AM UTC
Answered

Event video

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 is closed to new replies. Start a new post to keep the conversation going.
TLCMediaDesign
TLCMediaDesignCorrect answer
Inspiring
Apr 21, 2021 12:29 PM UTC

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);
});

 

5 replies

TLCMediaDesign
TLCMediaDesignCorrect answer
Inspiring
Apr 21, 2021 12:29 PM UTC

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);
});

 

Translate
Karim MK
Karim MKAuthor
Known Participant
Apr 21, 2021 2:02 PM UTC

@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

Translate
TLCMediaDesign
Inspiring
Apr 21, 2021 2:08 PM UTC

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.

Translate
Lilybiri
Legend
Apr 21, 2021 12:29 PM UTC

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.

Translate