com.google.android.youtube.player.YouTubePlayer类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(858)

本文整理了Java中com.google.android.youtube.player.YouTubePlayer类的一些代码示例,展示了YouTubePlayer类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YouTubePlayer类的具体详情如下:
包路径:com.google.android.youtube.player.YouTubePlayer
类名称:YouTubePlayer

YouTubePlayer介绍

暂无

代码示例

代码示例来源:origin: eneim/toro

@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean restored) {
 this.youTubePlayer = player;
 if (this.callback != null) this.callback.onPlayerCreated(this, player);
 player.setPlayerStateChangeListener(this);
 player.setPlaybackEventListener(this);
 player.setManageAudioFocus(true);
 player.setShowFullscreenButton(false);  // fullscreen requires more work ...
 if (shouldPlay()) { // Make sure YouTubePlayerView is playable at this moment.
  player.loadVideo(videoId, (int) this.playbackInfo.getResumePosition());
 }
}

代码示例来源:origin: eneim/toro

void releasePlayer() {
 youTubePlayer.setManageAudioFocus(false);
 youTubePlayer.setOnFullscreenListener(null);
 youTubePlayer.setPlaybackEventListener(null);
 youTubePlayer.setPlayerStateChangeListener(null);
 youTubePlayer.setPlaylistEventListener(null);
 youTubePlayer.release();
}

代码示例来源:origin: eneim/toro

void configPlayer() {
 if (this.youTubePlayer == null) return;
 youTubePlayer.addFullscreenControlFlag(
   YouTubePlayer.FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE);
 youTubePlayer.setPlayerStateChangeListener(new PlayerStateImpl());
 youTubePlayer.setPlaybackEventListener(new PlaybackEventImpl());
 youTubePlayer.setShowFullscreenButton(true);
}

代码示例来源:origin: eneim/toro

@Override public void onInitializationSuccess(YouTubePlayer.Provider provider,
  YouTubePlayer youTubePlayer, boolean b) {
 player = youTubePlayer;
 if (initData != null) {
  player.setShowFullscreenButton(false);
  player.loadVideo(initData.videoId, (int) initData.playbackInfo.getResumePosition());
 }
}

代码示例来源:origin: flipkart-incubator/android-inline-youtube-view

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, final YouTubePlayer player, boolean restored) {
  youTubePlayer = player;
  youTubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
  youTubePlayer.setShowFullscreenButton(true);
  youTubePlayer.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_ORIENTATION);
  youTubePlayer.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CONTROL_SYSTEM_UI);
  youTubePlayer.setPlaybackEventListener(new YouTubePlayer.PlaybackEventListener() {
    @Override
    public void onPlaying() {
  youTubePlayer.setPlayerStateChangeListener(new YouTubePlayer.PlayerStateChangeListener() {
    @Override
    public void onLoading() {
  player.setOnFullscreenListener(new YouTubePlayer.OnFullscreenListener() {
    @Override
    public void onFullscreen(boolean b) {
    youTubePlayer.loadVideo(getVideoId());

代码示例来源:origin: flipkart-incubator/android-inline-youtube-view

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, final YouTubePlayer player, boolean restored) {
  youTubePlayer = player;
  youTubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
  youTubePlayer.setShowFullscreenButton(false);
  youTubePlayer.setPlaybackEventListener(new YouTubePlayer.PlaybackEventListener() {
    @Override
    public void onPlaying() {
  youTubePlayer.setPlayerStateChangeListener(new YouTubePlayer.PlayerStateChangeListener() {
    @Override
    public void onLoading() {
    String videoId = arguments != null ? arguments.getString(ARG_VIDEO_ID) : null;
    if (!TextUtils.isEmpty(videoId)) {
      youTubePlayer.loadVideo(videoId);

代码示例来源:origin: youtube/yt-direct-lite-android

@Override
public void onInitializationSuccess(
    YouTubePlayer.Provider provider,
    YouTubePlayer youTubePlayer, boolean b) {
  youTubePlayer.loadVideo(youtubeId);
  mYouTubePlayer = youTubePlayer;
  youTubePlayer
      .setPlayerStateChangeListener(PlayActivity.this);
  youTubePlayer
      .setOnFullscreenListener(PlayActivity.this);
}

代码示例来源:origin: eneim/toro

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
  boolean restored) {
 youTubePlayer = player;
 configPlayer();
 youTubePlayer.loadVideo("6ZfuNTqbHE8");
}

代码示例来源:origin: anitaa1990/TrailersApp

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
  youTubePlayer.setFullscreen(true);
  youTubePlayer.loadVideo(videoKey); // Plays https://www.youtube.com/watch?v=fhWaJi1Hsfo
}

代码示例来源:origin: msahakyan/nested-recycler-view

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
                  YouTubePlayer player, boolean wasRestored) {
  if (mTrailerPath == null) {
    finish();
  }
  if (!wasRestored) {
    // if you want to play it automatically
    player.loadVideo(mTrailerPath);
    // if you don't want to play it automatically
    // player.cueVideo(Config.YOUTUBE_VIDEO_CODE);
    // Showing player controls
    player.setPlayerStyle(PlayerStyle.DEFAULT);
  }
}

代码示例来源:origin: eneim/toro

void updateResumePosition() {
 if (youTubePlayer != null) {
  playbackInfo.setResumePosition(youTubePlayer.getCurrentTimeMillis());
 }
}

代码示例来源:origin: eneim/toro

@Override public void onFragmentStopped(FragmentManager fm, Fragment f) {
  if (f == fragment && player != null) {
   player.release();
   player = null;
  }
 }
};

代码示例来源:origin: flipkart-incubator/android-inline-youtube-view

private void handleStopEvent() {
  if (listener != null && youTubePlayer != null && (PlayerStateList.PLAYING.equals(playerState)
      || PlayerStateList.BUFFERING.equals(playerState) || PlayerStateList.PAUSED.equals(playerState))) {
    playerState = PlayerStateList.STOPPED;
    listener.onStop((youTubePlayer.getCurrentTimeMillis()), (youTubePlayer.getDurationMillis()));
  }
}

代码示例来源:origin: youtube/yt-direct-lite-android

public boolean popPlayerFromBackStack() {
  if (mIsFullScreen) {
    mYouTubePlayer.setFullscreen(false);
    return false;
  }
  if (getFragmentManager().findFragmentByTag(YOUTUBE_FRAGMENT_TAG) != null) {
    getFragmentManager().popBackStack();
    return false;
  }
  return true;
}

代码示例来源:origin: narenkukreja/Munch-For-Reddit

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
  /** Start buffering **/
  if (!b) {
    youTubePlayer.loadVideo(normalYoutubeUrl);
  }
}

代码示例来源:origin: eneim/toro

InitData getLatestData() {
 if (initData == null) return null;
 if (player != null) {
  try {
   initData.playbackInfo.setResumePosition(player.getCurrentTimeMillis());
  } catch (IllegalStateException er) {
   er.printStackTrace();
  }
 }
 PlaybackInfo info = new PlaybackInfo(initData.playbackInfo);
 return new InitData(initData.adapterOrder, initData.videoId, info, initData.returnOrientation);
}

代码示例来源:origin: flipkart-incubator/android-inline-youtube-view

@MainThread
  public void release() {
    if (youTubePlayer != null) {
      youTubePlayer.release();
      youTubePlayer = null;
    }
  }
}

代码示例来源:origin: flipkart-incubator/android-inline-youtube-view

@Override
public void onBuffering(boolean isBuffering) {
  if (listener != null && youTubePlayer != null) {
    listener.onBuffering((youTubePlayer.getCurrentTimeMillis()), isBuffering);
  }
}

代码示例来源:origin: flipkart-incubator/android-inline-youtube-view

@Override
  public void onDestroy() {
    super.onDestroy();
    if (youTubePlayer != null) {
      youTubePlayer.release();
    }
  }
}

代码示例来源:origin: flipkart-incubator/android-inline-youtube-view

@Override
public void onPlaying() {
  if (listener != null && youTubePlayer != null && !PlayerStateList.PLAYING.equals(playerState)) {
    playerState = PlayerStateList.PLAYING;
    listener.onPlay(youTubePlayer.getCurrentTimeMillis());
  }
}

相关文章