本文整理汇总了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);
}