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?
-
You need to elaborate your question more clearly to get more attention. – VVB Aug 07 '14 at 13:36
-
Couldn't you simply use iframe with the link of the video you'd like to watch? Can you elaborate a little more/have you tried implementing any code? – Dan Aug 07 '14 at 20:49
-
I want to palay youtube video with CSS and javascript from local file inside assets. or I want to play youtube video on html5. How is this possible? – asok Buzz Aug 08 '14 at 10:11
-
1Look at this answer http://stackoverflow.com/a/16179544/1332892 – Mehul Aug 12 '14 at 04:25
-
use chrome client in android – KOTIOS Aug 13 '14 at 09:48
3 Answers
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.

- 127
- 5
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^^

- 161
- 1
- 9
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

- 5,646
- 7
- 36
- 58