Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

videojs return vdata error when dispose is call

I'm getting an error and i dont find any clues, i'm using videojs to control multiple video in a slider, on each completed transition, i call a new instance of videojs and and store the ID into a variable and dispose() the old videojs. Since i have lot of slide (or videos) and want to kill them when there are not active for performance. My slider work under TweenMax.. and i call the dispose() in the onStart event from a Timline. When the dispose() is called, i'm getting this error :

Uncaught TypeError: Cannot read property 'vdata1408997779453' of null

This is a sample of my code :

var $slides = [],
    videos =[],
    currentSlide = 0,
    currentVideo = null;

$(function(){

    TweenLite.to($('#header-wrap'), 1, {
            left: x,
            onStart: function(){
                if(currentVideo) {
                    TweenMax.set($('.video-holder'), {autoAlpha: 0});
                    currentVideo.dispose();
                }
            },

            onComplete: function() {
                if(videos[slideActive].url) {
                        videojs('movie-video-holder-'+slideActive+'', {"autoplay": false, "preload": "auto", "controls": false, "lopp": false}, function(){
                            currentVideo = $vid;
                            [...]
                        });
                }
            }
    [...]

Thanks!

like image 786
Mikhael Aubut Avatar asked Jul 24 '26 04:07

Mikhael Aubut


1 Answers

This looks like it's related to https://github.com/videojs/video.js/pull/1481

A really nasty hack (until the patch is merged) would be to pause the player, wait for the frame after the error, then dispose of the player:

player.pause();
setTimeout(function() {
    player.dispose();
}, 0);
like image 53
bne Avatar answered Jul 25 '26 18:07

bne