2015-11-04 77 views
0

我想創建一個網站,允許用戶將視頻上傳到YouTube頻道,並將這些YouTube視頻嵌入到我的網站中。這可能使用YouTube的API嗎?我將如何去學習如何做到這一點?我熟悉HTML5/CSS3和Python,熟悉Java和JavaScript。任何建議非常感謝。使用YouTube API顯示用戶上傳的視頻

+0

以下是您可以查看的一些相關文檔:https://developers.google.com/youtube/v3/guides/uploading_a_video,https://developers.google.com/youtube/iframe_api_reference,https://開發人員.google.com/YouTube的/ V3 /引導/認證。 –

回答

0

你試過了嗎? YouTube API

的YouTube API有蟒蛇的API,讓你在你的網站上使用的YouTube

0

下面是使用JavaScript調用YouTube播放器播放嵌入在網頁中的視頻樣本頁面。該示例顯示瞭如何播放一個視頻以及如何排列幾個視頻然後播放它們。該示例在頁面加載時自動播放默認視頻。視頻播放完畢後,會播放默認視頻。

<!doctype html> 
<html lang="en"> 
<head> 
<title>Play YouTube Videos</title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
</head> 
<body> 
<script type="text/javascript"> 
var tag = document.createElement('script'); 
tag.src = "https://www.youtube.com/player_api"; 
var firstScriptTag = document.getElementsByTagName('script')[0]; 
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 
var player; 
var videosQueuedCount; 
function onYouTubePlayerAPIReady() { 
videosQueuedCount = 1; 
var vars = { 
    autoplay: 1, 
    enablejsapi: 1, 
    controls: 1 
} 
player = new YT.Player('ytplayer', { 
    height: '390', 
    width: '640', 
    playerVars: vars, 
    videoId:'HL6ZL9q3UJ8', 
    events: { 
     'onReady': onPlayerReady, 
     'onStateChange': onPlayerStateChange 
      } 
}); 
} 
function onPlayerReady(evt) { 
} 
function playVideo(VID) { 
    window.top.scrollTo(0,200); 
    videosQueuedCount = 1; 
    player.loadVideoById(VID); 
} 
function queueVideo(queuedCount,VID) { 
    window.top.scrollTo(0,200); 
    videosQueuedCount = queuedCount; 
    player.loadPlaylist(VID); 
    player.playVideo(); 
} 
function onPlayerStateChange(event) { 
    if (event.data == YT.PlayerState.ENDED) { 
    videosQueuedCount -= 1; 
    if (videosQueuedCount < 1) { 
     videosQueuedCount = 1; 
     playVideo('HL6ZL9q3UJ8'); 
    } 
    } 
} 
</script> 
<div id="ytplayer"></div> 
<p><b>10/22/2015</b> <a href="javascript:playVideo('kaLlstcp5GE');">East Lyme, CT Issues and Answers (28:26)</a><br> 
Information<br>Teri Smith of Smith&#39;s Acres and Niantic Main Street<br> 
</p> 
<p><b>10/21/2015 East Lyme, CT Board of Selectmen Meeting</b><br> 
Regular Meeting<br> 
<a href="javascript:playVideo('naz9POIJvwI');">Part 1 (28:50)</a>&nbsp;&nbsp;&nbsp; 
<a href="javascript:playVideo('q3p1eexyUxY');">Part 2 (29:25)</a>&nbsp;&nbsp;&nbsp; 
<a href="javascript:playVideo('R17mYVS4ZMg');">Part 3 (29:17)</a>&nbsp;&nbsp;&nbsp; 
<a href="javascript:playVideo('jDiaFwVfHWg');">Part 4 (01:53)</a>&nbsp;&nbsp;&nbsp; 
<a href="javascript:queueVideo(4,['naz9POIJvwI','q3p1eexyUxY','R17mYVS4ZMg','jDiaFwVfHWg']);">All</a>&nbsp;&nbsp;&nbsp; 
</p> 
</body> 
</html> 

我希望這有助於!