I am trying to play video only in full screen mode using Youtube Intents
What i am trying to do is i have a TubePlayerView in Xml As the code below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.google.android.youtube.player.YouTubePlayerView
android:id="@+id/videoView1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="2dp"
android:paddingTop="5dp" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
The youtubeplayer view with id videoView ,when i click on it i want to play video on new intent Using youtube intent as code follows.
But the problem is event after implementing onClick on it the Intent is not called
public class CallingIntent extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {
public static final String develop_you_key = " i have my key";
YouTubePlayerView youTubeView;
TextView ID,Video_id,Video_name,duration,countView,published;
String ID1,Video_id1,Video_name1,duration1,countView1,published1;
private static final int RECOVERY_DIALOG_REQUEST = 1;
YouTubePlayer youTubePlayer;
MediaPlayer mPlayer;
Intent receInt;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.vid_play);
Intent in = getIntent();
// String st= in.getStringExtra("image");
ID1=in.getStringExtra("ID");
Video_id1=in.getStringExtra("video_id");
Video_name1=in.getStringExtra("video_name");
ID =(TextView) findViewById(R.id.textView1);
Video_id =(TextView) findViewById(R.id.textView2);
Video_name=(TextView)findViewById(R.id.textView3);
ID.setText(ID1);
Video_id.setText(Video_id1);
Video_name.setText(Video_name1);
youTubeView= (YouTubePlayerView) findViewById(R.id.videoView1);
youTubeView.initialize(develop_you_key,(YouTubePlayer.OnInitializedListener)this);
findViewById(R.id.videoView1).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = YouTubeIntents.createPlayVideoIntentWithOptions(getApplicationContext(), Video_id1, true, false);
startActivity(intent);
finish();
}
});;
mPlayer = new MediaPlayer();
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider player,
YouTubeInitializationResult errorReason) {
// TODO Auto-generated method stub
String errorMessage = errorReason.toString();
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
boolean wasRestored) {
// TODO Auto-generated method stub
if(!wasRestored)player.cueVideo(Video_id1);
}
}
please observe the onclickListener and tell me on Intialization success how can i play video directly Using Youtube intent "YouTubeIntents.createPlayVideoIntentWithOptions"
The thing is that i want to load video don't want to have thumbnail image instead of VideoView .
Aucun commentaire:
Enregistrer un commentaire