title: Updating source URL on HTML5 video with React
body: <p>I want to update the source tag in a HTML5 video element so that when I click a button, whatever's playing switches to a new video.</p>
  
  <p>I have a Clip component that returns an HTML5 video element, with the source URL provided via props.</p>
  
  <pre><code>function Clip(props) {
    return (
      &lt;video width="320" height="240" controls autoPlay&gt;
        &lt;source src={props.url} /&gt;
      &lt;/video&gt;
    )
  }
  </code></pre>
  
  <p>I also have a Movie component, which contains multiple URLs, each corresponding to a section of the movie. It also contains a position attribute, which acts like an iterator by remembering which section is currently playing. </p>
  
  <pre><code>class Movie extends Component {
    constructor() {
      super();
      this.state = {
        sections: [
          'https://my-bucket.s3.amazonaws.com/vid1.mp4',
          'https://my-bucket.s3.amazonaws.com/vid2.mp4'
        ],
        position: 0
      };
    }
    render() {
      const sections = this.state.sections
      const position = this.state.position
  
      return (
        &lt;div&gt;
          {position}
          &lt;Clip url={sections[position]} /&gt;
          &lt;button onClick={() =&gt; this.updatePosition()}&gt;Next&lt;/button&gt;
        &lt;/div&gt;
      )
    }
    updatePosition() {
      const position = this.state.position + 1;
      this.setState({ position: position });
    }
  }
  </code></pre>
  
  <p>The Movie component renders a Clip component and a "Next" button. When the Next button gets clicked, I want to update the position attribute and re-render the HTML5 video element using the next URL from sections.</p>
  
  <p>As of now, when I hit Next the HTML5 video source tag updates, but the element continues playing the video from the previous URL. Can anyone help me figure out how to reset the video element?</p>
  
  <p><strong>Update:</strong> I created a JSFiddle, which you can see <a href="http://jsfiddle.net/gundam194/d0exvp02/1/" rel="noreferrer">here</a>.</p>
  
  <p><strong>Update 2:</strong> Updating the src attribute on the video element works! </p>