Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Event video

Explorer ,
Apr 21, 2021 Apr 21, 2021

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

TOPICS
Advanced , Advanced actions , Audio and video
465
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Apr 21, 2021 Apr 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

...
Translate
LEGEND ,
Apr 21, 2021 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Apr 21, 2021 Apr 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);
});

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 21, 2021 Apr 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Apr 21, 2021 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 21, 2021 Apr 21, 2021
LATEST

Great, it works!

Thank you for your help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources