WordPress插件:VideoJS播放列表块中未定义videojs

时间:2019-03-11 16:04:22

标签: wordpress video.js playlist video-player

我正在尝试实现一个功能,使用Gutenberg Blocks for Wordpress显示Videojs播放列表,但出现以下错误: console error

这是我函数的代码

function getPlaylistData(){
      //import videojs = require('video.js');
      var player = videojs(document.querySelector('my-playlist'),{
        inactivityTimeout: 0,
        fluid: true
      });
      player.playlist([
        {
        source:[{
          src: 'http://media.w3.org/2010/05/sintel/trailer.mp4',
          type: 'video/mp4'
        }],
        poster: 'http://media.w3.org/2010/05/sintel/poster.png'
        },
        {
        source:[{
          src: 'http://media.w3.org/2010/05/sintel/trailer.mp4',
          type: 'video/mp4'
        }],
        poster: 'http://media.w3.org/2010/05/sintel/poster.png'
        },
      ]);
      
      player.playlist.autoadvance(0);
    }

这就是我创建古腾堡块的方法:

registerBlockType('vizzi/playlist-embed', {
      title: 'Vizzi Embed Playlist',
      icon: 'playlist-video',
      category: 'common',
      attributes: {
        content: {
          type: 'string',
          source: 'attribute',
          attribute: 'alt',
        },
        mediaURL: {
          type: 'string',
          source: 'attribute',
          selector: 'img',
          attribute: 'src',
      }
      },
      edit: function(){
        return([
          el('video',{
            "id": "my-playlist",
            "class": "video-js vjs-default-skin",
            "controls": "controls",
            "preload": "auto",
            "data-setup":'"{fluid: true}"'
          })
        ]),
        getPlaylistData();
      },
      save: function(){
     
      },
    });

已经通过npm安装了videojs和videojs-playlist,所以我不明白问题出在哪里

0 个答案:

没有答案