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


Java YouTubeRequestInitializer类代码示例

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


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

示例1: upload

import com.google.api.services.youtube.YouTubeRequestInitializer; //导入依赖的package包/类
@Override
public void upload(Account account, HashMap<String, String> valueMap) {
	Timber.d("Upload file: Entering upload");
	
	String title = valueMap.get(VALUE_KEY_TITLE);
	String body = valueMap.get(VALUE_KEY_BODY);
	String mediaPath = valueMap.get(VALUE_KEY_MEDIA_PATH);
	boolean useTor = (valueMap.get(VALUE_KEY_USE_TOR).equals("true")) ? true : false;
	
	List<String> scopes = new ArrayList<String>();
	scopes.add(YouTubeScopes.YOUTUBE_UPLOAD);
	
	//set username
	GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(super.mContext, scopes);
	credential.setSelectedAccountName(account.getCredentials());
	
	//set proxy
	useTor=false; //FIXME Hardcoded until we find a Tor workaround
	if(super.torCheck(useTor, super.mContext)) {
		Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(ORBOT_HOST, ORBOT_HTTP_PORT));
		transport = new NetHttpTransport.Builder().setProxy(proxy).build();
	}
	
       mYoutube = new com.google.api.services.youtube.YouTube.Builder(transport, jsonFactory, credential)
                       .setApplicationName(mContext.getString(R.string.google_app_name))
                       .setGoogleClientRequestInitializer(new YouTubeRequestInitializer(CLIENT_ID))
                       .build();

       File mediaFile = new File(mediaPath);  
       YouTube.Videos.Insert requestInsert = prepareUpload(title, body, mediaFile);
       new VideoUploadAsyncTask().execute(requestInsert);
}
 
开发者ID:StoryMaker,项目名称:SecureShareLib,代码行数:33,代码来源:YoutubeSiteController.java


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