我个人的笔记一般比较随便,层次只有自己看的明白。
对于自己发的东西,不喜欢码字码版面,不错,我就是这么偏执。
ExoPlayer:
google文档明确指出,ExoPlayer是拓展和方便MediaPlayer应用而开发的。支持更多的功能和特性。
由于是在MediaPlayer基础上拓展的,所以,所有MediaPlayer的API和所支持的音视频特质均有增无减。
MP4, M4A, FMP4, WebM, MKV, MP3, Ogg, WAV, MPEG-TS, MPEG-PS, FLV and ADTS (AAC).
It also discusses ExoPlayer events, messages, customization and DRM support.
compile 'com.google.android.exoplayer:exoplayer:r2.X.X'
compile 'com.google.android.exoplayer:exoplayer-core:r2.X.X'
compile 'com.google.android.exoplayer:exoplayer-dash:r2.X.X'
compile 'com.google.android.exoplayer:exoplayer-ui:r2.X.X'
exoplayer-core: Core functionality (required).
exoplayer-dash: Support for DASH content.
exoplayer-hls: Support for HLS content.
exoplayer-smoothstreaming: Support for SmoothStreaming content.
exoplayer-ui: UI components and resources for use with ExoPlayer.
//Create a default TrackSelector
Handler mainHandler = new Handler();
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
//Create the player
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(context, trackSelector);
/**
* SimpleExoPlayerView, which encapsulates a PlaybackControlView and a Surface onto which video is rendered.
* setVideoSurfaceView, setVideoTextureView, setVideoSurfaceHolder and setVideoSurface.
* simpleExoPayerView.setPlayer(player);
**/
preparing:
// Measures bandwidth during playback. Can be null if not required.
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
// Produces DataSource instances through which media data is loaded.
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context,Util.getUserAgent(context, "yourApplicationName"), bandwidthMeter);
// Produces Extractor instances for parsing the media data.
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
// This is the MediaSource representing the media to be played.
MediaSource videoSource = new ExtractorMediaSource(mp4VideoUri,dataSourceFactory, extractorsFactory, null, null);
// Prepare the player with the source.
player.prepare(videoSource);
这里的意思是说,ExoPlayer对于媒体源都是用实现MediaSource来封装复用的。这一点,有点像对androidAnimatio封装,可以叠合。
DASH:DashMediaSource
SmoothStreaming:SsMediaSource
HLS:HlsMediaSource
regular media:ExtractorMediaSource
setPlayWhenReady();seekTo();
ExoPlayer.release
//合并播放
MediaSource videoSource = new ExtractorMediaSource(videoUri,...);
MediaSource subtitleSource = new SingleSampleMediaSource(subtitleUri,...);
//Plays the video with the sideloaded subtitle
MergingMediaSource mergedSource = new MergingMediaSource(videoSouce,subtitleSource);
//循环播放
MediaSource source = new ExtractorMediaSource(videoUri,...);
//Loops the video indefinitely.
LoopingMediaSource loopingSouce = new LoopingMediaSource(source(,int));
//播放一个视频序列
MediaSource firstSource = new ExtractorMediaSource(firstVideoUri,...);
MediaSource secondSource = new ExtratorMediaSource(secondVideoUri,...);
//Plays the first video,then the second video
ConcatenatingMediaSource concatenatedSource = new ConcatenatingMediaSource(firstSource,secondSource);
在ExoPlayer的特性中,是支持数字版权的,Digit Rights Manager,DRM,具体的可以查看google的相信文档,这里只是抛砖引玉。还要说的是,DRM和Exo的一些东西,需要在android4.4之后才有支持。所以在选型时,还要考虑更多的东西。。如果没记错的话,BiLibiLi,也就是B站,在自己封装的解编码框架基础上,实现了一个类似ExoPlayer的东西。可以作为选型的方案之一。
Google提供这样的支持库,扩展和强化功能,已经不是一点两点的事了。在以前的使用有一个CustomWeb好像,记不清了,用新的思想来加载WebView,对于原理和项目我也记不清了,支持到这是对android WebView的提高和优化,并不是去解决浏览器渲染核心这个级别的问题。