Put this in the video with subtitles in Spanish
/**
* Put this in the video with subtitles in Spanish
*/
var broadCast = new BroadcastChannel('video-sync-player');
var video = document.getElementById("player0");
video.onplay = () => {
console.log("Played video");
broadCast.postMessage({
type: 'video-played',
});
}
video.onpause = () => {
console.log("Paused video");
broadCast.postMessage({
type: 'video-paused',
});
}
Put this in the video with audio in English
/**
* Put this in the video with audio in English
*/
var broadCast = new BroadcastChannel('video-sync-player');
var video = document.getElementById("player0");
broadCast.onmessage = ({ data = {} }) => {
console.log("onmessage video-sync-player: ", data);
if (data.type === 'video-played') {
video.play();
} else if (data.type === 'video-paused') {
video.pause();
} else {
console.log("Yo need to map this event: ", data);
}
};
Thank you!