本文整理汇总了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);
}
}