Android播放器的自定义媒体播放器控件

时间:2022-01-07 18:59:08

I want to play video from YouTube on my app but with custom media player controls as following:

我想在我的应用上播放YouTube上的视频,但使用自定义媒体播放器控件如下:

Android播放器的自定义媒体播放器控件

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.

如果我将这些按钮放在播放器下方的单独布局上,它可以工作,但我需要覆盖YouTube不支持的布局(ActionBar除外)。如何修改Android播放器以满足我的需求?是否可以使用不同的媒体播放器(使用VideoView)播放YouTube视频/播放列表?或者ActionBar可以用来包括那些媒体控件,包括SeekBar?请建议。

2 个解决方案

#1


0  

You can stream youtube videos through the android MediaPlayer if you have the direct link to the YouTube video.

如果您有直接链接到YouTube视频,则可以通过Android MediaPlayer流式传输YouTube视频。

This source suggests that the direct link can be retrieved using the Google Data API.

此来源表明可以使用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.

然后自定义控件,扩展自己的自定义MediaController类,这里将详细介绍。


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.

我能想到的另一种方法是使用本地html文件(来自您的资产)在WebView中显示视频。在JQuery的帮助下,它的控件可以调整。

Here's an example in JFiddle that uses jquery and css to style the video: JFiddle (alt link)

以下是JFiddle中使用jquery和css设置视频样式的示例: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.

但是请注意,这个方法可能与旧的Android版本不兼容,因为不久之前WebView从WebKit升级到Chromium。旧的WebView与HTML5和视频的兼容性非常差。

#2


-1  

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.

你可以参考下面的链接,你有两个选择首先下载* .jar然后导入到你的Android项目并运行,另一个从svn服务器检查源并修改为你想要的。

https://code.google.com/p/android-youtube-player/

Addition

加成

...    
intent.setClass(MainActivity.this, OpenYouTubeActivity.class);
startActivity(intent);

#1


0  

You can stream youtube videos through the android MediaPlayer if you have the direct link to the YouTube video.

如果您有直接链接到YouTube视频,则可以通过Android MediaPlayer流式传输YouTube视频。

This source suggests that the direct link can be retrieved using the Google Data API.

此来源表明可以使用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.

然后自定义控件,扩展自己的自定义MediaController类,这里将详细介绍。


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.

我能想到的另一种方法是使用本地html文件(来自您的资产)在WebView中显示视频。在JQuery的帮助下,它的控件可以调整。

Here's an example in JFiddle that uses jquery and css to style the video: JFiddle (alt link)

以下是JFiddle中使用jquery和css设置视频样式的示例: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.

但是请注意,这个方法可能与旧的Android版本不兼容,因为不久之前WebView从WebKit升级到Chromium。旧的WebView与HTML5和视频的兼容性非常差。

#2


-1  

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.

你可以参考下面的链接,你有两个选择首先下载* .jar然后导入到你的Android项目并运行,另一个从svn服务器检查源并修改为你想要的。

https://code.google.com/p/android-youtube-player/

Addition

加成

...    
intent.setClass(MainActivity.this, OpenYouTubeActivity.class);
startActivity(intent);