youtube_player_flutter icon indicating copy to clipboard operation
youtube_player_flutter copied to clipboard

AutoPlay not working [BUG]

Open Riyaz7364 opened this issue 3 years ago • 10 comments

Describe the bug I am using same code provide in Git but my video is not auto-playing like this example https://sarbagyastha.com.np/youtube_player_flutter/#/

I'm using chrome browser Version 96.0.4664.45 (Official Build) (64-bit)

Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision 18116933e7 (7 weeks ago) • 2021-10-15 10:46:35 -0700 Engine • revision d3ea636dc5 Tools • Dart 2.14.4

Riyaz7364 avatar Nov 30 '21 10:11 Riyaz7364

On my side, its working on Firefox but not Chrome and Safari.

jeromecaudoux avatar Dec 03 '21 16:12 jeromecaudoux

can confirm, works in Firefox but not in Chrome.

BennyKirschner avatar Dec 26 '21 16:12 BennyKirschner

found the issue - within player_frament.dart you have to set allow="autoplay" after "src="$sourceUri" within the iframe. Fixes the issue in Chrome.

BennyKirschner avatar Dec 27 '21 22:12 BennyKirschner

Could you provide a bit more details? I tried to reproduce but it only allows me to play the video after I press the play button. I am also on chrome and this is definitely still an open issue. Is there an hotfix?

JeanBarreiro avatar Jan 07 '22 16:01 JeanBarreiro

image Check out the player_fragments.dart file. In line 39 you have to add the allow"autoplay" flag and you should be good

BennyKirschner avatar Jan 07 '22 23:01 BennyKirschner

Edit: I not sure if I am in the right place, mine appears in line 35?

image mine appears in image

Thanks for the feedback!

I notice that if you start the app without interacting with it it will still not load, if you click on the tab and reload it, it will load every time, weird huh?

I am trying to figure out if I can force play it using a bool forcePlay = true but am struggling with that as well.

JeanBarreiro avatar Jan 07 '22 23:01 JeanBarreiro

@Jankeelol were you able to force play the video on loading? Even I am struggling to get it force play

SampatDixit avatar Jan 10 '22 07:01 SampatDixit

@SampatDixit I was! The issue is that Chrome does not allow you to force play a video with sound.the work around that i used was to use firefox in the end device. Firefox allows you to force autoplay with sound. Otherwise, you need to mute the video in order for chrome to allow autoplay on loading the app

JeanBarreiro avatar Jan 10 '22 17:01 JeanBarreiro

@Jankeelol thanks..this helps !

SampatDixit avatar Jan 10 '22 18:01 SampatDixit

Autoplaying with sound on Chrome works if you add allow="autoplay" (as suggested in a previous comment) AND you click anywhere on the Chrome page before video starts autoplaying. I guess Chrome only allows autoplay with sound on current active tab.

So my dilemma right now is how to simulate a click on the page from code. I've tried setting focus to the page but it did not work. Any ideas?

kaciula avatar May 03 '22 06:05 kaciula