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