Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Broken autoplay #3188

Closed
doublex opened this issue Mar 17, 2016 · 9 comments
Closed

Broken autoplay #3188

doublex opened this issue Mar 17, 2016 · 9 comments

Comments

@doublex
Copy link

doublex commented Mar 17, 2016

Hello,

The pull request (#2971) broke the autoplay (at least on my computer - FF on Ubuntu). I don't know why - "this.src()" returns an empty string (maybe a race condition?).

The down below patch fixes this issue (and #2825).

Thanks a lot
Markus

*** src/js/player.js-o        2016-03-17 17:02:39.290288039 +0100
--- src/js/player.js    2016-03-17 17:04:47.529929151 +0100
*************** class Player extends Component {
*** 731,738 ****
      // In Safari (5.1.1), when we move the video element into the container div, autoplay doesn't work.
      // In Chrome (15), if you have autoplay + a poster + no controls, the video gets hidden (but audio plays)
      // This fixes both issues. Need to wait for API, so it updates displays correctly
!     if (this.src() && this.tag && this.options_.autoplay && this.paused()) {
!       delete this.tag.poster; // Chrome Fix. Fixed in Chrome v16.
        this.play();
      }
    }
--- 731,740 ----
      // In Safari (5.1.1), when we move the video element into the container div, autoplay doesn't work.
      // In Chrome (15), if you have autoplay + a poster + no controls, the video gets hidden (but audio plays)
      // This fixes both issues. Need to wait for API, so it updates displays correctly
!     if (this.tag && this.options_.autoplay && this.paused()) {
!         try {   // Safari 5 throws: "TypeError: Unable to delete property."
!         delete this.tag.poster; // Chrome Fix. Fixed in Chrome v16.
!       } catch (e) {}
        this.play();
      }
    }
@dennissch
Copy link

I have noticed the same issue with:
Mozilla/5.0 (PlayStation 4 3.15) AppleWebKit/537.73 (KHTML, like Gecko)

'message' => 'Unable to delete property.',
'name' => 'TypeError',
'logData'` => 'Exception info',
if (this.src() && this.tag && this.options_.autoplay && this.paused()) {
->  delete this.tag.poster; // Chrome Fix. Fixed in Chrome v16.
  this.play();
}

@gkatsev
Copy link
Member

gkatsev commented Mar 28, 2016

Given that the delete statement seems to be a fix for older Chrome and fixed in chrome 16, do we even need to have that line altogether?
I guess wrapping it in a try/catch is "safer" but if it's just causing problems now, we should just remove it.
Thoughts, @videojs/core-committers, particularly @heff (you probably added it in)?

@heff
Copy link
Member

heff commented Mar 28, 2016

Yeah, the delete could definitely be removed. You'd want to check Safari first before removing the whole block. And probably not just the latest Safari but whatever versions are in use, because removing it could immediately break playback for people. If it works now though it'd be great to get rid of all that.

@gkatsev
Copy link
Member

gkatsev commented Mar 28, 2016

I'm just talking about removing just

delete this.tag.poster; // Chrome Fix. Fixed in Chrome v16.
and not the whole block.

@heff
Copy link
Member

heff commented Mar 28, 2016

But the addition of this.src() in #2971 is apparently what caused the issue, so I don't know if that's a full fix for this issue.

@doublex
Copy link
Author

doublex commented Mar 29, 2016

Sorry - there are two issues:
a) this.src() broke the autoplay (maybe only on my setup - I will investigate futher)
b) delete this.tag.poster breaks old Safari browser (and old ipad tablets)

Maybe the best fix for now: Could you add a try/catch block arround the delete and ignore the this.src()?

@rbran100
Copy link
Contributor

rbran100 commented Apr 29, 2016

I seem to be having the same issue, the only way I get the video to auto-play in chrome 50 is to add src manually into my video tag.

Also removing this.src() from the IF statement will fix my issue.

@gkatsev
Copy link
Member

gkatsev commented Jun 22, 2016

PR for this was merged. See #3337.

@gkatsev gkatsev closed this as completed Jun 22, 2016
@doublex
Copy link
Author

doublex commented Jun 23, 2016

@gkatsev
Thanks for supporting legacy apple devices.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants