如何使用Firebase的Youtube API播放视频? [英] How to play a video using the Youtube API with Firebase?
问题描述
1.-我将实例设置为firebase
/ p>
mDatabase = FirebaseDatabase.getInstance()。getReference()。child(Videos);
2.然后我将布局链接到代码
$ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $>
mNoticiasSingleImage =(ImageView)findViewById(R.id.imageView);
mNoticiasSingleVid =(YouTubePlayerView)findViewById(R.id.videoView);
<3> - 我在onDataChange(DataSnapshot dataSnapshot)中工作{}
$ p $ $ $ $ $ $ String post_title =(String)dataSnapshot.child(title)。getValue();
String post_image =(String)dataSnapshot.child(image)。getValue();
String post_video =(String)dataSnapshot.child(vid)。getValue();
mNoticiasSingleTitle .setText(post_consejo);
Picasso.with(VideoAct.this).load(post_image).into(mNoticiasSingleImage);
//缺少代码
加载图像我使用picasso,如果我想上传YouTube的视频,我可以做到这一点,请帮助,谢谢。
youTubePlayerView.initialize(YOUR API KEY,
new YouTubePlayer.OnInitializedListener(){
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
YouTubePlayer youTubePlayer,boolean b){
youTubePlayer.loadVideo(VIDEO_ID_HERE);
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider,
YouTubeInitializationResult youTubeInitializationResult){
}
});
To do this:
1.- I make the instance to firebase
mDatabase = FirebaseDatabase.getInstance().getReference().child("Videos");
2.- Then I link the layout to the code
mNoticiasSingleTitle = (TextView)findViewById(R.id.post_titleNoti);
mNoticiasSingleImage = (ImageView) findViewById(R.id.imageView);
mNoticiasSingleVid = (YouTubePlayerView) findViewById(R.id.videoView);
3.- I work in onDataChange(DataSnapshot dataSnapshot){}
String post_title = (String)dataSnapshot.child("title").getValue();
String post_image = (String)dataSnapshot.child("image").getValue();
String post_video = (String)dataSnapshot.child("vid").getValue();
mNoticiasSingleTitle .setText(post_consejo);
Picasso.with(VideoAct.this).load(post_image).into(mNoticiasSingleImage);
//Missing code here
To load the image I use picasso and if I want to upload a video of youtube as I can do it, help please, thanks.
Do this.
youTubePlayerView.initialize("YOUR API KEY",
new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
YouTubePlayer youTubePlayer, boolean b) {
youTubePlayer.loadVideo("VIDEO_ID_HERE");
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider,
YouTubeInitializationResult youTubeInitializationResult) {
}
});
这篇关于如何使用Firebase的Youtube API播放视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!