1) YoutubeVideoPlay.java
==================
package com.activities;
import android.os.Bundle;
import com.R;
import com.utils.StaticUtils;
import com.utils.YouTubeFailureRecoveryActivity;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayerView;
public class YoutubeVideoPlay extends YouTubeFailureRecoveryActivity implements YouTubePlayer.OnInitializedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_youtube_video_play);
YouTubePlayerView youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);
youTubeView.initialize(StaticUtils.DEVELOPER_KEY, this);
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored) {
if (!wasRestored) {
youTubePlayer.cueVideo(PostDetail.VIDEO_URL);
youTubePlayer.setFullscreen(true);
youTubePlayer.setShowFullscreenButton(false);
}
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
}
@Override
protected YouTubePlayer.Provider getYouTubePlayerProvider() {
return (YouTubePlayerView) findViewById(R.id.youtube_view);
}
}
==================
package com.activities;
import android.os.Bundle;
import com.R;
import com.utils.StaticUtils;
import com.utils.YouTubeFailureRecoveryActivity;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayerView;
public class YoutubeVideoPlay extends YouTubeFailureRecoveryActivity implements YouTubePlayer.OnInitializedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_youtube_video_play);
YouTubePlayerView youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);
youTubeView.initialize(StaticUtils.DEVELOPER_KEY, this);
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored) {
if (!wasRestored) {
youTubePlayer.cueVideo(PostDetail.VIDEO_URL);
youTubePlayer.setFullscreen(true);
youTubePlayer.setShowFullscreenButton(false);
}
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
}
@Override
protected YouTubePlayer.Provider getYouTubePlayerProvider() {
return (YouTubePlayerView) findViewById(R.id.youtube_view);
}
}
2)activity_youtube_video_play.xml
==========================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.youtube.player.YouTubePlayerView
android:id="@+id/youtube_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
3) app=>libs add
YouTubeAndroidPlayerApi.jar
4)Intent i = new Intent(PostDetail.this, YoutubeVideoPlay.class);
startActivity(i);
5) add internet permission
6) public static final String DEVELOPER_KEY = "AIzaSyA4umjr-_ev7AT1IfCnzidGNk2BkDkH898";
5) add internet permission
6) public static final String DEVELOPER_KEY = "AIzaSyA4umjr-_ev7AT1IfCnzidGNk2BkDkH898";
7)refer android hive for more detail
No comments:
Post a Comment