2014-01-30 207 views
-1

我正在嘗試使Vimeo視頻工作,但視頻仍然只是黑屏。哪裏不對?Vimeo視頻不起作用

<video src="//player.vimeo.com/video/20802032?title=0&amp;byline=0&amp;portrait=0&amp;color=990033" width="960" height="540" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></video> 

謝謝。

+2

什麼_you_做錯了就是把這個URL放在一個'video'元素中...... URL提供了一個完整的HTML文檔,所以嵌入它使用一個'iframe'。 – CBroe

+0

好吧,但iframe也不起作用... @CBroe – Caspert

回答

0

您需要改爲使用iframe

演示here

從小提琴例:

<iframe src="//player.vimeo.com/video/20802032?title=0&amp;byline=0&amp;portrait=0&amp;color=990033" width="960" height="540" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> 
2

正如其他人所說,你應該使用嵌入的iframe,而不是當前的嘗試。 Vimeo爲您擁有或以其他方式能夠(允許)嵌入的每個視頻提供此代碼。

獲得正確嵌入代碼的另一種方法是使用它們的端點oEmbed。例如,這JSON是爲您的視頻檢索:

http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/20802032

萬一你不小心點擊,這裏是什麼在該網址提供:

{ 
    "type":"video", 
    "version":"1.0", 
    "provider_name":"Vimeo", 
    "provider_url":"https:\/\/vimeo.com\/", 
    "title":"Motion Graphics Reel 2011", 
    "author_name":"timurfrost", 
    "author_url":"http:\/\/vimeo.com\/timurfrost", 
    "is_plus":"1", 
    "html":"<iframe src=\"\/\/player.vimeo.com\/video\/20802032\" width=\"1280\" height=\"720\" frameborder=\"0\" title=\"Motion Graphics Reel 2011\" webkitallowfullscreen mozallowfullscreen allowfullscreen><\/iframe>", 
    "width":1280, 
    "height":720, 
    "duration":78, 
    "description":"Motion Graphics Reel by Timur Frost", 
    "thumbnail_url":"http:\/\/b.vimeocdn.com\/ts\/161\/363\/161363406_1280.jpg", 
    "thumbnail_width":1280, 
    "thumbnail_height":720, 
    "video_id":20802032 
} 

正如你看到的,沒有理由猜測嵌入視頻的正確方法。僅使用視頻網址和此數據服務的知識,您可以提交http請求並檢索官方認可的嵌入html以及其他一些有用信息。