當前位置: 首頁>>代碼示例>>Java>>正文


Java YouTubeInitializationResult類代碼示例

本文整理匯總了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;
}
 
開發者ID:ur13l,項目名稱:Guanajoven,代碼行數:24,代碼來源:AyudaFragment.java

示例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();
    }
}
 
開發者ID:wax911,項目名稱:anitrend-app,代碼行數:26,代碼來源:YoutubeFragment.java

示例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);
    		}
 }    
}
 
開發者ID:ajindal2,項目名稱:Youtubemysongs,代碼行數:21,代碼來源:MainActivity.java

示例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);
  }
}
 
開發者ID:sgehrman,項目名稱:UTubeTV,代碼行數:21,代碼來源:DrawerActivity.java

示例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();
    }
}
 
開發者ID:rishabh115,項目名稱:Odyssey2017,代碼行數:12,代碼來源:YoutubeActivity.java

示例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();
        }
    }
}
 
開發者ID:tgbMedia,項目名稱:Android-app,代碼行數:16,代碼來源:OverviewActivity.java

示例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();
    }
}
 
開發者ID:DameMatiku,項目名稱:damematiku-android,代碼行數:11,代碼來源:YouTubeFailureRecoveryActivity.java

示例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();
    }
}
 
開發者ID:rahulmaddineni,項目名稱:Stayfit,代碼行數:10,代碼來源:Fragment2.java

示例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)));
    }
}
 
開發者ID:mrprona92,項目名稱:SecretBrand,代碼行數:11,代碼來源:OnYoutubeClickListener.java

示例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();
    }
}
 
開發者ID:silicon-mountain,項目名稱:smconf-android,代碼行數:30,代碼來源:YouTubeUtils.java

示例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();
    }
}
 
開發者ID:applicaster,項目名稱:rn-youtube-android,代碼行數:10,代碼來源:YoutubePlayerActivity.java

示例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();
    }
}
 
開發者ID:SEA2015-GROUP7,項目名稱:projectTetViet,代碼行數:13,代碼來源:YouTubePlayerActivity.java

示例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();
    }
}
 
開發者ID:muddassir235,項目名稱:Pop-Movies-Android-App,代碼行數:9,代碼來源:YoutubeFailureRecoveryFragment.java

示例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();
        }
    }
}
 
開發者ID:ganesh2shiv,項目名稱:yt-channel-list-android,代碼行數:11,代碼來源:YoutubePlayerFragment.java

示例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();
    }
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:31,代碼來源:StandalonePlayerDemoActivity.java


注:本文中的com.google.android.youtube.player.YouTubeInitializationResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。