繁体   English   中英

如何在 JWPlayer 的错误消息中隐藏错误代码?

[英]How to hide error code in the error message in JWPlayer?

我有一个 React 代码,如下所示,它呈现播放器。 在下面的代码中,我使用 ReactJWPlayer 组件及其道具。 为了配置intl.{lang}.errors ,我使用了react-jw-player公开的 customProps 选项

const ReactJWPlayerContainer = props => {
    const [error, setError] = useState("");
    const [errorNode, setErrorNode] = useState(null);
 
    const player = ()=> {
            return (
                <ReactJWPlayer
                    playlist={[props.playlist]}
                    customProps={{
                        intl: {
                          en: {
                            errors: {
                              badConnection: "This video cannot be played because of a problem with your internet connection.",
                              cantLoadPlayer: "Sorry, the video player failed to load.",
                            },
                          },
                          fr: {
                            errors: {
                              badConnection: "This video cannot be played because of a problem with your internet connection.",
                              cantLoadPlayer: "Sorry, the video player failed to load.",
                            },
                          },
                        },
                      }}  
                />
            )
        }
    }

    return (
        <>
            {props.playlist && player()}
        </>
    )

}

如果播放器加载失败,上面的代码会成功显示带有相应错误代码的自定义错误消息。

问题陈述:

我想知道我需要对上面的 React 代码进行哪些更改才能成功隐藏错误代码。 在下面的屏幕截图中,我想隐藏该行(Error Code: 232011)

您必须将 props.playlist 作为变量传递,但您将作为数组项传递。

将此代码 playlist={[props.playlist]} 更改为 playlist={props.playlist}

我假设 props.playlist 是一个像这个例子一样的数组:

https://github.com/micnews/react-jw-player#playing-a-custom-playlist

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM