user2211659
user2211659

Reputation: 83

Customizing youtube player view in android

i am using an youtube player api of google to play youtube videos, it specifies three different styles of player view, is this any way to customize the player view in android.

Thank you

Upvotes: 8

Views: 22479

Answers (4)

The Finest Artist
The Finest Artist

Reputation: 3189

I don't know what kind of style you want, but you can use YouTube Player as Activity or Fragment or a View.

So you can basically customise your player easily with new YouTubePlayer API

If you want some simple youtube player with fullscreen (no titlebar mode), You are welcome to use my code!!

This source handle "Orientation Problem", "Media Volume Problem", "Youtube Url Parsing Problem"

  1. Here is open source library

    https://github.com/TheFinestArtist/SimpleYouTubePlayer

  2. This is sample codes

    https://gist.github.com/TheFinestArtist/5545437

  3. I also made sample app you can download

    https://play.google.com/store/apps/details?id=com.thefinestartist.simpleyoutubeplayer

Upvotes: 9

Abhishek Maheshwari
Abhishek Maheshwari

Reputation: 121

Try this link for youtube video play in my layout : http://www.techrepublic.com/blog/software-engineer/using-googles-youtube-api-in-your-android-apps/

public class MainActivity extends YouTubeBaseActivity implements
YouTubePlayer.OnInitializedListener {

    static private final String DEVELOPER_KEY = "add your own key here!";
    static private final String VIDEO = "4SK0cUNMnMM";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        YouTubePlayerView youTubeView = (YouTubePlayerView)
        findViewById(R.id.youtube_view);
        youTubeView.initialize(DEVELOPER_KEY, 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(VIDEO);
    }
}

Upvotes: 5

user2088250
user2088250

Reputation: 81

FYI: you can use PopupWindow to workaround restriction: "it is not permitted to overlay the [player] view with other views while a video is playing"

Upvotes: 0

Ibrahim Ulukaya
Ibrahim Ulukaya

Reputation: 12877

You can pick he chromeless style, it doesn't have any controls - it's only a rectangle that plays a video under programmatic control.

You're free to implement your own controls UI outside the player and wire them up through the YouTubePlayer that you get back after initializing a YouTubePlayerView or YouTubePlayerFragment. Keep in mind that, as mentioned in the YouTubePlayerView JavaDoc, "it is not permitted to overlay the [player] view with other views while a video is playing"

Upvotes: 3

Related Questions