Youtube video 400 when trying to play video

I am trying to play a video using the YouTube video API.

When I set static identifiers, I declare the ID in the file, the code is working at this time.

But when I try to get the id from getIntent (), I also got the id, but the video is not playing.

I am having a network problem.

Below is my code. His work is in this state.

public String VIDEO = "QqnBjKnwCwE";

youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);
        youTubeView.initialize(DEVELOPER_KEY, Videosshow.this);

@Override
    public void onInitializationFailure(Provider provider,
            YouTubeInitializationResult error) {
        Toast.makeText(this, "Oh no! " + error.toString(), Toast.LENGTH_LONG)
                .show();
    }

    @Override
    public void onInitializationSuccess(Provider provider,
            YouTubePlayer player, boolean wasRestored) {

        player.loadVideo(String.valueOf( VIDEO));
    }

Now that i used

Bundle data = getIntent().getExtras();

        VIDEO=data.getString("videourl");
        youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);
        youTubeView.initialize(DEVELOPER_KEY, Videosshow.this);

not working I got a 400 network error

+3
source share
3 answers

Check your ID. I think there is a space in the id or youtube url to either start or end. I have a similar problem and are being solved by this. You should also try. Perhaps this will help if you configured it correctly.

+1

, , , , = (say = hdeFZ6nt9tc), . , URL- youtube ( https://www.youtube.com/watch?v=hdeFZ6nt9tc). , . , . , youtube 404 ( " " ) .

+1

I had the same problem, but getting the video id from url solved my problem.

String video_id=jsonObject.getString("id");

Thank ritesh

0
source

All Articles