sampotts / plyr

A simple HTML5, YouTube and Vimeo player
https://plyr.io
MIT License
26.56k stars 2.93k forks source link

iOS Audio Change Source Requires Additional Click to Play #1334

Open jhakooz opened 5 years ago

jhakooz commented 5 years ago

Expected behaviour

After initial "click to play" audio on iOS, changing the audio source and calling player.play() should not require an additional click to play.

Actual behaviour

After initial click to play on iOS, changing the audio source requires an additional click to play. *** Pretty sure this is because iOS now requires the user to click to play audio for each element on the page. Since Plyr is re-creating the audio element, iOS treats it as a new element and requires a new "click".

Can Plyr change the source of the audio element without re-creating it? Seems like this would fix the issue.

Steps to reproduce

  1. Play audio on iOS by clicking the play button.
  2. Change the source via JS and call player.play(); The new audio is loaded but does not play.

Environment

iPad / iPhone

Console errors (if any)

Link to where the bug is happening

Simple CodePen showing the issue: https://codepen.io/anon/pen/xMLNGj

This is a link describing the "New" iOS AutoPlay Policies. See section: Developer recommendations from Safari https://bitmovin.com/play-not-play-new-autoplay-policies-safari-11-chrome-64/

jgrant404 commented 5 years ago

I am having the same issue -- any update on this?

jgrant404 commented 5 years ago

Proof of concept: I rewrote the change function and now autoplay works on iOS without having to re-click... though. Only for HTML5 audio files in this rendition, just to show that it should be a simple change for the dev and it does in fact fix the issue.

change: function change(input) { var _this2 = this;

var sources = input.sources,
    type = input.type;

var _sources = _slicedToArray(sources, 1),
    _sources$ = _sources[0],
    _sources$$provider = _sources$.provider,
    provider = _sources$$provider === void 0 ? providers.html5 : _sources$$provider,
    src = _sources$.src;

$("audio source").attr({"src":src});
$("audio")[0].load();
$("audio")[0].play(); }`
numerized commented 4 years ago

hello guys, I have the same issue, changing source with all autoplay active on youtube should automatically play video on changing source

numerized commented 4 years ago

I ended using video.js with playlist plugin it works perfectly.

dreamindigital commented 4 years ago

It looks like the same issue exists on the video element as well.