YoutubePlayerView ServiceMisssing

时间:2015-11-06 08:06:28

标签: java android android-youtube-api

我的youtubeplayerview有问题。我根据https://developers.google.com/youtube/android/player/register制作了一个简单的测试应用程序。 Basicaly它包含这个“7lCDEYXw3mM”,参考关于谷歌apis的sipmple视频。我在.... / debug.keystore中添加带有sha1的devolper密钥(android)。代码为:

import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

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 MainActivity extends YouTubeBaseActivity implements
YouTubePlayer.OnInitializedListener {

static private final String DEVELOPER_KEY = "AIzaSyBE1SLvAholqLaWxeC4W5SQI2xxp58YjZM";
static private final String VIDEO = "7lCDEYXw3mM";
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    YouTubePlayerView youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);
    youTubeView.initialize(DEVELOPER_KEY, this);


}

@Override
public void onInitializationFailure(Provider provider,
                                    YouTubeInitializationResult error) {
    Toast.makeText(this, "error" + error.toString(), Toast.LENGTH_LONG)
            .show();
}

@Override
public void onInitializationSuccess(Provider provider,
                                    YouTubePlayer player, boolean wasRestored) {

    player.loadVideo(VIDEO);
}

}

我不知道为什么这不起作用(服务缺失)。也许我错过了什么或做错了什么?

0 个答案:

没有答案