asok Buzz
asok Buzz

Reputation: 1894

html5 mediaplayer to play youtube video

I want to play youtube videos with html5 on my android device. I would also like to add some css and change to media control. How can I achieve this? Is there any good place to start or some sample application?

Upvotes: 4

Views: 833

Answers (3)

Confuse
Confuse

Reputation: 5786

Sample app

Code

Source Code

Also add this code to Mainfest -

<activity
    android:name="com.sample.android.YouTubePlayerActivity"
    android:configChanges="keyboardHidden|orientation|screenSize"
    android:screenOrientation="sensor"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
</activity>

HOW TO USE

Put Youtube_api_key in YouTubePlayerActivity

public static final String GOOGLE_API_KEY = "AIzaSyAOfxiG4aV66h3XmssCEkP3qCvCq******";

Get Youtube Video id from URL

final String videoId = YouTubePlayerActivity.getYouTubeVideoId("VideoURL");

Add video id as Extra and Start Activity

Intent intent = new Intent(MainActivity.this, YouTubePlayerActivity.class);
intent.putExtra(YouTubePlayerActivity.EXTRA_VIDEO_ID, videoId);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);

EDIT

You can also customize YouTube Video using YouTube Player

Upvotes: 1

Stephan
Stephan

Reputation: 161

Try out the videojs-youtube-plugin, it´s based on videojs.

Videojs is one of the best HTML5 video player, we use it every time we have to include a video.

It´s fully customizable for the desgin of controls and many other options. It uses the HTML5 video tag and no iframes! For older devices/browsers it has a Fallback. It´s just awesome^^

Upvotes: 1

Adam Sax
Adam Sax

Reputation: 127

You may want to consider trying to using the YouTube Embedded API inside an Android WebView.

Essentially you would create an Activity that contains a WebView that loads an HTML file that contains the youtube <iframe>.

The YouTube Embedded API doesn't allow for complete customization but there are some parameters for changing colors and control styles.

Upvotes: 4

Related Questions