I wanted to allow users to be able to add videos but I'm having an issue with one of the sites.
I will allow videos from Youtube, Vimeo, Vevo, Daily Motion and MTV.
The problem is for MTV. The URL is always different, so I was wondering if there ways to get the source value of an IFrame/embed code.
Example: MTV embed code is:
<div style="background-color:#000000;width:520px;">
<div style="padding:4px;">
<iframe src="http://media.mtvnservices.com/embed/mgid:uma:videolist:mtv.com:1687162/cp~instance%3Dfullepisode%26autoPlay%3Dfalse%26series%3D2211%26seriesId%3D29240%26channelId%3D1%26id%3D1687162%26instance%3Dfullepisode%26uri%3Dmgid%3Auma%3Avideolist%3Amtv.com%3A1687162" width="512" height="288" frameborder="0"></iframe>
<p style="text-align:left;background-color:#FFFFFF;padding:4px;margin-top:4px;margin-bottom:0px;font-family:Arial, Helvetica, sans-serif;font-size:12px;">Get More:
<a href="http://www.mtv.com/shows/teen_mom/season_4/series.jhtml" style="color:#439CD8;" target="_blank">Teen Mom (Season 4)</a>, <a href="http://www.mtv.com/videos/home.jhtml" style="color:#439CD8;" target="_blank">Full Episodes</a></p></div></div>
Is there a way I can get the IFrame source value out of that complete string?
I just want :
http://media.mtvnservices.com/embed/mgid:uma:videolist:mtv.com:1687162/cp~instance%3Dfullepisode%26autoPlay%3Dfalse%26series%3D2211%26seriesId%3D29240%26channelId%3D1%26id%3D1687162%26instance%3Dfullepisode%26uri%3Dmgid%3Auma%3Avideolist%3Amtv.com%3A1687162
Any help would be appreciated. The other video sources were simple since I was able to use the physical URL itself rather than the embed code.
That's valid HTML, so you can easily parse it with SimpleXML:
$root = simplexml_load_string($embed_code);
$url = (string) $root->div->iframe['src'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With