本文整理匯總了Java中com.google.android.youtube.player.YouTubePlayer類的典型用法代碼示例。如果您正苦於以下問題:Java YouTubePlayer類的具體用法?Java YouTubePlayer怎麽用?Java YouTubePlayer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
YouTubePlayer類屬於com.google.android.youtube.player包,在下文中一共展示了YouTubePlayer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateView
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的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: hidePresentation
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
/**
* Hides the Presentation. Some UI components are also updated:
* the video view is returned to its normal place on the primary display; the YouTube player
* style is updated to the default; and an action item is updated to indicate the external
* display is no longer in use.
*/
private void hidePresentation() {
LOGD(TAG, "Hiding video presentation");
View presentationView = mPresentation.getYouTubeFragmentView();
((ViewGroup) presentationView.getParent()).removeView(presentationView);
mPlayerContainer.addView(presentationView);
mPresentationControls.setVisibility(View.GONE);
updatePresentationMenuItem(false);
mPresentation.dismiss();
mPresentation = null;
if (mYouTubePlayer != null) {
mYouTubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
mYouTubePlayer.play();
setFullscreenFlags(false);
}
}
示例3: onInitializationSuccess
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
YouTubePlayer youTubePlayer, boolean wasRestored) {
if (!wasRestored) {
if (LOG) {
Log.v(TAG, "trailerData " + trailerData);
}
if (trailerData != null && !trailerData.isEmpty()) {
Uri uri = trailerData.get(0).getTrailerUri();
if (LOG) {
Log.v(TAG, "trailerData " + trailerData.size());
}
String trailerCode = uri.getQueryParameter("v");
if (trailerCode != null) {
this.youTubePlayer = youTubePlayer;
youTubePlayer.cueVideo(trailerCode);
}
} else {
getFragmentManager().beginTransaction().remove(youTubePlayerFragment).commit();
}
}
}
示例4: onInitializationSuccess
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player, boolean wasRestored) {
if (!_screenEnabled) {
return;
}
if (!_youTubePlayerIsInitialized) {
_youtubePlayer = player;
_youtubePlayer.setPlayerStateChangeListener(_playerStateChangeListener);
_youtubePlayer.setPlaybackEventListener(_playbackEventListener);
_youTubePlayerIsInitialized = true;
}
if (!wasRestored) {
startVideo(_youtubeId);
}
}
示例5: onStart
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的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();
}
}
示例6: onInitializationSuccess
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored) {
if (!_screenEnabled) {
_logger.Debug("Screen is not enabled!");
return;
}
if (!_youTubePlayerIsInitialized) {
_youtubePlayer = player;
_youtubePlayer.setPlayerStateChangeListener(_playerStateChangeListener);
_youtubePlayer.setPlaybackEventListener(_playbackEventListener);
_youTubePlayerIsInitialized = true;
}
if (!wasRestored) {
startVideo(_youtubeId);
}
}
示例7: onInitializationSuccess
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored) {
if (null == player) return;
mPlayer = player;
displayCurrentTime();
// Start buffering
if (!wasRestored) {
player.cueVideo(VIDEO_ID);
}
player.setPlayerStyle(PlayerStyle.CHROMELESS);
mPlayButtonLayout.setVisibility(View.VISIBLE);
// Add listeners to YouTubePlayer instance
player.setPlayerStateChangeListener(mPlayerStateChangeListener);
player.setPlaybackEventListener(mPlaybackEventListener);
}
示例8: onInitializationSuccess
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
youTubePlayer.setOnFullscreenListener(this);
if (!b) {
videoId = getArguments().getString("video_id");
if(skipToMillis==-1) {
Log.v("LoadingVideo:"," "+videoId);
youTubePlayer.loadVideo(videoId);
}else{
Log.v("CueingVideo:"," "+videoId);
youTubePlayer.cueVideo(videoId,skipToMillis);
Log.v("MillisToSeek:", " " + skipToMillis/1000);
}
this.youTubePlayer = youTubePlayer;
youTubePlayer.setShowFullscreenButton(false);
//youTubePlayer.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI);
}
}
示例9: onInitializationSuccess
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, final YouTubePlayer player, boolean restored) {
LogHelper.logMessage("onInitializationSuccess: " + restored + " videoId: " + videoId);
this.player = player;
player.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI);
player.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CUSTOM_LAYOUT);
player.setOnFullscreenListener(new YouTubePlayer.OnFullscreenListener() {
@Override
public void onFullscreen(boolean fullscreen) {
YoutubeOverlayFragment.this.fullscreen = fullscreen;
}
});
if (!restored && videoId != null) {
player.loadVideo(videoId);
}
}
示例10: onInitializationSuccess
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
this.player = youTubePlayer;
player.setOnFullscreenListener(this);
player.setPlayerStateChangeListener(this);
player.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION
| YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI
| YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE
| YouTubePlayer.FULLSCREEN_FLAG_CUSTOM_LAYOUT);
player.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
if (!b)
player.loadVideo(videoId);
}
示例11: onInitializationSuccess
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored)
{
if (Configuration.ORIENTATION_PORTRAIT == getResources().getConfiguration().orientation) {
this.youTubePlayer = youTubePlayer;
youTubePlayer.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
youTubePlayer.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI);
youTubePlayer.setShowFullscreenButton(false);
youTubePlayer.setOnFullscreenListener(new YouTubePlayer.OnFullscreenListener()
{
@Override
public void onFullscreen(boolean b)
{
isFullscreen = b;
}
});
if (mVideoId != null && !wasRestored) {
youTubePlayer.loadVideo(mVideoId);
}
if (wasRestored) {
youTubePlayer.seekToMillis(millis);
}
}
}
示例12: setupFullscreenListener
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
private void setupFullscreenListener() {
if (mPlayer == null) {
DUtils.log("mPlayer is null inside: " + DUtils.currentMethod());
return;
}
mPlayer.setOnFullscreenListener(new YouTubePlayer.OnFullscreenListener() {
public void onFullscreen(boolean isFullscreen) {
DUtils.log("setOnFullscreenListener: " + (isFullscreen ? "yes" : "no"));
VideoPlayerFragment.this.mFullscreen = isFullscreen;
mFragmentListener.onFullScreen(isFullscreen);
}
});
}
示例13: onCheckedChanged
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int controlFlags = player.getFullscreenControlFlags();
if (isChecked) {
// If you use the FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE, your activity's normal UI
// should never be laid out in landscape mode (since the video will be fullscreen whenever the
// activity is in landscape orientation). Therefore you should set the activity's requested
// orientation to portrait. Typically you would do this in your AndroidManifest.xml, we do it
// programmatically here since this activity demos fullscreen behavior both with and without
// this flag).
setRequestedOrientation(PORTRAIT_ORIENTATION);
controlFlags |= YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE;
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
controlFlags &= ~YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE;
}
player.setFullscreenControlFlags(controlFlags);
}
示例14: onError
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onError(YouTubePlayer.ErrorReason errorReason) {
Log.e(LOG_TAG, "player error: " + errorReason);
if (highlightImageView.getVisibility()==View.VISIBLE) {
highlightImageView.startAnimation(fadeOutSlow);
}
currentVideoId = null;
if (errorReason == YouTubePlayer.ErrorReason.UNEXPECTED_SERVICE_DISCONNECTION) {
// player has encountered an unrecoverable error - stop the demo
flipDelayHandler.removeCallbacksAndMessages(null);
state = State.UNINITIALIZED;
thumbnailLoader.release();
thumbnailLoader = null;
player = null;
} else {
state = State.VIDEO_ENDED;
}
}
示例15: onInitializationSuccess
import com.google.android.youtube.player.YouTubePlayer; //導入依賴的package包/類
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored) {
player = youTubePlayer;
youTubePlayer.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
youTubePlayer.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI);
youTubePlayer.setOnFullscreenListener(b -> isFullScreen = b);
if (videoId != null && !wasRestored) {
youTubePlayer.loadVideo(videoId);
}
if (wasRestored) {
youTubePlayer.seekToMillis(videoTime);
}
}