本文介紹了嵌入 Youtube 視頻的最佳方式是什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在建立一個視頻網站,我希望我的用戶能夠從 Youtube 上傳或嵌入視頻.Youtube API 似乎不提供從他們的網站上傳視頻,是嗎?所以我嘗試通過 iframe
使用 PHP 嵌入視頻.代碼如下:
I'm building a video website and I want my users to be able to upload or embed videos from Youtube. The Youtube API doesn't seem to provide video upload from their website, or do they?
So I tried to embed videos via an iframe
with PHP. Here is the code:
<?php
$source=$_POST['source'];
?>
<html>
<div id="bo"><?php echo $source;?></div>
<form action="altupload.php" method="post">
<input type="text" name="source">
<input type="submit">
</form>
</html>
但我得到的是:
<html><div id="bo"><iframe width="560" height="315" src="http://www.youtube.com/embed/tZa5hyb0_wA" frameborder="0" allowfullscreen></iframe></div>`
<html>
<form action="altupload.php" method="post">
<input type="text" name="source">
<input type="submit">
</form>
</html>
誰能推薦一些其他的方法來做到這一點?謝謝
Can anyone recommend some other ways to do it? Thanks
推薦答案
允許用戶僅上傳來自 URL 的 youtube 視頻 ID 為:
Allow the user upload only youtube video ID from URL as :
http://www.youtube.com/watch?v=Vw5FDZRGTL0
視頻 ID:Vw5FDZRGTL0
你可以設置IFrame標簽的其他選項:
and you can set other options of IFrame tag :
<iframe width="420" height="315" src="http://www.youtube.com/embed/<?php echo $videoID; ?>" frameborder="0" allowfullscreen></iframe>
祝你好運
這篇關于嵌入 Youtube 視頻的最佳方式是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!