博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ExoPlayer
阅读量:4292 次
发布时间:2019-05-27

本文共 3644 字,大约阅读时间需要 12 分钟。

我个人的笔记一般比较随便,层次只有自己看的明白。

对于自己发的东西,不喜欢码字码版面,不错,我就是这么偏执。

 ExoPlayer:

google文档明确指出,ExoPlayer是拓展和方便MediaPlayer应用而开发的。支持更多的功能和特性。

由于是在MediaPlayer基础上拓展的,所以,所有MediaPlayer的API和所支持的音视频特质均有增无减。

DASH, SmoothStreaming and HLS adaptive streams, as well as formats such as
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.

creating player:
//Create a default TrackSelectorHandler mainHandler = new Handler();BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);//Create the playerSimpleExoPlayer 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 subtitleMergingMediaSource 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 videoConcatenatingMediaSource concatenatedSource = new ConcatenatingMediaSource(firstSource,secondSource);

在ExoPlayer的特性中,是支持数字版权的,Digit Rights Manager,DRM,具体的可以查看google的相信文档,这里只是抛砖引玉。还要说的是,DRM和Exo的一些东西,需要在android4.4之后才有支持。所以在选型时,还要考虑更多的东西。。如果没记错的话,BiLibiLi,也就是B站,在自己封装的解编码框架基础上,实现了一个类似ExoPlayer的东西。可以作为选型的方案之一。

Google提供这样的支持库,扩展和强化功能,已经不是一点两点的事了。在以前的使用有一个CustomWeb好像,记不清了,用新的思想来加载WebView,对于原理和项目我也记不清了,支持到这是对android WebView的提高和优化,并不是去解决浏览器渲染核心这个级别的问题。

转载地址:http://tcegi.baihongyu.com/

你可能感兴趣的文章
Android include标签的使用注意事项
查看>>
final成员变量和final局部变量
查看>>
Android数据加密之异或加密算法
查看>>
greenDao好的示例网址
查看>>
Android自定义控件--仿安全卫士中的一键加速
查看>>
Android Tools Attributes,让布局设计所见即所得
查看>>
Android内存泄露的原因
查看>>
Java并发总结
查看>>
JavaScript筑基篇(二)->JavaScript数据类型
查看>>
干货:Java几种线程池的分析和使用。
查看>>
避免在Java接口中使用数组的3个理由
查看>>
android 自定义带动画的统计饼图
查看>>
入职必备,Android 真实面试题(内有答案)
查看>>
JavaScript 日期处理类库---Moment.js
查看>>
仿斗鱼直播的弹幕效果实现
查看>>
Android(Java)中的Object
查看>>
Java反射机制——学习总结
查看>>
Android大图片处理
查看>>
Hadoop平台相关技术
查看>>
Android中热修复框架AndFix原理解析及案例使用
查看>>