Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 448
user2211659 Avatar asked May 02 '13 06:05

user2211659


2 Answers

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

like image 67
The Finest Artist Avatar answered Nov 20 '22 14:11

The Finest Artist


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);
    }
}
like image 5
Abhishek Maheshwari Avatar answered Nov 20 '22 15:11

Abhishek Maheshwari