Android Youtube Player Api - ERROR_CONNECTING_TO_SERVICE [英] Android Youtube Player Api - ERROR_CONNECTING_TO_SERVICE

查看:11
本文介绍了Android Youtube Player Api - ERROR_CONNECTING_TO_SERVICE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用新的 api youtube.我按照提供的示例进行操作,但出现错误:ERROR_CONNECTING_TO_SERVICE

I'm trying to use the new api youtube. I followed the examples provided, but I get the error: ERROR_CONNECTING_TO_SERVICE

我使用的API 密钥"是正确的(因为它在 google 演示中可以正常工作).

The "API key" that I'm using is correct (since it works correctly in the google demos).

进口:

import com.google.android.youtube.player.YouTubeBaseActivity;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayer.Provider;
import com.google.android.youtube.player.YouTubePlayerView;

类定义:

public class Track extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {

     private YouTubePlayerView ytpv;
     private YouTubePlayer ytp;

     public void onCreate(Bundle savedInstanceState) {
          ...

          ytpv = (YouTubePlayerView) findViewById(R.id.youtube_view);
          ytpv.initialize("my_api_key_correctly_created", this); 
     }

     public void onInitializationFailure(Provider arg0, YouTubeInitializationResult arg1) {
          Toast.makeText(this, "Initialization Fail" + arg1.toString(), Toast.LENGTH_LONG).show();
     }


     public void onInitializationSuccess(Provider arg0, YouTubePlayer arg1, boolean arg2) {
          ytp = arg1;
          Toast.makeText(this, "Initialization  Success", Toast.LENGTH_LONG).show();

          if(ytp !=null)
          {
               ytp.loadVideo("ZvvgDC_MNqI");
          }
     }
}

我做错了什么?谢谢,对不起我的英语:)

What am I doing wrong? Thank you, and sorry my english:)

推荐答案

您是否尝试将跟踪"活动作为 TabHost 内的 ActivityGroup/TabActivity 的一部分启动?如果是这样,很遗憾 YouTubePlayerView 或 YouTubePlayerFragment 无法在 ActivityGroup 中初始化.由于 ActivityGroup 现在已弃用,我能给出的唯一建议是改用 Fragments.

Are you trying to start the 'Track' Activity as part of an ActivityGroup/TabActivity inside a TabHost? If so, unfortunately the YouTubePlayerView or YouTubePlayerFragment can't be initialized inside an ActivityGroup. Since the ActivityGroup is now deprecated, the only suggestion I can give is to use Fragments instead.

这篇关于Android Youtube Player Api - ERROR_CONNECTING_TO_SERVICE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆