1

我一直在做一个在我的项目中使用 YouTube API 的应用程序。我有代表 3 个选项卡的选项卡。第一个频道标签,第二个热门视频,最后是最喜欢的视频。我想使用独立的 YouTube,但不知何故它无法显示每个标签的视频。所以,我首先测试顶部选项卡中的代码,它给出了这个错误“ERROR_CONNECTING_TO_SERVICE”。请帮我。谢谢 :)

/import android.app.Activity;
import android.os.Bundle;

import org.brickred.socialshare.YouTubeFailureRecoveryActivity;
//import com.google.android.youtube.player.YouTubeBaseActivity;
import com.google.android.youtube.player.YouTubePlayer;
//import com.google.android.youtube.player.YouTubePlayerFragment;
import com.google.android.youtube.player.YouTubePlayerView;
import com.google.android.youtube.player.YouTubeInitializationResult;


public class Top extends YouTubeFailureRecoveryActivity {

        public static final String PLAYLIST_ID = "PLC7961A4662BB1042";
        /** Called when the activity is first created. */

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            setContentView(R.layout.top);

            YouTubePlayerView youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);
            youTubeView.initialize(DeveloperKey.DEV_KEY, this);
        }

        @Override
        public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
            boolean wasRestored) {
          if (!wasRestored) {
            player.loadPlaylist(PLAYLIST_ID);
          }
        }

        @Override
        protected YouTubePlayer.Provider getYouTubePlayerProvider() {
          return (YouTubePlayerView) findViewById(R.id.youtube_view);
        }
}
4

0 回答 0