Skip to content

Commit

Permalink
Merge pull request #337 from brave/autoplay-fix
Browse files Browse the repository at this point in the history
Actually wait for playing to fix autoplay intermittent fails
  • Loading branch information
bbondy committed Aug 18, 2018
2 parents 71a21bf + 2654feb commit 4d79b46
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions test/data/autoplay/autoplay_by_attr.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
</head>
<body>

<video width="320" height="240" controls autoplay onplay="playing()">
<video width="320" height="240" controls autoplay onplay="onPlay()">
<source src="autoplay.mp4" type="video/mp4">
</video>

<div id='status'>Video not playing</div>

<script>
function playing () {
function onPlay () {
let status = document.getElementById('status')
status.textContent = 'Video playing'
window.playing = true;
if (window.notifyBrowser)
notifyWhenPlaying();
}
function notifyWhenPlaying() {
if (playing)
if (window.playing)
window.domAutomationController.send("PLAYING");
else
window.notifyBrowser = true;
Expand Down
6 changes: 3 additions & 3 deletions test/data/autoplay/autoplay_by_attr_muted.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
</head>
<body>

<video width="320" height="240" controls autoplay onplay="playing()" muted>
<video width="320" height="240" controls autoplay onplay="onPlay()" muted>
<source src="autoplay.mp4" type="video/mp4">
</video>

<div id='status'>Video not playing</div>

<script>
function playing () {
function onPlay () {
let status = document.getElementById('status')
status.textContent = 'Video playing'
window.playing = true;
if (window.notifyBrowser)
notifyWhenPlaying();
}
function notifyWhenPlaying() {
if (playing)
if (this.playing)
window.domAutomationController.send("PLAYING");
else
window.notifyBrowser = true;
Expand Down
6 changes: 3 additions & 3 deletions test/data/autoplay/autoplay_by_method.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
</head>
<body onload="autoplay()">

<video id="autoplay" width="320" height="240" controls onplay="playing()">
<video id="autoplay" width="320" height="240" controls onplay="onPlay()">
<source src="autoplay.mp4" type="video/mp4">
</video>

<div id='status'>Video not playing</div>

<script>
function playing () {
function onPlay () {
let status = document.getElementById('status')
status.textContent = 'Video playing'
window.playing = true;
if (window.notifyBrowser)
notifyWhenPlaying();
}
function notifyWhenPlaying() {
if (playing)
if (window.playing)
window.domAutomationController.send("PLAYING");
else
window.notifyBrowser = true;
Expand Down
6 changes: 3 additions & 3 deletions test/data/autoplay/autoplay_by_method_muted.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
</head>
<body onload="autoplay()">

<video id="autoplay" width="320" height="240" controls onplay="playing()" muted>
<video id="autoplay" width="320" height="240" controls onplay="onPlay()" muted>
<source src="autoplay.mp4" type="video/mp4">
</video>

<div id='status'>Video not playing</div>

<script>
function playing () {
function onPlay () {
let status = document.getElementById('status')
status.textContent = 'Video playing'
window.playing = true;
if (window.notifyBrowser)
notifyWhenPlaying();
}
function notifyWhenPlaying() {
if (playing)
if (window.playing)
window.domAutomationController.send("PLAYING");
else
window.notifyBrowser = true;
Expand Down

0 comments on commit 4d79b46

Please sign in to comment.