如何重写 /feed 中启用自动播放的视频网址
今天我在开发 Wall Feed 插件时遇到了一个有趣的问题。通过 YouTube 发布到源的大多数视频都启用了自动播放。
"source": "http://www.youtube.com/v/IXTS79iDTNA?version=3&autohide=1&autoplay=1",
我试图在使用 php 嵌入之前重写该 url。你会怎么做?
到目前为止,我已经尝试使用 strtr();使用数组,似乎如果提要中有很多视频,事情似乎就会慢很多。
/* $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>';
}
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>';
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于
strstr
,它很慢。粗略地说,str_replace
速度快了 30-50 倍。It is slow because of the
strstr
. Roughly speaking,str_replace
is 30-50 times faster.