Copy link to clipboard
Copied
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
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
});
Copy link to clipboard
Copied
@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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Great, it works!
Thank you for your help!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now