小编Jo *_*Lee的帖子

VideoJS 覆盖和反应

我想知道,是否可以添加反应组件作为内容?

我像这样在覆盖层内添加了组件 -

 this.player.overlay({
      content: <SomeReactComponent />,
      align: 'bottom-left',
      overlays: [{
        start: 'play',
        end: 'end'
      }]
    });
Run Code Online (Sandbox Code Playgroud)

并且 SomeReactComponent 只是一个动态图像渲染器的反应组件,看起来像这样

import like from './like.png';
import love from './love.png';
import neutral from './neutral.png';

class SomeReactComponent extends Component {
  getImage(pic) {
    const image = pic;
    return image;
  }

  render() {
    const pic = [love, like, neutral];

    return (
        <div>
          { sentimentsArray.map(sentiment =>
            <img src={this.getImage(pic)} style={{ width: '75%', height: '75%', objectFit: 'scale-down' }} />
          )}
        </div>
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

当我在控制台中调用 this.player.overlay 时,它说 overlays.options.content …

video.js videojs-overlay

5
推荐指数
1
解决办法
466
查看次数

标签 统计

video.js ×1

videojs-overlay ×1