当前位置: 首页>>代码示例>>Java>>正文


Java Video类代码示例

本文整理汇总了Java中com.google.api.services.youtube.model.Video的典型用法代码示例。如果您正苦于以下问题:Java Video类的具体用法?Java Video怎么用?Java Video使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Video类属于com.google.api.services.youtube.model包,在下文中一共展示了Video类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: searchYouTube

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
/**
 * Search method that runs a youtube search and converts the Video objects
 * to YouTubeSong objects
 * 
 * @param searchWord
 * @return List of songs
 */
private List<Song> searchYouTube(String searchWord) {

	List<Song> songList = new ArrayList<Song>();

	YouTubeSearch ys = new YouTubeSearch();

	List<Video> ytList = ys.search(searchWord); // List of videos from yt

	// Convert all videos to YouTubeSong and add them to songList
	for (int i = 0; i < ytList.size(); i++) {

		YouTubeSong s = new YouTubeSong();

		s.setTitle(ytList.get(i).getSnippet().getTitle());
		s.setArtist(ytList.get(i).getSnippet().getChannelTitle());
		s.setLength(ytList.get(i).getContentDetails().getDuration());
		s.setPath(ytList.get(i).getId());
		s.setThumbnailURL(ytList.get(i).getSnippet().getThumbnails().getDefault().getUrl());
		songList.add(s);
	}

	return songList;
}
 
开发者ID:brokenprogrammer,项目名称:RapidTunes,代码行数:31,代码来源:SearchHandler.java

示例2: schedule

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
@Override
public void schedule(final DateTime dateTime, final String videoid, final Account account) throws ScheduleIOException {

	try {
		final YouTube youTube = youTubeProvider.setAccount(account).get();

		final YouTube.Videos.List listVideosRequest = youTube.videos().list("status").setId(videoid);
		final VideoListResponse listResponse = listVideosRequest.execute();

		final List<Video> videoList = listResponse.getItems();
		if (videoList.isEmpty()) {
			LOGGER.info("Can't find a video with ID: " + videoid);
			return;
		}

		final Video video = videoList.get(0);
		final VideoStatus status = video.getStatus();
		status.setPublishAt(dateTime);

		youTube.videos().update("status", video).execute();
	} catch (final Exception e) {
		throw new ScheduleIOException(e);
	}
}
 
开发者ID:dennisfischer,项目名称:simplejavayoutubeuploader,代码行数:25,代码来源:ScheduleServiceImpl.java

示例3: getVideos

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
@Override
public List<Video> getVideos(List<String> videoIds)
{
	try
	{
		YouTube.Videos.List videos = getTubeService().videos().list("id,snippet,player,contentDetails,statistics");
		videos.setKey(getApiKey());
		videos.setId(Joiner.on(",").join(videoIds));
		VideoListResponse vlr = videos.execute();

		return vlr.getItems();
	}
	catch( Exception ex )
	{
		throw Throwables.propagate(ex);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:GoogleServiceImpl.java

示例4: itemsToMap

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
private List<YouTubeData> itemsToMap(List<Video> playlistItemList) {
  List<YouTubeData> result = new ArrayList<YouTubeData>();

  // convert the list into hash maps of video info
  for (Video playlistItem : playlistItemList) {
    YouTubeData map = new YouTubeData();

    map.mVideo = playlistItem.getId();
    map.mTitle = playlistItem.getSnippet().getTitle();
    map.mDescription = Utils.condenseWhiteSpace(playlistItem.getSnippet().getDescription());
    map.mThumbnail = thumbnailURL(playlistItem.getSnippet().getThumbnails());
    map.mDuration = Utils.durationToDuration((String) playlistItem.getContentDetails()
        .get("duration"));

    result.add(map);
  }

  return result;
}
 
开发者ID:sgehrman,项目名称:UTubeTV,代码行数:20,代码来源:YouTubeAPI.java

示例5: handleTemplate

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
@Override
public String handleTemplate(String msg, Interaction interaction, MessageBuilder response, MessageReceivedEvent event) {
    String param = interaction.getParameter();
    int selection = 0;
    try {
        selection = Integer.parseInt(param);
    } catch (NumberFormatException ignored){}
    if(selection>0 && selection<=3) {
        D4JSearch search = (D4JSearch) interaction.getTagCache().get(0);
        List<Video> resultArray = search.getResultArray(event.getAuthor().getStringID());
        interaction.setParameter(resultArray.get(selection-1).getId());
        msg = interaction.replaceMsg(msg,"%title", resultArray.get(selection - 1).getSnippet().getTitle());
    } else if(param.trim().equalsIgnoreCase("c")){
        msg = "Alright, I've deleted the results.";
        interaction.stopProcessing();
    } else {
        msg = interaction.getRandomTemplate("fail").getTemplate();
        interaction.addUsageCount();
    }
    return msg;
}
 
开发者ID:ripxfrostbite,项目名称:karren-sama,代码行数:22,代码来源:D4JSelect.java

示例6: createAttachments

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
@Override
protected List<Attachment> createAttachments(SectionInfo info)
{
	List<Attachment> attachments = Lists.newArrayList();
	List<String> videoIds = Lists.newArrayList(results.getSelectedValuesAsStrings(info));
	List<Video> videos = google.getVideos(videoIds);

	for( Video v : videos )
	{
		CustomAttachment a = new CustomAttachment();

		Channel channel = google.getChannel(v.getSnippet().getChannelId());
		a.setType(YoutubeUtils.ATTACHMENT_TYPE);

		Thumbnail defaultThumb = v.getSnippet().getThumbnails().getDefault();
		a.setData(YoutubeUtils.PROPERTY_THUMB_URL, defaultThumb.getUrl());
		a.setThumbnail(defaultThumb.getUrl());

		a.setData(YoutubeUtils.PROPERTY_PLAY_URL, "//www.youtube.com/v/" + v.getId());

		a.setData(YoutubeUtils.PROPERTY_ID, v.getId());
		a.setData(YoutubeUtils.PROPERTY_DURATION, v.getContentDetails().getDuration());
		a.setData(YoutubeUtils.PROPERTY_AUTHOR, channel.getSnippet().getTitle());
		DateTime uploaded = v.getSnippet().getPublishedAt();
		if( uploaded != null )
		{
			a.setData(YoutubeUtils.PROPERTY_DATE, uploaded.getValue());
		}
		String title = v.getSnippet().getTitle();
		a.setData(YoutubeUtils.PROPERTY_TITLE, title);
		a.setDescription(title);

		attachments.add(a);
	}
	return attachments;
}
 
开发者ID:equella,项目名称:Equella,代码行数:37,代码来源:YoutubeHandler.java

示例7: reloadUi

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
private void reloadUi(final PlaylistVideos playlistVideos, boolean fetchPlaylist) {
    // initialize the cards adapter
    initCardAdapter(playlistVideos);

    if (fetchPlaylist) {
        // start fetching the selected playlistVideos contents
        new GetPlaylistAsyncTask(mYouTubeDataApi) {
            @Override
            public void onPostExecute(Pair<String, List<Video>> result) {
                handleGetPlaylistResult(playlistVideos, result);
            }
        }.execute(playlistVideos.playlistId, playlistVideos.getNextPageToken());
    }
}
 
开发者ID:mrprona92,项目名称:SecretBrand,代码行数:15,代码来源:YouTubeRecyclerPlaylistFragment.java

示例8: initCardAdapter

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
private void initCardAdapter(final PlaylistVideos playlistVideos) {
    // create the adapter with our playlistVideos and a callback to handle when we reached the last item
    mPlaylistCardAdapter = new PlaylistCardAdapter(playlistVideos, new PlaylistCardAdapter.LastItemReachedListener() {
        @Override
        public void onLastItem(int position, String nextPageToken) {
            new GetPlaylistAsyncTask(mYouTubeDataApi) {
                @Override
                public void onPostExecute(Pair<String, List<Video>> result) {
                    handleGetPlaylistResult(playlistVideos, result);
                }
            }.execute(playlistVideos.playlistId, playlistVideos.getNextPageToken());
        }
    }, new PlaylistCardAdapter.ClickOnItemListener() {
        @Override
        public void onItemClick(int position) {
            int rand = new Random().nextInt(2);
            if (rand % 2 == 0) {
                if (mInterstitialAd.isLoaded()) {
                    mInterstitialAd.show();
                } else {
                    Log.d("TAG", "The interstitial wasn't loaded yet.");
                }
            }
        }
    });
    mRecyclerView.setAdapter(mPlaylistCardAdapter);
}
 
开发者ID:mrprona92,项目名称:SecretBrand,代码行数:28,代码来源:YouTubeRecyclerPlaylistFragment.java

示例9: handleGetPlaylistResult

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
private void handleGetPlaylistResult(PlaylistVideos playlistVideos, Pair<String, List<Video>> result) {
    if (result == null) return;
    final int positionStart = playlistVideos.size();
    playlistVideos.setNextPageToken(result.first);
    playlistVideos.addAll(result.second);
    mPlaylistCardAdapter.notifyItemRangeInserted(positionStart, result.second.size());
}
 
开发者ID:mrprona92,项目名称:SecretBrand,代码行数:8,代码来源:YouTubeRecyclerPlaylistFragment.java

示例10: getVideoTitleFromYouTubeDataAPIs

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
private Single<String> getVideoTitleFromYouTubeDataAPIs(String videoId) {
    SingleOnSubscribe<String> onSubscribe = emitter -> {
        try {
            YouTube youTubeDataAPIEndPoint = new YouTube
                    .Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null)
                    .setApplicationName(APP_NAME)
                    .build();

            VideoListResponse videoListResponse = youTubeDataAPIEndPoint
                    .videos()
                    .list("snippet")
                    .setFields("items(snippet(title))")
                    .setId(videoId)
                    .setKey(YOUTUBE_DATA_API_KEY)
                    .execute();

            if(videoListResponse.getItems().size() != 1)
                throw new RuntimeException("There should be exactly one video with the provided id");

            Video video = videoListResponse.getItems().get(0);
            String videoTitle = video.getSnippet().getTitle();
            emitter.onSuccess(videoTitle);

        } catch (IOException e) {
            emitter.onError(e);
        }
    };

    return Single.create(onSubscribe);
}
 
开发者ID:PierfrancescoSoffritti,项目名称:Android-YouTube-Player,代码行数:31,代码来源:MainActivity.java

示例11: onMessage

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
@Override
public void onMessage(final MessageEvent event) {
	super.onMessage(event);
	PircBotX bot = event.getBot();
	String[] splitMessage = event.getMessage().split(" ");
	for (String aSplitMessage : splitMessage) {
		if (aSplitMessage.contains("youtube.com") && aSplitMessage.contains("v=")) {
			int index = aSplitMessage.lastIndexOf("v=") + 2;
			String videoId = (aSplitMessage.indexOf("&",index) > -1 ? aSplitMessage.substring(index, aSplitMessage.indexOf("&",index)) : aSplitMessage.substring(index));
			System.out.println(videoId);
			try {
				YouTube.Videos.List videos = youtube.videos().list("id,snippet,contentDetails");
				videos.setKey(SettingsManager.getInstance().getSettings().getYoutubeKey());
				videos.setId(videoId);

				VideoListResponse videoListResponse = videos.execute();
				List<Video> videoList = videoListResponse.getItems();
				if (videoList != null) {
					Video firstResult = videoList.get(0);
					bot.sendIRC().message(event.getChannel().getName(), formatResult(firstResult));
				} else {
					bot.sendIRC().message(event.getChannel().getName(), "Could not find information about that video");
				}

			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:MCUpdater,项目名称:RavenBot,代码行数:31,代码来源:YouTubeHandler.java

示例12: formatResult

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
private String formatResult(Video result) {
	StringBuilder response = new StringBuilder();
	response.append(Colors.BOLD).append("Title: ").append(Colors.NORMAL).append(result.getSnippet().getTitle()).append(" ");
	response.append(Colors.BOLD).append("Length: ").append(Colors.NORMAL).append(result.getContentDetails().getDuration().substring(2)).append(" ");
	response.append(Colors.BOLD).append("Channel: ").append(Colors.NORMAL).append(result.getSnippet().getChannelTitle());
	return response.toString();
}
 
开发者ID:MCUpdater,项目名称:RavenBot,代码行数:8,代码来源:YouTubeHandler.java

示例13: directTag

import com.google.api.services.youtube.model.Video; //导入依赖的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();
}
 
开发者ID:sgehrman,项目名称:youtubeAPI,代码行数:30,代码来源:MainActivity.java

示例14: initCardAdapter

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
private void initCardAdapter(final PlaylistVideos playlistVideos) {
    // create the adapter with our playlistVideos and a callback to handle when we reached the last item
    mPlaylistCardAdapter = new PlaylistCardAdapter(playlistVideos, new LastItemReachedListener() {
        @Override
        public void onLastItem(int position, String nextPageToken) {
            new GetPlaylistAsyncTask(mYouTubeDataApi) {
                @Override
                public void onPostExecute(Pair<String, List<Video>> result) {
                    handleGetPlaylistResult(playlistVideos, result);
                }
            }.execute(playlistVideos.playlistId, playlistVideos.getNextPageToken());
        }
    });
    mRecyclerView.setAdapter(mPlaylistCardAdapter);
}
 
开发者ID:akoscz,项目名称:YouTubePlaylist,代码行数:16,代码来源:YouTubeRecyclerViewFragment.java

示例15: getVideo

import com.google.api.services.youtube.model.Video; //导入依赖的package包/类
@Override
public Video getVideo(String videoId)
{
	List<Video> videos = getVideos(Lists.newArrayList(videoId));
	return Check.isEmpty(videos) ? null : videos.get(0);
}
 
开发者ID:equella,项目名称:Equella,代码行数:7,代码来源:GoogleServiceImpl.java


注:本文中的com.google.api.services.youtube.model.Video类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。