com.google.android.youtube.player.YouTubeStandalonePlayer Java Examples
The following examples show how to use
com.google.android.youtube.player.YouTubeStandalonePlayer.
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: YouTubeStandaloneModule.java From react-native-youtube with MIT License | 6 votes |
@Override public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent intent) { if (requestCode == REQ_START_STANDALONE_PLAYER) { if (mPickerPromise != null) { if (resultCode != Activity.RESULT_OK) { YouTubeInitializationResult errorReason = YouTubeStandalonePlayer.getReturnedInitializationResult(intent); if (errorReason.isUserRecoverableError()) { errorReason.getErrorDialog(activity, requestCode).show(); mPickerPromise.reject(E_PLAYER_ERROR); } else { String errorMessage = String.format("There was an error initializing the YouTubePlayer (%1$s)", errorReason.toString()); mPickerPromise.reject(E_PLAYER_ERROR, errorMessage); } } else { mPickerPromise.resolve(null); } mPickerPromise = null; } } }
Example #2
Source File: YouTubeStandaloneModule.java From react-native-youtube with MIT License | 6 votes |
@ReactMethod public void playVideos(final String apiKey, final ReadableArray videoIds, final boolean autoplay, final boolean lightboxMode, final int startIndex, final int startTimeMillis, final Promise promise) { Activity currentActivity = getCurrentActivity(); if (currentActivity == null) { promise.reject(E_ACTIVITY_DOES_NOT_EXIST, "Activity doesn't exist"); return; } final List<String> videoIdsList = new ArrayList<String>(); for (int i = 0; i < videoIds.size(); i++) { videoIdsList.add(videoIds.getString(i)); } final Intent intent = YouTubeStandalonePlayer.createVideosIntent( currentActivity, apiKey, videoIdsList, startIndex, startTimeMillis, autoplay, lightboxMode); play(intent, promise); }
Example #3
Source File: YoutubePlayerDialog.java From Android-SDK with MIT License | 6 votes |
@Override public void onInitializationSuccess( YouTubeThumbnailView view, YouTubeThumbnailLoader loader) { loader.setOnThumbnailLoadedListener(this); loader.setVideo(VIDEO_ID); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = YouTubeStandalonePlayer.createVideoIntent(getActivity(), API_KEY, VIDEO_ID); startActivity(intent); dismiss(); } }); }
Example #4
Source File: DrawerActivity.java From UTubeTV with The Unlicense | 6 votes |
@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); } }
Example #5
Source File: YouTubeStandaloneModule.java From react-native-youtube with MIT License | 5 votes |
@ReactMethod public void playVideo(final String apiKey, final String videoId, final boolean autoplay, final boolean lightboxMode, final int startTimeMillis, final Promise promise) { Activity currentActivity = getCurrentActivity(); if (currentActivity == null) { promise.reject(E_ACTIVITY_DOES_NOT_EXIST, "Activity doesn't exist"); return; } final Intent intent = YouTubeStandalonePlayer.createVideoIntent( currentActivity, apiKey, videoId, startTimeMillis, autoplay, lightboxMode); play(intent, promise); }
Example #6
Source File: YouTubeStandaloneModule.java From react-native-youtube with MIT License | 5 votes |
@ReactMethod public void playPlaylist(final String apiKey, final String playlistId, final boolean autoplay, final boolean lightboxMode, final int startIndex, final int startTimeMillis, final Promise promise) { Activity currentActivity = getCurrentActivity(); if (currentActivity == null) { promise.reject(E_ACTIVITY_DOES_NOT_EXIST, "Activity doesn't exist"); return; } final Intent intent = YouTubeStandalonePlayer.createPlaylistIntent( currentActivity, apiKey, playlistId, startIndex, startTimeMillis, autoplay, lightboxMode); play(intent, promise); }
Example #7
Source File: StandalonePlayerDemoActivity.java From yt-android-player with Apache License 2.0 | 5 votes |
@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); } 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(); } } }
Example #8
Source File: StandalonePlayerDemoActivity.java From yt-android-player with Apache License 2.0 | 5 votes |
@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(); } } }
Example #9
Source File: YouTubeAPI.java From UTubeTV with The Unlicense | 4 votes |
public static void playMovie(Activity activity, String movieID, boolean fullScreen) { Intent intent = YouTubeStandalonePlayer.createVideoIntent(activity, Auth.devKey(), movieID, 0, true, !fullScreen); activity.startActivityForResult(intent, REQ_PLAYER_CODE); }