com.google.android.youtube.player.YouTubeIntents Java Examples

The following examples show how to use com.google.android.youtube.player.YouTubeIntents. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntentsDemoActivity.java    From yt-android-player with Apache License 2.0 6 votes vote down vote up
public boolean isIntentTypeEnabled(IntentType type) {
  switch (type) {
    case PLAY_VIDEO:
      return YouTubeIntents.canResolvePlayVideoIntent(this);
    case OPEN_PLAYLIST:
      return YouTubeIntents.canResolveOpenPlaylistIntent(this);
    case PLAY_PLAYLIST:
      return YouTubeIntents.canResolvePlayPlaylistIntent(this);
    case OPEN_SEARCH:
      return YouTubeIntents.canResolveSearchIntent(this);
    case OPEN_USER:
      return YouTubeIntents.canResolveUserIntent(this);
    case UPLOAD_VIDEO:
      return YouTubeIntents.canResolveUploadIntent(this);
  }

  return false;
}
 
Example #2
Source File: IntentsDemoActivity.java    From yt-android-player with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.intents_demo);

  intentItems = new ArrayList<DemoListViewItem>();
  intentItems.add(new IntentItem("Play Video", IntentType.PLAY_VIDEO));
  intentItems.add(new IntentItem("Open Playlist", IntentType.OPEN_PLAYLIST));
  intentItems.add(new IntentItem("Play Playlist", IntentType.PLAY_PLAYLIST));
  intentItems.add(new IntentItem("Open User", IntentType.OPEN_USER));
  intentItems.add(new IntentItem("Open Search Results", IntentType.OPEN_SEARCH));
  intentItems.add(new IntentItem("Upload Video", IntentType.UPLOAD_VIDEO));

  ListView listView = (ListView) findViewById(R.id.intent_list);
  DemoArrayAdapter adapter =
      new DemoArrayAdapter(this, R.layout.list_item, intentItems);
  listView.setAdapter(adapter);
  listView.setOnItemClickListener(this);

  TextView youTubeVersionText = (TextView) findViewById(R.id.youtube_version_text);
  String version = YouTubeIntents.getInstalledYouTubeVersionName(this);
  if (version != null) {
    String text = String.format(getString(R.string.youtube_currently_installed), version);
    youTubeVersionText.setText(text);
  } else {
    youTubeVersionText.setText(getString(R.string.youtube_not_installed));
  }
}
 
Example #3
Source File: IntentsDemoActivity.java    From yt-android-player with Apache License 2.0 5 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  IntentItem clickedIntentItem = (IntentItem) intentItems.get(position);

  Intent intent;
  switch (clickedIntentItem.type) {
    case PLAY_VIDEO:
      intent = YouTubeIntents.createPlayVideoIntentWithOptions(this, VIDEO_ID, true, false);
      startActivity(intent);
      break;
    case OPEN_PLAYLIST:
      intent = YouTubeIntents.createOpenPlaylistIntent(this, PLAYLIST_ID);
      startActivity(intent);
      break;
    case PLAY_PLAYLIST:
      intent = YouTubeIntents.createPlayPlaylistIntent(this, PLAYLIST_ID);
      startActivity(intent);
      break;
    case OPEN_SEARCH:
      intent = YouTubeIntents.createSearchIntent(this, USER_ID);
      startActivity(intent);
      break;
    case OPEN_USER:
      intent = YouTubeIntents.createUserIntent(this, USER_ID);
      startActivity(intent);
      break;
    case UPLOAD_VIDEO:
      // This will load a picker view in the users' gallery.
      // The upload activity is started in the function onActivityResult.
      intent = new Intent(Intent.ACTION_PICK, null).setType("video/*");
      intent.putExtra(EXTRA_LOCAL_ONLY, true);
      startActivityForResult(intent, SELECT_VIDEO_REQUEST);
      break;
  }
}
 
Example #4
Source File: IntentsDemoActivity.java    From yt-android-player with Apache License 2.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent returnedIntent) {
  if (resultCode == RESULT_OK) {
    switch (requestCode) {
      case SELECT_VIDEO_REQUEST:
        Intent intent = YouTubeIntents.createUploadIntent(this, returnedIntent.getData());
        startActivity(intent);
        break;
    }
  }
  super.onActivityResult(requestCode, resultCode, returnedIntent);
}
 
Example #5
Source File: YouTubeAPI.java    From UTubeTV with The Unlicense 4 votes vote down vote up
public static void playMovieUsingIntent(Context context, String videoId) {
  Intent intent = YouTubeIntents.createPlayVideoIntent(context, videoId);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  // need this to start activity if we just have a plain context (not an Activity)
  context.startActivity(intent);
}
 
Example #6
Source File: YouTubeAPI.java    From UTubeTV with The Unlicense 4 votes vote down vote up
public static void openPlaylistUsingIntent(Activity activity, String playlistId) {
  Intent intent = YouTubeIntents.createOpenPlaylistIntent(activity, playlistId);
  activity.startActivity(intent);
}
 
Example #7
Source File: ServiceUtil.java    From android-inline-youtube-view with Apache License 2.0 2 votes vote down vote up
/**
 * Check if youtube service is available
 *
 * @param context {@link Context}
 * @return true if present, else false
 */
public static boolean isYouTubeServiceAvailable(Context context) {
    return YouTubeIntents.isYouTubeInstalled(context) ||
            YouTubeApiServiceUtil.isYouTubeApiServiceAvailable(context) == YouTubeInitializationResult.SUCCESS;
}