Reputation: 1894
I want to play video from YouTube on my app but with custom media player controls as following:
It works if I put those buttons on a separate layout below the player, but I need to overlay the layout which YouTube doesn't support (except for ActionBar
). How can I modify the Android player to meet my needs? Is it possible to use different media player (with VideoView
) to play YouTube videos/playlists? Or can ActionBar
be used to include those media controls including SeekBar
? Please suggest.
Upvotes: 5
Views: 6887
Reputation: 45150
Alternatively, you can use ExoPlayer
and customise controller view:
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:controller_layout_id="@layout/custom_playback_control"/>
XML layout Example :
For more info read this guide:
https://codelabs.developers.google.com/codelabs/exoplayer-intro/#6
Upvotes: 0
Reputation: 44178
You can stream youtube videos through the android MediaPlayer if you have the direct link to the YouTube video.
This source suggests that the direct link can be retrieved using the Google Data API.
Then to customize the the controls you would need to extend your own custom MediaController class which is covered in detail here.
Another way I can think of is to use local html file (from your assets) to display the video inside a WebView. With the help of JQuery it's controls can be tweaked.
Here's an example in JFiddle that uses jquery and css to style the video: JFiddle (alt link)
However note that this method might not be compatible with older android versions as WebView upgraded from WebKit to Chromium not too long ago. The old WebView had a very poor compatibility with HTML5 and videos in general.
Upvotes: 0
Reputation: 59
you can refer below link, you have two choice first download *.jar then import to your android project and run, another check out source from svn server and modify to your want.
https://code.google.com/p/android-youtube-player/
Addition
...
intent.setClass(MainActivity.this, OpenYouTubeActivity.class);
startActivity(intent);
Upvotes: -1