我正在尝试将视频从设备内存上传到YouTube品牌帐户。
我做了什么
我成功创建了一个使用YouTube数据API v3的应用,并且可以很好地将视频上传到当前通过OAuth2选择的帐户中。
现在,我要将视频上传到一个品牌帐户,该帐户已与此选定的用户帐户关联(由具有相同gmail ID的同一人创建)。
我找不到适用于Android的适当文档。
所以我只是做了一些实验,并更改了一些我的代码,如下所示:
// Add extra information to the video before uploading.
Video videoObjectDefiningMetadata = new Video();
// Set the video to public (default).
VideoStatus status = new VideoStatus();
status.setPrivacyStatus("public");
videoObjectDefiningMetadata.setStatus(status);
// We set a majority of the metadata with the VideoSnippet object.
VideoSnippet snippet = new VideoSnippet();
// Video file name.
snippet.setTitle(uTitle);
snippet.setChannelId(BradAccountChannelID); // I added this to set Channel ID
snippet.setDescription(uDescription);
// Set completed snippet to the video object.
videoObjectDefiningMetadata.setSnippet(snippet);
InputStreamContent mediaContent = new InputStreamContent(
VIDEO_FILE_FORMAT, new BufferedInputStream(new FileInputStream(videoFile)));
mediaContent.setLength(videoFile.length());
/*
* The upload command includes: 1. Information we want returned after file is successfully
* uploaded. 2. Metadata we want associated with the uploaded video. 3. Video file itself.
*/
YouTube.Videos.Insert videoInsert = youtube.videos()
.insert("snippet,statistics,status", videoObjectDefiningMetadata, mediaContent)
.setKey(Config.YOUTUBE_API_KEY)
.setOnBehalfOfContentOwnerChannel(BradAccountChannelID); //I setted this because the user is the owner of all brand account which he creates.
我遇到了问题:
但是我遇到了IOException:500 Internal Server Error { “代码”:500, “消息”:null }。
我不知道发生了什么。如果有人可以找到问题,请帮助我。 预先谢谢你。