I\'m trying to use Android Youtube API
. Everything works ok excepts that when I extends AppCompatActivity
. The UI of YoutubePlayer looks so bad. I trie
There is a quick work around for this problem as I applied to my app.
Activity:
public class YouTubePlayerActivity extends YouTubeBaseActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_you_tube_player);
YouTubePlayerView playerView = (YouTubePlayerView) findViewById(R.id.youtubePlayerView);
final String videoID = getIntent().getExtras().getString("videoID");
playerView.initialize(YTConfig.DEVELOPER_KEY, new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
youTubePlayer.setFullscreen(true);
youTubePlayer.setShowFullscreenButton(true);
youTubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.MINIMAL);
youTubePlayer.loadVideo(videoID.replace("https://www.youtube.com/watch?v=", ""));
youTubePlayer.setPlayerStateChangeListener(new YouTubePlayer.PlayerStateChangeListener() {
@Override
public void onLoading() {
}
@Override
public void onLoaded(String s) {
}
@Override
public void onAdStarted() {
}
@Override
public void onVideoStarted() {
}
@Override
public void onVideoEnded() {
}
@Override
public void onError(YouTubePlayer.ErrorReason errorReason) {
}
});
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
}
});
}
}