Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/478.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ReactJs更改时间视频html5_Javascript_Html_Reactjs_Video_Html5 Video - Fatal编程技术网

Javascript ReactJs更改时间视频html5

Javascript ReactJs更改时间视频html5,javascript,html,reactjs,video,html5-video,Javascript,Html,Reactjs,Video,Html5 Video,我正在开发一个使用ReactJs的网站,我使用html5 handleVideoMounted=element=>{ if(元素!==null){ element.currentTime=30; } }; render(){ 返回( ..... HtmlMedia元素有一个currentTime属性,允许您更改源的时间。它以秒为单位定义 通过使用Ref Callback,一旦安装了视频元素,就会向您传递允许您设置其currentTime的元素 null检查的原因是,当卸载视频(例如,卸载组件)

我正在开发一个使用ReactJs的网站,我使用html5
handleVideoMounted=element=>{
if(元素!==null){
element.currentTime=30;
}
};
render(){
返回(
.....
HtmlMedia元素有一个
currentTime
属性,允许您更改源的时间。它以秒为单位定义

通过使用Ref Callback,一旦安装了视频元素,就会向您传递允许您设置其
currentTime
的元素

null
检查的原因是,当卸载视频(例如,卸载组件)时,也会调用此Ref回调,但这次参数为null


这里的一个工作示例

我看到了这个示例,现在它似乎不再可用。我要做的是单击一系列按钮,我必须确保更改视频的时间。因此我不知道如何使用您的视频引用示例。我看到了链接,但只有一个按钮,如果单击,将调用作为道具传递的函数。我我不明白这是怎么回事?
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>SubTitle</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min2.css" />
    <style>
    a {
        cursor: pointer;
    }

    .help-block {
        font-size: 12px;
    }
    * {
        margin: 0;
        padding: 0;
    }
    body {
        background-color: #222222;
        color: #fff;
    }
    textarea {
      resize: none;
      -webkit-border-radius: 5px;
      -moz-border-radius: 5px;
      border-radius: 5px;
        outline: none !important;
    }

    textarea::-webkit-input-placeholder {
        color: black !important;
    }

    textarea:-moz-placeholder { /* Firefox 18- */
        color: black !important;
    }

    textarea::-moz-placeholder {  /* Firefox 19+ */
        color: black !important;
    }

    textarea:-ms-input-placeholder {
        color: black !important;
    }
    </style>
</head>

<body>
    <div id="app"></div>
</body>

</html>
import React from 'react';
import styles from '../Css/Styles.module.css';

class SubPage extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      value: '',
    };

  }

    render() {
      return (
        <div className={styles.video}>
        <video controls autoPlay="true">
          <source src="https://www89.uptostream.com/9kanocdc72/360/0/video.mp4" type="video/mp4" />
          <track label="English" kind="subtitles" srcLang="en" src="life.vtt" default />
        </video>
        </div>
       )
    }
}
handleVideoMounted = element => {
  if (element !== null) {
    element.currentTime = 30;
  }
};

render() {
  return (
    <video controls autoPlay={true} ref={this.handleVideoMounted}> 
.....