Skeepers

mail@pastecode.io avatar
unknown
javascript
3 years ago
1.1 kB
3
Indexable
Never
var hasTeesterVideoProduct = <?= $product->getSkeepersVideo() ? '1' : '0'; ?>;

window.onTeesterReady.push((SDK) => {

            var alreadyPlayed = false;

            var player = '';

            if(hasTeesterVideoProduct === 1) {
                player = SDK.init({
                    type: 'player',
                    args: {
                        key: '17a039ba-36d6-4d72-943e-b4cc61a5142e',
                        product: '<?= $product->getId(); ?>'
                    }
                }, document.querySelector('#skeepers-player-<?= $product->getId(); ?>'));

                player.onPlay(() => {
                    if (!alreadyPlayed) {
                        alreadyPlayed = true;
                    }
                });

                SDK.getVideos('17a039ba-36d6-4d72-943e-b4cc61a5142e', '<?= $product->getId(); ?>', (videos) => {
                    if(videos.length) {
                        document.getElementById('skeepers-item-pagination-<?= $product->getId() ?>')
                            .setAttribute('src', videos[0].thumbnails.original);
                    }
                });
            }
});