1

How would one go about getting a current Youtube Live Stream video ID for youTubePlayer.LoadVideo to run correctly?

 youTubePlayer.loadVideo("8XiqrERZo_8");

I want to be able to to receive a Youtubers Live Stream ID without having to hard code in the current video ID every time. If another way is easier to implement I'm happy to any suggestions!

Here is what I have currently in my MainActivity file:

public class MainActivity extends YouTubeBaseActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    YouTubePlayerView youTubePlayerView;
    YouTubePlayer.OnInitializedListener onInitializedListener;

    String KEY = "{GOOGLE_API_KEY}";

    youTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtubePlayer);

    onInitializedListener = new YouTubePlayer.OnInitializedListener() {
    @Override
    public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
        youTubePlayer.loadVideo("8XiqrERZo_8");
    }

    @Override
    public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {

    }
    };

     youTubePlayerView.initialize(KEY,onInitializedListener);



}
}

And in my xml class all I'm using is:

    <com.google.android.youtube.player.YouTubePlayerView
         android:id="@+id/youtubePlayer"
         android:layout_width="match_parent"
         android:layout_height="match_parent">

    </com.google.android.youtube.player.YouTubePlayerView>
Jolopy
  • 82
  • 2
  • 11
  • possible duplicate of use this reference: https://stackoverflow.com/questions/37521853/how-to-get-youtube-live-stream-by-channel-id-in-youtube-api-v3-in-android – ReyAnthonyRenacia Mar 14 '18 at 12:17
  • have you found a solution? – Andrey Solera Jan 20 '19 at 15:31
  • Never found a good solution that work automatically. I had to get a solution working so I just create a input EditText + Button and had the user input the streaming YouTube video. There's probably a way to do it but I was time limited. – Jolopy Jan 28 '19 at 13:49

0 Answers0