I ran into an interesting Issue today working on a Wall Feed Plugin. A majority of videos posted to the feed via youtube have autoplay enabled.
"source": "http://www.youtube.com/v/IXTS79iDTNA?version=3&autohide=1&autoplay=1",
I am trying to rewrite that url before embeding using php. How would you do this?
So far i have tried using strtr(); with array, seems though if there are alot of videos in the feed, things seem to slow down alot.
/* $fvalue[source] is the video url in graph api */
if($fvalue[source]){
$reWrite = array("autoplay=1" => "autoplay=0");
$getEmbed = $fvalue[source];
$strAuto = strtr($getEmbed, $reWrite);
echo '<object><embed src="'.$strAuto.'"></embed></object>';
}
It is slow because of the strstr
. Roughly speaking, str_replace
is 30-50 times faster.
//This code should be at least 30 times faster.
if($fvalue[source]){
$strAuto = str_replace("autoplay=1", "autoplay=0", $fvalue[source]);
echo '<object><embed src="'.$strAuto.'"></embed></object>';
}