如何在播放按钮后安排下一按钮

问题描述 投票:0回答:1

我想将下一个按钮放在video.js中的播放按钮之后

下面是我的实际代码:

 const  handleClick =  () => {
           return navigate(`/videos/${this.props.nextVideo && this.props.nextVideo.get("_id")}`);
        };
        var Button = videojs.getComponent('Button');
        var MyButton = videojs.extend(Button, {
            constructor: function () {
                Button.apply(this, arguments);
                this.addClass('fa');
                this.addClass('fa-angle-right');
                this.controlText("Exit Course");
            },
            handleClick: function () {
                handleClick()
            }
        });
        videojs.registerComponent('MyButton', MyButton);
        return (
            <div data-vjs-player>
                <video

                    ref={node => (this.videoNode = node)}
                    className="video-js vjs-default-skin vjs-16-9"
                    preload="auto"
                    poster={this.props.preview || this.props.sources.thumbnail}
                    playsInline
                    controls

                    // TODO:
                    // investigate why that callback called multiple times
                    // onPlay={this.props.onVideoPlay}
                >
                    <source
                        src={this.props.sources.low}
                        type="video/mp4"
                        res="360"
                        label="360p"
                    />
                </video>

这是我在componenetDidmount中的播放视频按钮之前添加按钮的方式:

this.player = videojs(this.videoNode, {
            autoplay: this.props.isAutoplay,
            plugins: {"ads-setup": {}}
        }); 

// Button added before play button
 var button = this.player.getChild('controlBar').addChild('myButton', {});
        button.el();
        this.player.controlBar.el().insertBefore(button.el(), this.player.controlBar.el().firstChild)

如何添加下一个按钮?

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9IYjhiSC5wbmcifQ==” alt =“在此处输入图像描述”>

reactjs redux react-hooks video.js redux-thunk
1个回答
0
投票

addChild的第三个参数是在其处插入子项的索引。

© www.soinside.com 2019 - 2024. All rights reserved.