I can play a video using an onclick function call (ex.1) but not using an inline clean call (ex.2). Why is that so?

ex1 

```
  <script> 
  function p()
  {document.getElementById("myVideo").play();}
  </script>

  <video id="myVideo" width="100" height="100" controls loop>
  <source src="movie.mp4" type="video/mp4">
  </video>
  <button onclick="p();">play</button>

```

ex2

```
  <video id="myVideo" width="100" height="100" controls loop>
  <source src="movie.mp4" type="video/mp4">
  </video>
  <button onclick="document.getElementById("myVideo").play();">play</button>

```