本文整理汇总了Java中com.google.android.youtube.player.YouTubeInitializationResult类的典型用法代码示例。如果您正苦于以下问题:Java YouTubeInitializationResult类的具体用法?Java YouTubeInitializationResult怎么用?Java YouTubeInitializationResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
YouTubeInitializationResult类属于com.google.android.youtube.player包,在下文中一共展示了YouTubeInitializationResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View v = inflater.inflate(R.layout.fragment_ayuda, container, false);
videoView = (YouTubePlayerFragment) getActivity().getFragmentManager().findFragmentById(R.id.fragment_youtube);
listener = new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
youTubePlayer.loadVideo(getString(R.string.fragment_ayuda_link_video));
youTubePlayer.setShowFullscreenButton(false);
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
}
};
videoView.initialize(getString(R.string.fragment_ayuda_youtubekey), listener);
return v;
}
示例2: onStart
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
public void onStart() {
try {
super.onStart();
initializedListener = new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult result) {
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player, boolean wasRestored) {
if (!wasRestored && stream_link != null) {
player_reference = player;
player_reference.cueVideo(stream_link);
} else if (wasRestored) {
player.seekToMillis(play_position);
}
}
};
init();
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: onPostExecute
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
protected void onPostExecute(String result)
{
if (progressDialog != null)
progressDialog.dismiss();
super.onPostExecute(result);
if (result == null)
Toast.makeText(myself, "Sorry! No video found :(", Toast.LENGTH_SHORT).show();
else {
Intent intent = YouTubeStandalonePlayer.createVideoIntent(
myself , DeveloperKey.DEVELOPER_KEY, result,0, true, false);
if (intent == null || !canResolveIntent(intent))
YouTubeInitializationResult.SERVICE_MISSING.getErrorDialog(myself, 2).show();
else {
startTime = System.currentTimeMillis();
logger.videoStarted(result, querySong, getDuration(), selectedIndex);
startActivity(intent);
}
}
}
示例4: onActivityResult
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
// called when playing a movie, could fail and this dialog shows the user how to fix it
case YouTubeAPI.REQ_PLAYER_CODE:
if (resultCode != RESULT_OK) {
YouTubeInitializationResult errorReason = YouTubeStandalonePlayer.getReturnedInitializationResult(data);
if (errorReason.isUserRecoverableError()) {
errorReason.getErrorDialog(this, 0).show();
} else {
String errorMessage = String.format("PLAYER ERROR!! - %s", errorReason.toString());
Utils.toast(this, errorMessage);
}
}
break;
default:
super.onActivityResult(requestCode, resultCode, data);
}
}
示例5: onInitializationFailure
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
if (youTubeInitializationResult.isUserRecoverableError()) {
LogSaver.appendLog(TAG+" :"+youTubeInitializationResult.toString());
youTubeInitializationResult.getErrorDialog(this, RECOVERY_DIALOG_REQUEST).show();
} else {
String errorMessage = String.format(
getString(R.string.error_player), youTubeInitializationResult.toString());
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
}
}
示例6: onActivityResult
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQ_START_STANDALONE_PLAYER && resultCode != RESULT_OK) {
YouTubeInitializationResult errorReason =
YouTubeStandalonePlayer.getReturnedInitializationResult(data);
if (errorReason.isUserRecoverableError()) {
errorReason.getErrorDialog(this, 0).show();
} else {
String errorMessage =
String.format(getString(R.string.error_player), errorReason.toString());
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
}
}
}
示例7: onInitializationFailure
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider,
YouTubeInitializationResult errorReason) {
if (errorReason.isUserRecoverableError()) {
errorReason.getErrorDialog(this, RECOVERY_DIALOG_REQUEST).show();
} else {
String errorMessage = String.format(getString(R.string.error_player), errorReason.toString());
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
}
}
示例8: onInitializationFailure
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
if (youTubeInitializationResult.isUserRecoverableError()) {
youTubeInitializationResult.getErrorDialog(getActivity(), RECOVERY_DIALOG_REQUEST).show();
} else {
//Handle the failure
Toast.makeText(getActivity(), "onInitializationFailure", Toast.LENGTH_LONG).show();
}
}
示例9: onClick
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
public void onClick(View v) {
Context context = v.getContext();
if (YouTubeApiServiceUtil.isYouTubeApiServiceAvailable(context).equals(YouTubeInitializationResult.SUCCESS)) {
Intent intent = YouTubeIntents.createPlayVideoIntentWithOptions(context, mYoutubeUrl, false, false);
context.startActivity(intent);
} else {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + mYoutubeUrl)));
}
}
示例10: showYouTubeVideo
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
public static void showYouTubeVideo(String videoId, Activity activity) {
if (!TextUtils.isEmpty(videoId)) {
Intent liveIntent;
if (YouTubeIntents.isYouTubeInstalled(activity) && YouTubeApiServiceUtil
.isYouTubeApiServiceAvailable(activity)
== YouTubeInitializationResult.SUCCESS) {
// YouTube service is available.
LOGW(TAG, "YouTube service available.");
// start the YouTube player
liveIntent = YouTubeStandalonePlayer.createVideoIntent(activity,
com.google.samples.apps.iosched.BuildConfig.YOUTUBE_API_KEY, videoId);
} else if (YouTubeIntents.canResolvePlayVideoIntent(activity)) {
// The YouTube app may not be fully up-to-date but it is installed and can resolve
// intents.
LOGW(TAG, "YouTube can resolve the intent.");
// Start an intent to the YouTube app
liveIntent = YouTubeIntents.createPlayVideoIntent(activity, videoId);
} else {
// YouTube may not be installed or it may be disabled.
LOGW(TAG, "Redirecting to a browser.");
liveIntent = new Intent(Intent.ACTION_VIEW);
liveIntent.setData(Uri.parse("https://www.youtube.com/watch?v=" + videoId));
}
activity.startActivity(liveIntent);
} else {
Toast.makeText(activity, R.string.explore_io_video_id_not_valid,
Toast.LENGTH_LONG).show();
}
}
示例11: onInitializationFailure
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult errorReason) {
if (errorReason.isUserRecoverableError()) {
errorReason.getErrorDialog(this, RECOVERY_REQUEST).show();
} else {
String error = String.format("player error!", errorReason.toString());
Toast.makeText(this, error, Toast.LENGTH_LONG).show();
}
}
示例12: onInitializationFailure
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider,
YouTubeInitializationResult errorReason) {
if (errorReason.isUserRecoverableError()) {
errorReason.getErrorDialog(this, RECOVERY_DIALOG_REQUEST).show();
} else {
String errorMessage = String.format(
"There was an error initializing the YouTubePlayer (%1$s)",
errorReason.toString());
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
}
}
示例13: onInitializationFailure
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
if (youTubeInitializationResult.isUserRecoverableError()) {
youTubeInitializationResult.getErrorDialog(getActivity(), RECOVERY_DIALOG_REQUEST).show();
} else {
Toast.makeText(getActivity(), "The Youtube Player could'nt be initialized", Toast.LENGTH_LONG).show();
}
}
示例14: onInitializationFailure
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
if (youTubeInitializationResult.isUserRecoverableError()) {
youTubeInitializationResult.getErrorDialog(getActivity(), RECOVERY_DIALOG_REQUEST).show();
} else {
if (isAdded()) {
Toast.makeText(getActivity().getApplicationContext(), getString(R.string.error_init_failure_msg), Toast.LENGTH_SHORT).show();
}
}
}
示例15: onClick
import com.google.android.youtube.player.YouTubeInitializationResult; //导入依赖的package包/类
@Override
public void onClick(View v) {
int startIndex = parseInt(startIndexEditText.getText().toString(), 0);
int startTimeMillis = parseInt(startTimeEditText.getText().toString(), 0) * 1000;
boolean autoplay = autoplayCheckBox.isChecked();
boolean lightboxMode = lightboxModeCheckBox.isChecked();
Intent intent = null;
if (v == playVideoButton) {
intent = YouTubeStandalonePlayer.createVideoIntent(
this, DeveloperKey.DEVELOPER_KEY, VIDEO_ID, startTimeMillis, autoplay, lightboxMode);
} else if (v == playPlaylistButton) {
intent = YouTubeStandalonePlayer.createPlaylistIntent(this, DeveloperKey.DEVELOPER_KEY,
PLAYLIST_ID, startIndex, startTimeMillis, autoplay, lightboxMode);
} else if (v == playVideoListButton) {
intent = YouTubeStandalonePlayer.createVideosIntent(this, DeveloperKey.DEVELOPER_KEY,
VIDEO_IDS, startIndex, startTimeMillis, autoplay, lightboxMode);
}
if (intent != null) {
if (canResolveIntent(intent)) {
startActivityForResult(intent, REQ_START_STANDALONE_PLAYER);
} else {
// Could not resolve the intent - must need to install or update the YouTube API service.
YouTubeInitializationResult.SERVICE_MISSING
.getErrorDialog(this, REQ_RESOLVE_SERVICE_MISSING).show();
}
}
}