How can I autoplay a video using the new embed code style for

文章推薦指數: 80 %
投票人數:10人

Just put "?autoplay=1" in the url the video will autoload. So your url would be: http://www.youtube.com/embed/JW5meKfy3fY?autoplay=1. Home Public Questions Tags Users Collectives ExploreCollectives FindaJob Jobs Companies Teams StackOverflowforTeams –Collaborateandshareknowledgewithaprivategroup. CreateafreeTeam WhatisTeams? Teams CreatefreeTeam CollectivesonStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. Learnmore Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. Learnmore HowcanIautoplayavideousingthenewembedcodestyleforYoutube? AskQuestion Asked 11years,3monthsago Active 6monthsago Viewed 801ktimes 178 34 Ican'tworkouthowtoautoplayavideousingthenewembedcodestyleforYoutube.Itriedadding&autoplay=1totheurl,whichworkedwiththeoldstyle,butitdidn'twork.Forexample,http://www.youtube.com/embed/JW5meKfy3fYistheembedlink,buthttp://www.youtube.com/embed/JW5meKfy3fY&autoplay=1doesn'twork.Cananyonetellmehowtodoit?Thanks videoyoutubeyoutube-api Share Improvethisquestion Follow editedAug4'10at12:15 ben askedAug4'10at11:57 benben 27.5k4141goldbadges123123silverbadges175175bronzebadges 3 3 Thisisoutdated.'mute=1'isrequirednow.See:AnsweringStackOverflowArticle – Trevor Oct11'18at16:27 1 Yes,Ineededtoadd?autoplay=1&mute=1forautoplaytoworkinchrome.Thanks – johnblair Sep23'19at9:33 Sojusttobeclear,chromewillonlyallowautoplayifthevideoismuted?Thereisnowaytoforceautoplaywiththesoundon? – webrightnow Oct24'19at17:36 Addacomment  |  12Answers 12 Active Oldest Votes 376 +50 Justput"?autoplay=1"intheurlthevideowillautoload. Soyoururlwouldbe: http://www.youtube.com/embed/JW5meKfy3fY?autoplay=1 Incaseyouwannadisableautoplay,justmake1to0as ?autoplay=0 Share Improvethisanswer Follow editedApr8'19at11:27 WasiF 18.3k1111goldbadges9696silverbadges106106bronzebadges answeredAug8'10at6:16 matthewbauermatthewbauer 4,09611goldbadge1515silverbadges2121bronzebadges 8 12 Thisdoesn'tappeartoworkasofrightnow.Itworkedperfectly1weekago. – Peeja Feb18'14at15:36 26 ThefirstparameterafterthevideoIDneedstostartwith"?",allparametersAFTERthatneedstobeaddedwith"&".Ifyouhadforexample"?rel=0&autoplay=1"itwouldbethesameas"?autoplay=1&rel=0"andtheywouldbothwork. – Thanos Feb21'14at1:34 9 Thisanswerstillworks2016.Justaddingtheinfo,sinceit'sthefirstresultthatpopsupongoogle. – FlorianRachor Jan28'16at10:06 2 Someadditionalexplanationsincethisissohighinthegoogresults.ThepartoftheURLfollowing'?'istheQueryStringandwhatyouneedisthe'autoplay'keywithvalue'1'.Soforexample,'.../embed/JW5meKfy3fY?autoplay=1?rel=1'wouldalsobewrongbecausethenyouwouldhave'autoplay'withvalue'1?rel=1'.TheQueryStringbeginswith'?'andisseparatedintokey=valuepairsbythe'&'symbol.en.wikipedia.org/wiki/Query_string#Structure – knickum Jan31'17at19:35 9 Updatefor2017:Nowiniframeneedaddonemoreconf:allow="autoplay"acordingtodevelopers.google.com/web/updates/2017/09/…soyouriframewilllokslike: – vityapro Aug26'19at14:15  |  Show3morecomments 31 Actually,youwillhavetousethe"?"insteadof"&"foryourfirstparameteronly.Ifyouusemorethanoneparameter,youwillthenhavetoadd"&"tothechain. Forinstance,ifyouwanttoaddautoplayandclosedcaptioning,youwillhavetoaddthisportiontoyourembeddedvideoURL:?autoplay=1&cc_load_policy=1. Itwouldlooklikethis: Share Improvethisanswer Follow editedSep23'11at14:37 answeredSep23'11at14:31 SachaSacha 31933silverbadges33bronzebadges 1 whatdoyoumeanbyclosedcaptioning? – WasiF Apr8'19at11:16 Addacomment  |  17 Youneedtoaddanextraparameter,alongsidetheautoplay=1 allow="autoplay" makingit: Share Improvethisanswer Follow answeredNov5'18at16:23 AndrewWestAndrewWest 18911silverbadge66bronzebadges 1 Thisisrecommendedsolutionfor2020 – Rahul Jun1'20at19:27 Addacomment  |  6 TheonlywayIwasabletogetautoplaytoworkwastousetheiframeplayerapi. Share Improvethisanswer Follow answeredApr4'15at10:26 JulesJules 1,8811515silverbadges1818bronzebadges Addacomment  |  6 Okaythisisanexampleforthenewembedcodeforyoutubevideos. ifyouwanttoautoplayit,atthesrc="http://www.youtube.com/embed/8v_4O44sfjM"addthe?autoplay=1parameter Sothecodewilllooklikethis: itriedthisonmybloganditworks!Hopethishelp(: Share Improvethisanswer Follow editedNov9'18at0:55 CommunityBot 111silverbadge answeredJan25'11at7:12 AmelAmel 6111silverbadge11bronzebadge Addacomment  |  5 Noneoftheaboveworkedformeinthecurrentyoutubeembed.Trythis,itactuallyworkedforme:) Hopeithelps! Share Improvethisanswer Follow editedJun11'15at18:40 josliber♦ 42.4k1212goldbadges9191silverbadges129129bronzebadges answeredJun11'15at18:32 KateatGavinAcademyKateatGavinAcademy 8622silverbadges66bronzebadges 0 Addacomment  |  5 Chromeblocksaudiocontentbeingplayedwithoutanyuserinteraction. So,awork-aroundistostartthevideomutedbyadding &mute=1 Thiswillwork100%ofthetime. Share Improvethisanswer Follow answeredMay16at13:01 FacePalmFacePalm 8,48833goldbadges4242silverbadges4545bronzebadges 1 ItworksonChromeforDesktop.Itdoesn'tworkonChromeforMobilenorFirefoxbothDesktopandMobile. – Ivan Aug30at11:33 Addacomment  |  4 YouTubeHelpsaysthat&autoplay=1hastobeafterthevideoID-Iassume,immediatelyafter. Share Improvethisanswer Follow answeredAug4'10at12:01 AntonGogolevAntonGogolev 108k3737goldbadges191191silverbadges280280bronzebadges 1 @Aton:Thanksforyouranswer.Stilldoesn'tworkthough.I'veupdatedthequestionwithlinks. – ben Aug4'10at12:16 Addacomment  |  4 Youareusingawrongurlforyoutubeautoplayhttp://www.youtube.com/embed/JW5meKfy3fY&autoplay=1thisurldisplayyoutubeidaswholeJW5meKfy3fY&autoplay=1whichyoutuberejectstoplay.wehavetopassautoplayvariabletoyoutube,thereforeyouhavetouse?insteadof&soyoururlwillbehttp://www.youtube.com/embed/JW5meKfy3fY?autoplay=1andyourfinaliframewillbelikethat. Share Improvethisanswer Follow editedDec27'15at16:18 FreekdeBruijn 3,45422goldbadges2323silverbadges2727bronzebadges answeredJan23'13at17:32 WaheedurRehmanWaheedurRehman 75566silverbadges1313bronzebadges 1 1 Youforgottochangethe&to?intherightwaytodoit.(beforetheiframe) – user3052629 Dec22'15at8:43 Addacomment  |  3 Justadd?autoplay=1afterurlinembedcode,example: Changeitto: Share Improvethisanswer Follow editedOct6'12at14:07 UweKeim 37.5k5555goldbadges166166silverbadges274274bronzebadges answeredSep9'12at13:04 AjieKurniyawanAjieKurniyawan 4111bronzebadge Addacomment  |  2 Noneofyoursaresolvedmyproblem.But,Ifoundagoodsolutionformetoworkproperlyrightnow.Inbetweentagswritethiscode: Share Improvethisanswer Follow answeredOct18'15at16:36 BayBay 41955silverbadges2020bronzebadges Addacomment  |  2 YouTubeautoplayworksonlydesktopinneedtoworkmobilejustmakechangesinJavaScript.Like vartag=document.createElement('script'); tag.src="https://www.youtube.com/iframe_api"; varfirstScriptTag=document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag,firstScriptTag); varplayer; functiononYouTubeIframeAPIReady(){ player=newYT.Player('player',{ videoId:'VideoID', playerVars:{ 'autoplay':1, 'rel':0, 'showinfo':0, 'modestbranding':1, 'playsinline':1, 'showinfo':0, 'rel':0, 'controls':0, 'color':'white', 'loop':1, 'mute':1, //'origin':'https://meeranblog24x7.blogspot.com/' }, events:{ 'onReady':onPlayerReady, //'onStateChange':onPlayerStateChange } }); } functiononPlayerReady(event){ player.playVideo(); player.mute(); }vardone=false; functiononPlayerStateChange(event){ if(event.data==YT.PlayerState.PLAYING&&!done){ setTimeout(stopVideo,6000); done=true; } } functionstopVideo(){ player.stopVideo(); } SeeMore:-YouTubeautoplayfor5seconds Share Improvethisanswer Follow answeredJun26'20at7:49 NahoorNahoor 22011goldbadge22silverbadges1212bronzebadges 1 Thisisthesolutionthatworkedbestforme.Iwouldtakeitastepfurtherandaddawrapperdivandaddtheresponsivecsstomaketheiframeresponsive:.video-container{overflow:hidden;position:relative;width:100%;}.video-container::after{padding-top:56.25%;display:block;content:'';}.video-containeriframe{position:absolute;top:0;left:0;width:100%;height:100%;} – nathanielperales Mar4at22:41 Addacomment  |  Highlyactivequestion.Earn10reputation(notcountingtheassociationbonus)inordertoanswerthisquestion.Thereputationrequirementhelpsprotectthisquestionfromspamandnon-answeractivity. Nottheansweryou'relookingfor?Browseotherquestionstaggedvideoyoutubeyoutube-apioraskyourownquestion. TheOverflowBlog IntroducingContentHealth,anewwaytokeeptheknowledgebaseup-to-date Podcast394:whatifyoucouldinvestinyourfavoritedeveloper? FeaturedonMeta Nowlive:Afullyresponsiveprofile Reducingtheweightofourfooter Linked 7 Autoplaywith



請為這篇文章評分?