本文整理汇总了Java中com.google.api.services.youtube.model.VideoSnippet类的典型用法代码示例。如果您正苦于以下问题:Java VideoSnippet类的具体用法?Java VideoSnippet怎么用?Java VideoSnippet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VideoSnippet类属于com.google.api.services.youtube.model包,在下文中一共展示了VideoSnippet类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: directTag
import com.google.api.services.youtube.model.VideoSnippet; //导入依赖的package包/类
private void directTag(final VideoData video) {
final Video updateVideo = new Video();
VideoSnippet snippet = video
.addTags(Arrays.asList(
Constants.DEFAULT_KEYWORD,
Upload.generateKeywordFromPlaylistId(Constants.UPLOAD_PLAYLIST)));
updateVideo.setSnippet(snippet);
updateVideo.setId(video.getYouTubeId());
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... voids) {
YouTube youtube = new YouTube.Builder(transport, jsonFactory,
credential).setApplicationName(Constants.APP_NAME)
.build();
try {
youtube.videos().update("snippet", updateVideo).execute();
} catch (IOException e) {
Log.e(TAG, e.getMessage());
}
return null;
}
}.execute((Void) null);
Toast.makeText(this,
R.string.video_submitted_to_ytdl, Toast.LENGTH_LONG)
.show();
}
示例2: addTags
import com.google.api.services.youtube.model.VideoSnippet; //导入依赖的package包/类
public VideoSnippet addTags(Collection<? extends String> tags) {
VideoSnippet mSnippet = mVideo.getSnippet();
List<String> mTags = mSnippet.getTags();
if (mTags == null) {
mTags = new ArrayList<String>(2);
}
mTags.addAll(tags);
return mSnippet;
}
示例3: createVideoInsert
import com.google.api.services.youtube.model.VideoSnippet; //导入依赖的package包/类
private YouTube.Videos.Insert createVideoInsert(YouTube youtube, AbstractInputStreamContent mediaContent,
String title, String description) throws IOException {
// Add extra information to the video before uploading.
Video videoObjectDefiningMetadata = new Video();
/**
* Set the video to public, so it is available to everyone (what most people want). This is
* actually the default, but I wanted you to see what it looked like in case you need to set
* it to "unlisted" or "private" via API.
*/
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();
snippet.setTitle(title);
snippet.setDescription(description);
// Set completed snippet to the video object.
videoObjectDefiningMetadata.setSnippet(snippet);
/**
* 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);
// Set the upload type and add event listener.
MediaHttpUploader uploader = videoInsert.getMediaHttpUploader();
/**
* Sets whether direct media upload is enabled or disabled. True = whole media content is
* uploaded in a single request. False (default) = resumable media upload protocol to upload
* in data chunks.
*/
uploader.setDirectUploadEnabled(false);
return videoInsert;
}
示例4: YoutubeVideo
import com.google.api.services.youtube.model.VideoSnippet; //导入依赖的package包/类
public YoutubeVideo(com.google.api.services.youtube.model.Video v) {
setId(Sources.YOUTUBE + '#' + v.getId());
setSource(Sources.YOUTUBE);
title = v.getSnippet().getTitle();
description = v.getSnippet().getDescription();
creationDate = new Date(v.getSnippet().getPublishedAt().getValue());
crawlDate = new Date();
VideoStatistics statistics = v.getStatistics();
if (statistics != null) {
if(statistics.getFavoriteCount() != null) {
numLikes = statistics.getFavoriteCount().intValue();
}
if(statistics.getViewCount() != null) {
numViews = statistics.getViewCount().intValue();
}
if(statistics.getCommentCount() != null) {
numComments = statistics.getCommentCount().intValue();
}
}
VideoContentDetails details = v.getContentDetails();
if (details != null) {
quality = details.getDefinition();
}
VideoSnippet snippet = v.getSnippet();
Thumbnail t = snippet.getThumbnails().getHigh();
setThumbnail(t.getUrl());
setWidth(t.getWidth().intValue());
setHeight(t.getHeight().intValue());
url = "https://www.youtube.com/watch?v=" + v.getId();
webPageUrl = url;
UserAccount channel = new YoutubeChannel();
channel.setId(Sources.YOUTUBE + '#' + snippet.getChannelId());
channel.setSource(Sources.YOUTUBE);
channel.setUserId(snippet.getChannelId());
channel.setName(snippet.getChannelTitle());
channel.setPageUrl("https://www.youtube.com/channel/" + snippet.getChannelId());
channel.setDescription(snippet.getDescription());
setContributor(channel);
}
示例5: YoutubeUpload
import com.google.api.services.youtube.model.VideoSnippet; //导入依赖的package包/类
YoutubeUpload(File file, String token, String title, String description) throws IOException {
Credential credential = Auth.authorize(token);
youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential).setApplicationName("ttyrec2video.youtube").build();
Video metadata = new Video();
VideoStatus status = new VideoStatus();
status.setPrivacyStatus("public");
metadata.setStatus(status);
VideoSnippet snippet = new VideoSnippet();
snippet.setTitle(title);
snippet.setDescription(description);
metadata.setSnippet(snippet);
InputStreamContent content = new InputStreamContent("video/*", file.getAbsoluteFile().toURL().openStream());
YouTube.Videos.Insert videoinsert = youtube.videos().insert("snippet,statistics,status", metadata, content);
MediaHttpUploader uploader = videoinsert.getMediaHttpUploader();
uploader.setDirectUploadEnabled(false);
Video returnedVideo = videoinsert.execute();
System.out.println("https://youtu.be/" + returnedVideo.getId());
System.exit(0);
}