AndroidGSYVideoPlayer视频播放器功能的实现

AndroidGSYVideoPlayer视频播放器功能的实现

2023年7月11日发(作者:)

AndroidGSYVideoPlayer视频播放器功能的实现GSYVideoPlayerGSYVideoPlayer ⼀个基于IJkPlayer的播放器⽀持调节声⾳亮度边播边缓存 使⽤了AndroidVideoCache;ExoPlayer使⽤SimpleCache⽀持多种协议h26345、Https、concat、rtsp、hls、rtmp、crypto、mpeg等等简单滤镜(马赛克、⿊⽩、⾊彩过滤、⾼斯、模糊、模糊等等20多种)、动画、(⽔印、画⾯多重播放等)视频第⼀帧、视频帧截图功能,视频⽣成gif功能。调整显⽰⽐例:默认、16:9、4:3、填充;播放时旋转画⾯⾓度(0,90,180,270);镜像旋转IJKPlayer、EXOPlayer、MediaPlayer切换、⾃定义内核⼩窗⼝、多窗体下(包括桌⾯)的⼩窗⼝播放。⽚头⼴告、跳过⼴告⽀持、中间插⼊⼴告功能。暂停前后台切换不⿊屏;调整不同清晰度的⽀持;⽆缝切换⽀持;锁定/解锁全屏点击功能;进度条⼩窗⼝预览可⾃定义渲染层、⾃定义管理层、⾃定义播放层(控制层)、⾃定义缓存层使⽤依赖1、JCenter 引⼊⽅法(推荐)你可以选择下⾯三种的其中⼀种,在module下的添加。A、直接引⼊//完整版引⼊implementation ':GSYVideoPlayer:8.1.2'B、添加java和你想要的so⽀持:implementation ':gsyVideoPlayer-java:8.1.2'//是否需要ExoPlayer模式implementation ':GSYVideoPlayer-exo2:8.1.2'//根据你的需求ijk模式的soimplementation ':gsyVideoPlayer-armv5:8.1.2'implementation ':gsyVideoPlayer-armv7a:8.1.2'implementation ':gsyVideoPlayer-arm64:8.1.2'implementation ':gsyVideoPlayer-x64:8.1.2'implementation ':gsyVideoPlayer-x86:8.1.2'C、⽀持其他格式协议的(mpeg,rtsp, concat、crypto协议)implementation ':gsyVideoPlayer-java:8.1.2'//是否需要ExoPlayer模式implementation ':GSYVideoPlayer-exo2:8.1.2'//更多ijk的编码⽀持implementation ':gsyVideoPlayer-ex_so:8.1.2'代码中的全局切换⽀持//EXOPlayer内核,⽀持格式更多yManager();//系统内核模式yManager();//ijk内核,默认模式yManager();//exo缓存模式,⽀持m3u8,只⽀持heManager();//代理缓存模式,⽀持所有模式,不⽀持m3u8等,默认heManager();//切换渲染模式wType(_MATCH_FULL);//默认显⽰⽐例_TYPE_DEFAULT = 0;//16:_TYPE_16_9 = 1;//4:_TYPE_4_3 = 2;//全屏裁减显⽰,为了显⽰正常 CoverImageView 建议使⽤FrameLayout作为⽗布局_TYPE_FULL = 4;//全屏拉伸显⽰,使⽤这个属性时,surface_container建议使⽤_MATCH_FULL = -4;/*** * SCREEN_TYPE_CUSTOM 下⾃定义显⽰⽐例 * @param screenScaleRatio ⾼宽⽐,如 16:9 */public static void setScreenScaleRatio(float screenScaleRatio)//切换绘制模式derType(E);derType(ACE);derType(E);//ijk关闭Level(_LOG_SILENT);//exoplayer⾃定义MediaSourceInterceptListener(new ExoMediaSourceInterceptListener() { @Override public MediaSource getMediaSource(String dataSource, boolean preview, boolean cacheEnable, boolean isLooping, File cacheDir) { //可⾃定义MediaSource return null; }});⾃定义⼀个播放器public class LiveVideo extends StandardGSYVideoPlayer { public LiveDataFullscreenButtonClick liveDataClick;//点击全屏按钮回调 /** * 恢复暂停状态 */ public void onResume() { onVideoResume(); } /** * 暂停状态 */ public void onPause() { onVideoPause(); } /** * 接⼝回调 * @param liveDataClick */ public void setOnFullscreenButtonClick(LiveDataFullscreenButtonClick liveDataClick) { taClick = liveDataClick; } /* 重写⽅法⾃定义layout id与video_layout_⼀致 不重新使⽤系统默认布局*/ @Override public int getLayoutId() { return ; } public LiveVideo(Context context, Boolean fullFlag) { super(context, fullFlag); init(); } public LiveVideo(Context context) { super(context); init(); } public LiveVideo(Context context, AttributeSet attrs) { super(context, attrs); init(); } /* 初始化操作 */ private void init() { //EXOPlayer内核,⽀持格式更多// yManager(); //代理缓存模式,⽀持所有模式,不⽀持m3u8等,默认// heManager(); //系统内核模式// yManager(); //ijk内核,默认模式 yManager(); settingsVideo(); } /* ⼀些播放器的设置 做⼀些UI的隐藏 可根据⾃⼰需求*/ public void settingsVideo() { MediaCodec();//使能硬解码,播放前设置 ();//打开GSY的Log //隐藏⼀些UI setViewShowState(mBottomContainer, VISIBLE); setViewShowState(mTopContainer, VISIBLE); setViewShowState(mLockScreen, GONE); setViewShowState(mLoadingProgressBar, GONE); setViewShowState(mTopContainer, GONE); setViewShowState(mThumbImageView, GONE); setViewShowState(mBottomProgressBar, GONE); //显⽰⼀些UI 进度 时间 当前时间 全屏 返回 加载Loading 暂停开始 setViewShowState(mStartButton, VISIBLE); setViewShowState(mLoadingProgressBar, VISIBLE); setViewShowState(mFullscreenButton, VISIBLE); setViewShowState(mBackButton, GONE); setViewShowState(mProgressBar, VISIBLE); setViewShowState(mCurrentTimeTextView, VISIBLE); setViewShowState(mTotalTimeTextView, VISIBLE); setEnlargeImageRes(); setShrinkImageRes(); } //拦截事件 @Override public boolean dispatchTouchEvent(MotionEvent ev) { lickListener(new OnClickListener() { @Override public void onClick(View view) { k(); } }); return chTouchEvent(ev); } /* 取消 双击暂停 */ @Override protected void touchDoubleUp() {// oubleUp(); } public interface LiveDataFullscreenButtonClick { void onClick(); }}

api/** * 设置播放URL * * @param url 播放url * @param cacheWithPlay 是否边播边缓存 * @param title title * @return */("url", false, "");//设置播放路径layLogic();//开始播放到此这篇关于Android GSYVideoPlayer视频播放器功能的实现的⽂章就介绍到这了,更多相关Android GSYVideoPlayer视频播放器内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!

发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1689066573a202339.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信