嗨,我是網頁設計新手。我正在創建一個代碼,用戶可以將他的電腦上的視頻上傳到YouTube。我正在使用Google視頻上傳小部件。但它只能讓我選擇從網絡攝像機錄製視頻。我沒有獲得從我的文檔(PC)瀏覽和選擇視頻的選項。請問我能得到一些幫助嗎?或者是否有其他方法將視頻上傳到YouTube並獲取其網址或ID?我需要它作爲管理員,我可以將它保存在數據庫中以便稍後查看視頻。 這裏是我的代碼:通過上傳部件上傳視頻
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html>
<html>
<body>
<div id="widget"></div>
<div id="player"></div>
<script>
var tag = document.createElement('script');
tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var widget;
var player;
function onYouTubeIframeAPIReady() {
widget = new YT.UploadWidget('widget', {
width: 500,
events: {
'onUploadSuccess': onUploadSuccess,
'onProcessingComplete': onProcessingComplete
}
});
}
function onUploadSuccess(event) {
alert('Video ID ' + event.data.videoId + ' was uploaded and is currently being processed.');
}
function onProcessingComplete(event) {
player = new YT.Player('player', {
height: 390,
width: 640,
videoId: event.data.videoId,
events: {}
});
}
</script>
</body>
</html>
而且我的輸出是: