YouTube的GDATA APIU不再可用,这方面的任何替代方案?

问题描述 投票:-1回答:1

YouTube的饲料GDATA API不工作,从去年有些日子..所以任何替代获得来自YouTube API进..?

http://gdata.youtube.com/feeds/api/playlists/PL_yIBWagYVjyyqx_qPkbat5zufWZOyZEZ

android youtube youtube-api gdata android-youtube-api
1个回答
0
投票
  1. 下载YouTubePlyaer API https://developers.google.com/youtube/android/player/downloads/
  2. 注册您对谷歌开发者控制台https://console.developers.google.com应用
  3. 以一个独特的API密钥和使用,在您的应用程序。
  4. 使用下面的代码 公共类公司简介扩展YouTubeBaseActivity实现YouTubePlayer.OnInitializedListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_about_us); YouTubePlayerView youTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtube_player); youTubePlayerView.initialize(Constants.YOUTUBE_API_KEY, this); initViews(); } private void initViews() { Button btnVisitMega = (Button) findViewById(R.id.btn_visit_megaforties); Button btnVisitSecurity = (Button) findViewById(R.id.btn_visit_security_seals); btnVisitMega.setOnClickListener(this); btnVisitSecurity.setOnClickListener(this); } @Override public void onInitializationFailure(Provider arg0, YouTubeInitializationResult arg1) { Toast.makeText(this, "Failured to Initialize!", Toast.LENGTH_LONG).show(); } @Override public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored) { /** add listeners to YouTubePlayer instance **/ player.setPlayerStateChangeListener(playerStateChangeListener); player.setPlaybackEventListener(playbackEventListener); /** Start buffering **/ if (!wasRestored) { player.cueVideo(Constants.YOUTUBE_VIDEO_ID); } } private PlaybackEventListener playbackEventListener = new PlaybackEventListener() { @Override public void onBuffering(boolean arg0) { } @Override public void onPaused() { } @Override public void onPlaying() { } @Override public void onSeekTo(int arg0) { } @Override public void onStopped() { } }; private PlayerStateChangeListener playerStateChangeListener = new PlayerStateChangeListener() { @Override public void onAdStarted() { } @Override public void onError(ErrorReason arg0) { } @Override public void onLoaded(String arg0) { } @Override public void onLoading() { } @Override public void onVideoEnded() { } @Override public void onVideoStarted() { } };
© www.soinside.com 2019 - 2024. All rights reserved.