0

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.

KENdi
  • 7,576
  • 2
  • 16
  • 31
Charlie
  • 349
  • 4
  • 8
  • This code works perfectly when loading the text and the image but I do not know how to put a youtube video – Charlie Jul 05 '17 at 05:10
  • man use simple youtube api to get videos from youtube you don't need store video, images,title in firebase – Hamza Jul 05 '17 at 10:42

1 Answers1

1

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) {

                }
    });
Dishonered
  • 8,449
  • 9
  • 37
  • 50
  • @Charlie if it works sir, can you please share the code in answer that how to implement it completely and also it is a good practice to answer your own question in stack Overflow – Rohit B Aug 09 '17 at 08:07
  • Hello friend, well work this in a part of my project, I just upload to bitbucket, here the link: [PROJECT HERE](https://bitbucket.org/ChavezHinostroza/vocessapp/src/294216f3ea8963ede6a0a6a396108c61633a3f70/app/src/main/java/com/example/carlos/appproyectos/Videos/VideoSingleActivity.java?at=master&fileviewer=file-view-default) Do not forget that you must configure the Youtube API in your project – Charlie Aug 13 '17 at 17:10