当前位置: 首页>>代码示例>>Java>>正文


Java YouTubePlayer类代码示例

本文整理汇总了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;
}
 
开发者ID:ur13l,项目名称:Guanajoven,代码行数:24,代码来源:AyudaFragment.java

示例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);
    }
}
 
开发者ID:TheDeltaProgram,项目名称:iosched2013,代码行数:22,代码来源:SessionLivestreamActivity.java

示例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();
        }
    }
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:24,代码来源:TVShowActivity.java

示例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);
    }
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:20,代码来源:CenterViewController.java

示例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();
    }
}
 
开发者ID:wax911,项目名称:anitrend-app,代码行数:26,代码来源:YoutubeFragment.java

示例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);
    }
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-MediaServer,代码行数:21,代码来源:CenterViewController.java

示例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);
}
 
开发者ID:StackTipsLab,项目名称:YouTubePlayerView-Example,代码行数:20,代码来源:CustomPlayerControlActivity.java

示例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);
    }
}
 
开发者ID:muddassir235,项目名称:Pop-Movies-Android-App,代码行数:20,代码来源:YoutubeTrailerFragment.java

示例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);
    }
}
 
开发者ID:jszczygiel,项目名称:AndroidYoutubeOverlay,代码行数:18,代码来源:YoutubeOverlayFragment.java

示例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);

}
 
开发者ID:slartus,项目名称:4pdaClient-plus,代码行数:17,代码来源:YoutubeActivity.java

示例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);
        }
    }
}
 
开发者ID:mcruncher,项目名称:worshipsongs-android,代码行数:25,代码来源:CustomYoutubeBoxActivity.java

示例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);
    }

  });
}
 
开发者ID:sgehrman,项目名称:UTubeTV,代码行数:17,代码来源:VideoPlayerFragment.java

示例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);
}
 
开发者ID:youtube,项目名称:yt-android-player,代码行数:19,代码来源:FullscreenDemoActivity.java

示例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;
	}
}
 
开发者ID:entertailion,项目名称:Video-Wall,代码行数:19,代码来源:VideoWallActivity.java

示例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);
    }
}
 
开发者ID:prakh25,项目名称:MovieApp,代码行数:16,代码来源:TrailerActivity.java


注:本文中的com.google.android.youtube.player.YouTubePlayer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。