Turning off autoplay on youtube videos - php

I have a PHP/jQuery scraper function that essentially looks for web page content.
One method looks for videos. When testing a youtube video page the video is scraped and is displayed just fine. Source code looks something like:
<embed width="320" height="240" bgcolor="#000000" allowfullscreen="true" allowscriptaccess="always" flashvars="account_playback_token=&ptk=KrebsCOHO%252Buser&enablecsi=1&iv_close_button=0&mpvid=AAS2NjXQtb70zY15&fexp=912208%2C914092%2C906423%2C901604&hl=en_GB&autohide=2&csi_page_type=watch5ad&keywords=Company+of+Heroes%2CCompany+of+Heroes+2%2CCOH+2%2CCOH%2CCOHO%2CCompany+of+Heroes+Online%2CvCOH%2CCommander%2CDefensive+Doctrine%2CAirborne+Doctrine%2CInfantry+Doctrine%2CBlitzkrieg+Doctrine%2CTerror+Doctrine%2CArmor+Doctrine%2CGenHansKrebs%2CKrebsCOHO%2CCompany+of+Heroes+Replays%2CCompany+of+Heroes+Casts%2CCompany+of+Heroes+Brits%2CCompany+of+Heroes+British%2CPanzer+Elite%2CTales+of+Valor%2COpposing+Fronts%2CCOH+Strategy%2CCompany+of+Heroes+Cheats%2CCompany+of+Heroes+Hacks&cr=GB&cc3_module=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fswfbin%2Fsubtitles3_module-vflNKUm_s.swf&host_language=en&iv3_module=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fswfbin%2Fiv3_module-vflVIYXve.swf&no_get_video_log=1&fmt_list=46%2F1920x1080%2F99%2F0%2F0%2C45%2F1280x720%2F99%2F0%2F0%2C22%2F1280x720%2F9%2F0%2F115%2C44%2F854x480%2F99%2F0%2F0%2C35%2F854x480%2F9%2F0%2F115%2C43%2F640x360%2F99%2F0%2F0%2C34%2F640x360%2F9%2F0%2F115%2C18%2F640x360%2F9%2F0%2F115%2C5%2F320x240%2F7%2F0%2F0&iv_storage_server=http%3A%2F%2Fwww.youtube.com%2Fannotations%2F&targeting_video_doc_id=&trueview=True&theme=tlb&ad_preroll=1&tk=A6fmSiw2bPJ1To1EkQ_GEhN5IQb7NH3SA2Lr7AmnDtyq0YRIw5HQFw%3D%3D&iv_load_policy=1&cc_font=Arial+Unicode+MS%2C+arial%2C+verdana%2C+_sans&watch_xlb=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fxlb%2Fwatch%2Fstrings-en_GB-vflXhsWkH.xlb&ad_channel_code_instream=afv_instream%2CVertical_Instream_8%2CVertical_Instream_41%2CVertical_Instream_933%2CVidVert8%2CVidVert41%2CVidVert933%2CVertical_8%2CVertical_41%2CVertical_933%2Cafv_instream_gb%2Cyt_mpvid_AAS2NjXQtb70zY15%2Cyt_cid_1640983%2Civp%2Cytexp_912208.914092.906423.901604%2Cytps_default%2Cytel_detailpage&sdetail=f%3Ag-u%2C&cafe_experiment_id=&timestamp=1326243854&cc_asr=1&ad_host=ca-host-pub-6901191551304350&ad_eurl=http%3A%2F%2Fwww.youtube.com%2Fvideo%2F0LzC0V_6TfI&showpopout=1&url_encoded_fmt_stream_map=url%3Dhttp%253A%252F%252Fo-o.preferred.lhr14s15.v2.lscache4.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Csource%25252Cratebypass%25252Ccp%2526fexp%253D912208%25252C914092%25252C906423%25252C901604%2526itag%253D46%2526ip%253D95.0.0.0%2526signature%253DBB3EA0AD473B59EC8EE739170DFC4252629C04F1.A698AF6CCB326B05C6F31A687CB5C47003607517%2526sver%253D3%2526ratebypass%253Dyes%2526source%253Dyoutube%2526expire%253D1326268838%2526key%253Dyt1%2526ipbits%253D8%2526cp%253DU0hRS1JRVl9IUkNOMV9KS1pJOnVjQzhtUzNZVjVv%2526id%253Dd0bcc2d15ffa4df2%26quality%3Dhd1080%26fallback_host%3Dtc.v2.cache4.c.youtube.com%26type%3Dvideo%252Fwebm%253B%2Bcodecs%253D%2522vp8.0%252C%2Bvorbis%2522%26itag%3D46%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.lhr14s15.v22.lscache1.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Csource%25252Cratebypass%25252Ccp%2526fexp%253D912208%25252C914092%25252C906423%25252C901604%2526itag%253D45%2526ip%253D95.0.0.0%2526signature%253D9CA9C6F49F04CB131E4D3B9CFD12846CFA9E0C20.20C107ED1D2902332117EE528BB48DCB8A24D7CB%2526sver%253D3%2526ratebypass%253Dyes%2526source%253Dyoutube%2526expire%253D1326268838%2526key%253Dyt1%2526ipbits%253D8%2526cp%253DU0hRS1JRVl9IUkNOMV9KS1pJOnVjQzhtUzNZVjVv%2526id%253Dd0bcc2d15ffa4df2%26quality%3Dhd720%26fallback_host%3Dtc.v22.cache1.c.youtube.com%26type%3Dvideo%252Fwebm%253B%2Bcodecs%253D%2522vp8.0%252C%2Bvorbis%2522%26itag%3D45%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.lhr14s15.v1.lscache1.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Csource%25252Cratebypass%25252Ccp%2526fexp%253D912208%25252C914092%25252C906423%25252C901604%2526itag%253D22%2526ip%253D95.0.0.0%2526signature%253DB20BCC27B8113F47F66278E4208FE39BD53963C2.053298B3B43263F014DE8F65BE964D3815CB7683%2526sver%253D3%2526ratebypass%253Dyes%2526source%253Dyoutube%2526expire%253D1326268838%2526key%253Dyt1%2526ipbits%253D8%2526cp%253DU0hRS1JRVl9IUkNOMV9KS1pJOnVjQzhtUzNZVjVv%2526id%253Dd0bcc2d15ffa4df2%26quality%3Dhd720%26fallback_host%3Dtc.v1.cache1.c.youtube.com%26type%3Dvideo%252Fmp4%253B%2Bcodecs%253D%2522avc1.64001F%252C%2Bmp4a.40.2%2522%26itag%3D22%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.lhr14s15.v10.lscache8.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Csource%25252Cratebypass%25252Ccp%2526fexp%253D912208%25252C914092%25252C906423%25252C901604%2526itag%253D44%2526ip%253D95.0.0.0%2526signature%253D716B089CA9DFDB211533C46127FF2183118B8113.881E822D36F6CF39699C3BFAE2AFCF97B4BB9586%2526sver%253D3%2526ratebypass%253Dyes%2526source%253Dyoutube%2526expire%253D1326268838%2526key%253Dyt1%2526ipbits%253D8%2526cp%253DU0hRS1JRVl9IUkNOMV9KS1pJOnVjQzhtUzNZVjVv%2526id%253Dd0bcc2d15ffa4df2%26quality%3Dlarge%26fallback_host%3Dtc.v10.cache8.c.youtube.com%26type%3Dvideo%252Fwebm%253B%2Bcodecs%253D%2522vp8.0%252C%2Bvorbis%2522%26itag%3D44%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.lhr14s15.v14.lscache5.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Csource%25252Calgorithm%25252Cburst%25252Cfactor%25252Ccp%2526fexp%253D912208%25252C914092%25252C906423%25252C901604%2526algorithm%253Dthrottle-factor%2526itag%253D35%2526ip%253D95.0.0.0%2526burst%253D40%2526sver%253D3%2526signature%253D724A616F7861BC4BFF321FAC98F78FEF9F50183D.540D2E9D4E1772AE72CE68124A6BDCA3844E37FA%2526source%253Dyoutube%2526expire%253D1326268838%2526key%253Dyt1%2526ipbits%253D8%2526factor%253D1.25%2526cp%253DU0hRS1JRVl9IUkNOMV9KS1pJOnVjQzhtUzNZVjVv%2526id%253Dd0bcc2d15ffa4df2%26quality%3Dlarge%26fallback_host%3Dtc.v14.cache5.c.youtube.com%26type%3Dvideo%252Fx-flv%26itag%3D35%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.lhr14s15.v9.lscache2.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Csource%25252Cratebypass%25252Ccp%2526fexp%253D912208%25252C914092%25252C906423%25252C901604%2526itag%253D43%2526ip%253D95.0.0.0%2526signature%253D5690ED3BF298418A63A1FC3C88C958A68584195B.457E8F33852B796BECA5640EF06DC20DDE82154C%2526sver%253D3%2526ratebypass%253Dyes%2526source%253Dyoutube%2526expire%253D1326268838%2526key%253Dyt1%2526ipbits%253D8%2526cp%253DU0hRS1JRVl9IUkNOMV9KS1pJOnVjQzhtUzNZVjVv%2526id%253Dd0bcc2d15ffa4df2%26quality%3Dmedium%26fallback_host%3Dtc.v9.cache2.c.youtube.com%26type%3Dvideo%252Fwebm%253B%2Bcodecs%253D%2522vp8.0%252C%2Bvorbis%2522%26itag%3D43%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.lhr14s15.v6.lscache4.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Csource%25252Calgorithm%25252Cburst%25252Cfactor%25252Ccp%2526fexp%253D912208%25252C914092%25252C906423%25252C901604%2526algorithm%253Dthrottle-factor%2526itag%253D34%2526ip%253D95.0.0.0%2526burst%253D40%2526sver%253D3%2526signature%253D893DB716EDFB212C142092E4CDBCC0411D5F739F.ABE5CCCB87A14F189EF7CC5B09E5E9155FA42A4C%2526source%253Dyoutube%2526expire%253D1326268838%2526key%253Dyt1%2526ipbits%253D8%2526factor%253D1.25%2526cp%253DU0hRS1JRVl9IUkNOMV9KS1pJOnVjQzhtUzNZVjVv%2526id%253Dd0bcc2d15ffa4df2%26quality%3Dmedium%26fallback_host%3Dtc.v6.cache4.c.youtube.com%26type%3Dvideo%252Fx-flv%26itag%3D34%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.lhr14s15.v5.lscache4.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Csource%25252Cratebypass%25252Ccp%2526fexp%253D912208%25252C914092%25252C906423%25252C901604%2526itag%253D18%2526ip%253D95.0.0.0%2526signature%253D961584FFF0C062FAD18B1D50B608148227664DB6.0BE5C5579A29A79168BBFD3356A60CA015603F10%2526sver%253D3%2526ratebypass%253Dyes%2526source%253Dyoutube%2526expire%253D1326268838%2526key%253Dyt1%2526ipbits%253D8%2526cp%253DU0hRS1JRVl9IUkNOMV9KS1pJOnVjQzhtUzNZVjVv%2526id%253Dd0bcc2d15ffa4df2%26quality%3Dmedium%26fallback_host%3Dtc.v5.cache4.c.youtube.com%26type%3Dvideo%252Fmp4%253B%2Bcodecs%253D%2522avc1.42001E%252C%2Bmp4a.40.2%2522%26itag%3D18%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.lhr14s15.v21.lscache4.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbits%25252Citag%25252Csource%25252Calgorithm%25252Cburst%25252Cfactor%25252Ccp%2526fexp%253D912208%25252C914092%25252C906423%25252C901604%2526algorithm%253Dthrottle-factor%2526itag%253D5%2526ip%253D95.0.0.0%2526burst%253D40%2526sver%253D3%2526signature%253DA9B71D32C230E1F299E367D90AFA645A5D5E80A0.7E100FAA814386C7560B9657AA6932F2D8983458%2526source%253Dyoutube%2526expire%253D1326268838%2526key%253Dyt1%2526ipbits%253D8%2526factor%253D1.25%2526cp%253DU0hRS1JRVl9IUkNOMV9KS1pJOnVjQzhtUzNZVjVv%2526id%253Dd0bcc2d15ffa4df2%26quality%3Dsmall%26fallback_host%3Dtc.v21.cache4.c.youtube.com%26type%3Dvideo%252Fx-flv%26itag%3D5&tmi=1&iv_logging_level=3&ad_flags=0&endscreen_module=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fswfbin%2Fendscreen-vfl6o3XZn.swf&cid=1640983&referrer=None&afv_instream_max=20000&ad_logging_flag=1&t=vjVQa1PpcFPtL2KNy9BlI1YWfqrxIuH0Q7IxA2lS4fY%3D&sffb=True&ttsurl=http%3A%2F%2Fwww.youtube.com%2Fapi%2Ftimedtext%3Fsparams%3Dasr_langs%252Ccaps%252Cexpire%252Cv%26asr_langs%3Den%252Cko%252Cja%26caps%3Dasr%26expire%3D1326268800%26key%3Dyttt1%26signature%3D08601E0AFAF4E565C284D451574665CE892A187A.C3A7BCC212D929F08BA9FB37BA1FA706CE8B408B%26hl%3Den-GB&aftv=True&creator=KrebsCOHO&allow_embed=1&ad_host_tier=2902314&rvs=view_count%3D1%252C978%26author%3DKrebsCOHO%26length_seconds%3D2153%26id%3D51if2_4DyoY%26title%3DCompany%2Bof%2BHeroes%2B%252395%2B-%2BGuess%2BWho%2527s%2BBack%2Cview_count%3D1%252C287%26author%3DKrebsCOHO%26length_seconds%3D2128%26id%3DnpOGF24Xun0%26title%3DBattlefield%2B3%2B%25239%2B-%2BThe%2BAmazing%2BBack%2Bto%2BKarkand%2Cview_count%3D2%252C386%26author%3DKrebsCOHO%26length_seconds%3D2913%26id%3Dc91SxbW5RTI%26title%3D%255BCOH%255D%2B%252382%2B-%2BOne%2BMove%2Bto%2BChange%2Bit%2BAll%2Cview_count%3D1%252C337%26author%3Dfrewd100%26length_seconds%3D1555%26id%3DsgxLZTsoZEk%26title%3DCompany%2Bof%2BHeroes%2B3v3%2BOnline%2BBattle%2BRefinery%2B%25281%252F2%2529%2Cview_count%3D3%252C077%26author%3DKrebsCOHO%26length_seconds%3D3400%26id%3D5fHOapLYenQ%26title%3DCompany%2Bof%2BHeroes%2B%252397%2B-%2BEurope%2BIn%2BRuins%2BShowcase%2Cview_count%3D27%252C804%26author%3DEvolvSports%26length_seconds%3D351%26id%3DP4y5fdDZH60%26title%3DChris%2BSharma%2Band%2BMatt%2BSegal%2Bon%2Bthe%2BShaman%2Cview_count%3D2%252C037%26author%3DKrebsCOHO%26length_seconds%3D2569%26id%3DolWg5hYRv0o%26title%3DCompany%2Bof%2BHeroes%2B%252393%2B-%2BValiant%2BSacrifices%2Cview_count%3D255%252C178%26author%3DTheIllustrationArt%26length_seconds%3D180%26id%3DbN1_h_eGitE%26title%3DThe%2BTale%2Bof%2Bthe%2BThree%2BBrothers%2B%2528HD%2529%2Cview_count%3D4%252C312%26author%3DKrebsCOHO%26length_seconds%3D2418%26id%3DG1Isd6SM8aM%26title%3D%255BCOH%255D%2B%252374%2B-%2BLevel%2B20%2BWehrmacht%2Cview_count%3D7%252C734%26author%3DVorbeugungshaft%26length_seconds%3D292%26id%3DEO7NIzsBf44%26title%3DLeger%2Bdes%2BHeils%2B-%2BDer%2BGott%252C%2Bder%2BEisen%2Bwachsen%2Blie%25C3%259F%2Cview_count%3D153%252C325%26author%3DSarahFan0503%26length_seconds%3D338%26id%3DAnUVqu4CYus%26title%3DSarah%2BConnor%2B-%2B%2522Christmas%2BIn%2BMy%2BHeart%2522%2BLIVE%2B%2540%2BThe%2BChristmas%2BSpecial%2B2005%2Cview_count%3D23%252C660%26author%3DTriple6Games%26length_seconds%3D428%26id%3DEPUYh57VlH8%26title%3DTropico%2B4-PC%2BGameplay%2BHD%2BMaxed%2BOut&vq=auto&iv_enabled_features=TCS&sendtmp=1&ad3_module=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fswfbin%2Fad3-vfly6I_ZM.swf&gut_tag=%2F4061%2Fytunknown%2Fmain&ptchn=KrebsCOHO&as_launched_in_country=1&length_seconds=2779&feature=g-u&enablejsapi=1&plid=AAS2NjXP5DaZ4rS5&iv_module=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fswfbin%2Fiv_module-vflBrKDBK.swf&afv=True&ad_video_pub_id=ca-pub-6219811747049371&ad_slots=0&watermark=%2Chttp%3A%2F%2Fs.ytimg.com%2Fyt%2Fimg%2Fwatermark%2Fyoutube_watermark-vflHX6b6E.png%2Chttp%3A%2F%2Fs.ytimg.com%2Fyt%2Fimg%2Fwatermark%2Fyoutube_hd_watermark-vflAzLcD6.png&supersizefeatured=1&oid=oyMOP28xy70&cc_module=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fswfbin%2Fsubtitle_module-vfld45BNe.swf&ad_channel_code_overlay=invideo_overlay_480x70_cat20%2Cafv_overlay%2CVertical_Overlay_8%2CVertical_Overlay_41%2CVertical_Overlay_933%2CVidVert8%2CVidVert41%2CVidVert933%2CVertical_8%2CVertical_41%2CVertical_933%2Cyt_mpvid_AAS2NjXQtb70zY15%2Cyt_cid_1640983%2Civp%2Cytexp_912208.914092.906423.901604%2Cytps_default%2Cytel_detailpage&pyv_in_related_cafe_experiment_id=&video_id=0LzC0V_6TfI&sk=KGM0UWVabLqnTDH6CGaGWIPrk8jgepgiC" id="movie_player" src="http://s.ytimg.com/yt/swfbin/watch_as3-vfl7SkMGe.swf" type="application/x-shockwave-flash">
What I would like to know is, how can I stop this video from autoplaying? I have tried various ways of adding autoplay=0 after the src etc with no luck.
Has anyone had experience with the method I'm using? Is it technically viable?
Thanks

You are over-complicating things, You should grab the youtube video ID with a little regex:
if(preg_match('/(?<=video_id=).*?(?=&|")/',$str,$matches)){
$video_id = $matches[0];
}
And then use it to create the real embed code:
$youtube = '<iframe width="853" height="480" src="http://www.youtube.com/embed/'.$video_id.'?hd=1" frameborder="0" allowfullscreen></iframe>'
And then it never auto-plays

try by adding the following to the URL variables:
&autoplay=0

Related

How to play youtube video from MySQL database

I have a form which a user can enter a youtube link along with their product. I want to be able to play that video (which it's link is stored in a MySQL database, the problem is that the <iframe> tag needs a youtube "Embed" link and not the URL, is there a way to convert the URL to the Embed link?
video_url = https://www.youtube.com/watch?v=1DIDWWKk8Bg
//code to connect to MySQL DB and get all rows
$videourl = $row["video_url"];
}
?>
<iframe width="420" height="345" src="<?php $videourl?>">
</iframe>
Regular YouTube link look like this
https://www.youtube.com/watch?v=1234
Embed YouTube link look like this
https://www.youtube.com/embed/1234
You need just to replace this watch?v= to embed/
$link = "https://www.youtube.com/watch?v=1234";
echo str_replace("watch?v=", "embed/",$link);
You have to use embed.
like this.
$videourl = explode("https://www.youtube.com/watch?v=", $row['videourl']);
<iframe class="iframeVideo" src="https://www.youtube.com/embed/' . $videourl[1] . '"></iframe>
$videourl has to look like this https://www.youtube.com/watch?v=3J6o7hcm8bE
I hope this works for you.
You cannot not use the exact url from the youtube video. The url used in iframes has the following format http://www.youtube.com/embed/unique_id_here. So you only have to save the unique_id for each video. It is only a part of the url. For example, from this url: https://www.youtube.com/watch?v=hdhjs88737&list=RDEMnLv8DM0l6F9uGd8jrENGgg&index=3, the unique id is the one in bold: hdhjs88737. So here is what I would do. Go to any video on youtube and click the share option, under the options select embed. Then copy the code. It will look like this:
<iframe width="560" height="315" src="https://www.youtube.com/embed/<unique_id_here>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Modify the parameters in the iframe to fit your preferences then only save the unique_id to your database. That should solve your problem. Check this API reference for a detailed guide.
Here is what I used, I'm not sure if this code should be there twice but it works so...
<?php
str_replace("watch?v=", "embed/",$videourl);
?>
<iframe width="520" height="345" src="<?php echo str_replace("watch?v=", "embed/",$videourl);?>">
</iframe>
Thank you for the help.

How to play youtube video link in php

I want to play youtube video link on my php page
youtube link is
https://www.youtube.com/watch?v=VAJK04HOLd0
<object width="420" height="315" data="https://www.youtube.com/watch?v=VAJK04HOLd0">
i am try this code but it's not working
You can load the video file in <iframe>. Try this sample code,
<iframe width="560" height="315" src="https://www.youtube.com/embed/VAJK04HOLd0" frameborder="0" allowfullscreen></iframe>
Look at the last part of the url https://www.youtube.com/embed/VAJK04HOLd0,
VAJK04HOLd0
Which is the youtube video code. If you want to change the video change the code.
To embed YouTube videos, you should be using an iframe.
<iframe id="ytplayer" type="text/html" width="640" height="390" src="http://example.com/?autoplay=1" frameborder="0"/>
It's not connected to php.
You will want to include &autoplay=1 to the youtube string.

Wordpress- <iframe> is incorrectly interpreting url page content

I'm trying to embed a vimeo player in my Wordpress 3.8 site. To make changing the video a little easier, I've created Page which just contains the url for a Vimeo video. On the site, I try to embed the video like so:
<iframe allowfullscreen="" frameborder="0" mozallowfullscreen="" src="<? echo apply_filters('the_content', get_page(925)->post_content); ?>" webkitallowfullscreen=""></iframe>
But when I view the site, it just loads an empty page template inside the frame! When I echo that php chunk outside the iframe, however, it returns the url as expected. Putting in the url directly causes it to work fine, and I've tried a ton of quotation configurations to make sure the error wasn't there. Any idea what is causing it to wig out?
why are you running apply_filters on this? Also, get_page is deprecated.
Try something like this:
<?php
$vidPost = get_post(925);
echo '<iframe allowfullscreen="" frameborder="0" mozallowfullscreen="" src="'.$vidPost->post_content.'" webkitallowfullscreen=""></iframe>';
?>

How to get around This Content cannot be displayed in a frame? (Youtube issue)

I'm trying to keep a database of posted videos on a site I am currently developing. To be able to do this I have to store the URLs of the videos into a database and then I call the url from the database using php and sql by doing this bare in mind I am using this from a php defined area on my homepage. If I use this code it works on other video post sites!
echo '<iframe width="640" height="390" src="', $row['Post_URL'],'"frameborder="0" allowFullScreen></iframe>';
This will not work it says content cannot be displayed in a frame but if I do this it works.
<?php
echo '<iframe width="560" height="315" src="http://www.youtube.com/embed/wardQ7W8hPU" frameborder="0" allowfullscreen></iframe>';
?>
why does the one work properly and the other not? what is a way around this so I can call from the database into php and echo it out so it will display properly on the page?
I got the same problem today. As stated in one of the comments, the problem is the url used...
The iframe embed only works with urls looking like:
http://www.youtube.com/embed/[video_id]
Most of people are using the "share" feature, that generates minified urls like:
http://youtu.be/[video_id]
However, if you look into the "embed" feature, you'll notice that it generates an iframe with src urls like the first example.
So to answer the question, when using iframes to embed, use the src url like the first example.
Try this
<iframe width="640" height="390" src="<?php echo $row['Post_URL'] ?>" frameborder="0" allowFullScreen></iframe>
OR this
<?php
echo "<iframe width='640' height='390' src='{$row['Post_URL']}' frameborder='0' allowFullScreen></iframe>";
?>
OR this
<?php
echo "<iframe width='640' height='390' src='" . $row['Post_URL'] . "' frameborder='0' allowFullScreen></iframe>";
?>
they all are the same and will do the same process.
I'm doing this with dynamic data and it's easier for the client to use the youtube Share link.
So... it's then just a matter of getting the youtube video ID from that url.
// we can't use the "share" link so need to just get the video ID
$youtubePath = parse_url($youtubeShareLink,PHP_URL_PATH);
$youtubeId = str_replace('/','',$youtubePath);
and now we can use the ID in an iframe (adjust width and height per embed options in youtube)
<iframe width="560" height="315" src="//www.youtube.com/embed/<? echo $youtubeId; ?>?rel=0" frameborder="0" allowfullscreen></iframe>

Programmatically Embed Blip.tv Videos

I'm trying to build a php video embedding function that parses the video URL automatically and then produces the right embed code out of that. I'm having trouble with the new blip.tv player because there is no reference the the video in the url that makes sense in the embed code. Here goes an example:
URL: http://blip.tv/NovusSwell/s3w31-hawaii-surfer-groms-with-potato-cannon-spud-gun-5471671
Embed Code:
<embed src="http://blip.tv/play/g8hQgs38GwI" type="application/x-shockwave-flash" width="550" height="327" wmode="transparent" allowscriptaccess="always" allowfullscreen="true" ></embed>
g8hQgs38GwI is the video Id that I cannot guess out of the URL.
Is there a solution to this?
According to Blip.tv Wiki here's what you need to do:
Get the RSS version of the item: http://blip.tv/rss/view/5471671 (Get id from the URL).
Parse what you got at step 1 (RSS is basically an XML file): Using XPath, the copy/paste code is found at /rss/channel/item/media:player

Categories