Youku API playvideo method throws uncaught type error

104 Views Asked by At
$(document).ready (function() {
    console.log('onYouTubeIframeAPIReady');
    let containers = {}, players = {};
    @foreach($trade_videos as $video)
            containers['{{$video->youtube}}'] = document.querySelector('#player-container-{{$video->youtube}}');
    players['{{$video->youtube}}'] = document.querySelector('#player-{{$video->youtube}}');


    players['{{$video->youtube}}'] = new YKU.Player( 'player-{{$video->youtube}}', {
        height: containers['{{$video->youtube}}'].children[0].offsetHeight,
        width: containers['{{$video->youtube}}'].children[0].offsetWidth,
        // playerVars: {enablejsapi: 1, rel: 0, modestbranding: 1, autohide: 1},
        styleid: '0',
        autoplay: false,
        vid: '{{$video->youtube}}',
        client_id: 'CLIENT_ID',
        newPlayer: true,
        {{--events: {--}}
            {{--onPlayerReady: function (e) {--}}
                {{--e.target.a.parentNode.classList.add('playable');--}}
            {{--},--}}

            {{--onPlayStart: function(){--}}
                {{--containers['{{$video->youtube}}'].classList.add('playing');--}}
            {{--},--}}

            {{--onPlayEnd: function(){--}}
                {{--containers['{{$video->youtube}}'].classList.remove('playing');--}}
            {{--}--}}
        {{--}--}}

    });

    containers['{{$video->youtube}}'].addEventListener('click',function(){ players['{{$video->youtube}}'].playVideo(); });


    @endforeach
});

I'm unsure if I'm missing something with the youku api, the same setup works just fine with the youtube one, but youku is returning Uncaught TypeError: Cannot read property 'pauseVideo' of null the actual video is loading just fine, it just seems that the play methods are not working? Has anyone encountered something similar.

0

There are 0 best solutions below