Android Youtube Player Api - ERROR_CONNECTING_TO_SERVICE(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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android Youtube Player Api - ERROR_CONNECTING_TO_SERVICE
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
- GPS状态的广播接收器? 2022-01-01
- URL编码Swift iOS 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- UITextView 内容插图 2022-01-01
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01