hty527 / iplayer Goto Github PK
View Code? Open in Web Editor NEW支持IJKPlayer、ExoPlayer、MediaPlayer和其它更多解码器切换、支持静音、镜像、渲染模式、倍速设置等功能的轻便级播放器,支持自定义解码器、控制器、UI交互组件和悬浮窗播放能力等
支持IJKPlayer、ExoPlayer、MediaPlayer和其它更多解码器切换、支持静音、镜像、渲染模式、倍速设置等功能的轻便级播放器,支持自定义解码器、控制器、UI交互组件和悬浮窗播放能力等
我试了一下,某些m3u8链接使用IjkPlayerFactory内核播放时是没有声音的,例如这个: https://s.xlzys.com/play/9avDmPgd/index.m3u8
mVideoPlayer = (VideoPlayer) findViewById(R.id.video_player);
mVideoPlayer.getLayoutParams().height= getResources().getDisplayMetrics().widthPixels * 9 /16;//固定播放器高度,或高度设置为:match_parent
//使用SDK自带控制器+各UI交互组件
VideoController controller = new VideoController(mVideoPlayer.getContext());//创建一个默认控制器
mVideoPlayer.setController(controller);//将播放器绑定到控制器
mVideoPlayer.setLandscapeWindowTranslucent(true);
mVideoPlayer.setOnPlayerActionListener(new OnPlayerEventListener() {
@Override
public AbstractMediaPlayer createMediaPlayer() {
IJkMediaPlayer player= IjkPlayerFactory.create().createPlayer(MainActivity.this);
String filter = "movie='/sdcard/Download/lestream/test.jpg'[mask];[in][mask]overlay=10:10[out]";
player.getMediaPlayer().setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "vf", filter);
return player;
}
});
WidgetFactory.bindDefaultControls(controller);//一键使用默认UI交互组件绑定到控制器(需集成:implementation 'com.github.hty527.iPlayer:widget:lastversion')
//设置视频标题(仅横屏状态可见)
controller.setTitle("测试地址播放");
//设置播放源
mVideoPlayer.setDataSource(FILE_SAVE_PATH+"/video/test.webm");
//mVideoPlayer.setDataSource("http://39.135.138.58:18890/PLTV/88888888/224/3221225618/index.m3u8");
//异步开始准备播放
mVideoPlayer.prepareAsync();
在以上代码中,想要设置fitler
IJkMediaPlayer player= IjkPlayerFactory.create().createPlayer(MainActivity.this);
String filter = "movie='/sdcard/Download/lestream/test.jpg'[mask];[in][mask]overlay=10:10[out]";
player.getMediaPlayer().setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "vf", filter);
但是看起来并没生效,是啥问题?
我按照demo使用了仿抖音(扩展示例,支持缓存) 但是列表的视频一点就自动暂停播放了,我想点击跳转界面, 该怎么做
mVideoPlayer.setDataSource(liveRoom.getLivePlayUrl());
mVideoPlayer.prepareAsync();
......
Log.d(msg,"=================> positionMs=" + (positionMs/1000));
Log.d(msg,"=================> player.getCurrentPosition()1=" + player.getCurrentPosition());
player.seekTo(positionMs);
Log.d(msg,"=================> player.getCurrentPosition()2=" + player.getCurrentPosition());
player.seekTo(positionMs)的前后获取的player.getCurrentPosition()居然是一样的。视频也没有前进到指定时间。
1、ijkplayer不支持播放content协议的视频链接,只能转成普通格式的。我这儿已经解决
2、ijkplayer中的解码库类型不够多,只能播放mp4等常见格式的,我重新编译了新的ijkplayer解码库,内嵌了更多的播放格式,经过测试没有问题,所以你看我可以上传到你的仓库吗?
再次打扰,打算通过连续播放来实现广告功能的时候发现个问题
mVideoPlayer.setInterceptTAudioFocus(true);//是否监听音频焦点状态,设置为true后SDK在监听焦点丢失时自动暂停播放
无论为true还是false,onPause/onStop/播放器失焦:均不会停止播放
以下情况均在进程未销毁的情况下测试
当为true时
1、通过返回键回到桌面,触发onRestrat,画面会从头播放,音频会在之前的进程未关闭的情况下再从头播放一个,两个音频出现叠加
2、通过Home键回到桌面,触发onRestrat,视频音频皆正常播放
2、当为false时
1、通过返回键回到桌面,触发onRestrat,画面和音频均会从头播放,不会叠加
2、通过Home键回到桌面,触发onRestrat,之前的视频和音频会被暂停且存储(暂且称之为存储吧),正常播放不会出现问题。但是当点击返回的时候,会销毁当前的视图,并恢复到上一个存储的视图(View?),如果你点了N次Home键,那就需要点N+1次返回才能回到桌面。
有点晚了,所以还没看代码,描述可能不太准确。明天空了看看,如果有更正我再补充。
注:提issues的时候重试了一遍发现false下的2情况,不是百分百复现,有点迷,好像是在切换setInterceptTAudioFocus()参数并且未结束进程直接覆盖安装的时候会出现,作为我的白盒方向明天继续研究。
请问SDK支持竖屏全屏播放吗?如果不支持的话自定义播放器如何实现?
正常调用prepareAsync播放后点击播放器内部的全屏按钮切换为横屏全屏播放时,画面有些超出屏幕大小,而在普通情况下 (不点击全屏)时内容刚好可以放下,没有超出屏幕被截断。
一个小建议就是全屏播放时左侧会有一块黑色区域(应该是状态栏),是否可以让画面显示到状态栏?(透明状态栏或者应该叫沉浸模式?)
感谢作者开发的库,十分好用,谢谢。
Your demo code was
`<com.android.player.media.VideoPlayer
android:id="@+id/video_player"
android:layout_width="match_parent"
android:layout_height="200dp"
app:initController="true"/>`
But it should be ( player -> iplayer )
`<com.android.iplayer.media.VideoPlayer
android:id="@+id/video_player"
android:layout_width="match_parent"
android:layout_height="200dp"
app:initController="true"/>`
目前体验非常棒,细节处理的也很好
When I play an SDcard video that plays offline, it say "Network is not connected".
This class is not included in the iplayer package and cannot be used when you try to use the floating window, and this causes me a lot of problems
大佬能否在widget库内置一套类似于B站的弹幕发送组件,可以选择颜色和输入文字,发送事件由开发者们自行实现?很喜欢大佬的库,辛苦了。
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
repositories {
flatDir {
dirs 'libs'
}
google()
jcenter()
mavenCentral()
maven {
url "https://jitpack.io"
}
//GroMore SDK依赖
maven {
url "https://artifact.bytedance.com/repository/pangle"
}
//友盟统计服务
maven { url 'https://repo1.maven.org/maven2/' }
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' // add plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
flatDir {
dirs 'libs'
}
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
//GroMore SDK依赖
maven {
url "https://artifact.bytedance.com/repository/pangle"
}
//友盟统计服务
maven { url 'https://repo1.maven.org/maven2/' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
//播放器(无UI交互)
implementation 'com.github.hty527.iPlayer:iplayer:2.1.26.1'
//SDK默认UI交互组件
implementation 'com.github.hty527.iPlayer:widget:2.1.26.1'
//音视频预缓存+边播边存
implementation 'com.github.hty527.iPlayer:cache:2.1.26.1'
//ijk音视频解码器
implementation 'com.github.hty527.iPlayer:ijk:2.1.26.1'
//exo音视频解码器
implementation 'com.github.hty527.iPlayer:exo:2.1.26.1'
已经导包。但是无法调用这个方法
IjkPlayerFactory.create().createPlayer(VideoPlayerActivity.this)
can u add subtitle to the player please
java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.video.tools.audio/cache/video-cache/15-01.mp4file0.ts: open failed: ENOENT (No such file or directory)
在仿抖音滑动的使用场景中,偶尔会出现无法播放的问题,滑到下个视频再滑回来的时候就能播放了
无法播放时,控制台出现如下日志,显示I/O error但并没有响应error回调
E/IJKMEDIA: error:00000000:lib(0):func(0):reason(0)
I/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 2
E/IJKMEDIA: ************************.mp4: I/O error
I/IJKMEDIA: SDL_JNI_DetachThreadEnv: [26394]
I/IJKMEDIA: SDL_JNI_DetachThreadEnv: [26393]
D/IJKMEDIA: ijkmp_shutdown_l()=void
D/IJKMEDIA: ijkmp_dec_ref(): ref=0
D/IJKMEDIA: ijkmp_shutdown_l()
D/IJKMEDIA: ijkmp_shutdown_l()=void
E/IJKMEDIA: SDL_JNI_ThreadDestroyed: [26396] didn't call SDL_JNI_DetachThreadEnv() explicity
I/Pinger: Ping response: ping ok
, pinged? true
D/PreloadTask: 预缓存成功:position:26,Byte:1056767
D/PreloadTask: 预缓存结束:position:26
作者您好,我在使用IJK作为播放器时发现了一个问题:如果我不重写AbstractMediaPlayer的话,使用系统的MediaPlayer是可以播放content://开头的路径的。我按照Demo中的自己写了继承AbstractMediaPlayer的IJKMediaPlayer,塞入content://路径后无法播放。我猜应该是IJKMediaPlayer不支持content://的格式?作者有发现这个问题嘛,通过content://反向解析出file://貌似比较困难,能否让ijk直接播放content://路径的视频呢?
Demo中的VideoPlayer顶部功能菜单有tv投屏按钮,请问sdk内部实现了此功能了吗?如何调用?
视频源: https://developer.android.google.cn/static/videos/design/ui/hero.mp4
错误日志:
2024-04-12 17:34:43.265 24291-24542 CacheLog com.android.player D Open connection with offset 4068386 to https://developer.android.google.cn/static/videos/design/ui/hero.mp4
2024-04-12 17:34:43.269 24291-24542 System.out com.android.player I [okhttp]:check permission begin!
2024-04-12 17:34:43.270 24291-24542 System.out com.android.player I [okhttp]:not MMS!
2024-04-12 17:34:43.270 24291-24542 System.out com.android.player I [okhttp]:not Email!
2024-04-12 17:34:43.271 24291-24542 System.out com.android.player I [OkHttp] sendRequest>>
2024-04-12 17:34:43.271 24291-24542 System.out com.android.player I [OkHttp] sendRequest<<
2024-04-12 17:36:37.869 24291-24291 BufferQueueProducer com.android.player I [SurfaceTexture-0-24291-8](id:5ee30000000a,api:3,p:964,c:24291) disconnect(): api=3
2024-04-12 17:36:37.870 24291-24291 BufferQueueConsumer com.android.player I [SurfaceTexture-0-24291-8](id:5ee30000000a,api:0,p:-1,c:24291) disconnect()
2024-04-12 17:36:37.870 24291-24552 MediaPlayer com.android.player V resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
2024-04-12 17:36:37.870 24291-24552 MediaPlayer com.android.player V cleanDrmObj: mDrmObj=null mDrmSessionId=null
2024-04-12 17:36:37.870 24291-24552 MediaPlayer com.android.player D _release native called
2024-04-12 17:36:37.871 24291-24291 BasePlayer com.android.player D onPlayerState-->state:STATE_RESET,message:结束播放并重置
2024-04-12 17:36:37.871 24291-24552 MediaPlayer com.android.player D _release native finished
2024-04-12 17:36:37.874 24291-24341 CacheLog com.android.player D Open connection to http://127.0.0.1:38961/ping
2024-04-12 17:36:37.875 24291-24341 System.out com.android.player I [okhttp]:check permission begin!
2024-04-12 17:36:37.875 24291-24341 System.out com.android.player I [okhttp]:not MMS!
2024-04-12 17:36:37.875 24291-24341 System.out com.android.player I [okhttp]:not Email!
2024-04-12 17:36:37.875 24291-24341 System.out com.android.player I [socket]:check permission begin!
2024-04-12 17:36:37.877 24291-24341 System.out com.android.player I [OkHttp] sendRequest>>
2024-04-12 17:36:37.877 24291-24341 System.out com.android.player I [OkHttp] sendRequest<<
2024-04-12 17:36:37.878 24291-24341 CacheLog com.android.player I Ping response: `ping ok`, pinged? true
2024-04-12 17:36:37.880 24291-24291 ExoPlayerImpl com.android.player I Init c22e152 [ExoPlayerLib/2.18.1] [evergo, 21091116AC, Xiaomi, 30]
2024-04-12 17:36:37.884 24291-24291 IVideoPlayer com.android.player D 解码器内核:ExoMediaPlayer
2024-04-12 17:36:37.885 24291-24291 IVideoPlayer com.android.player D 渲染器内核:MediaTextureView
2024-04-12 17:36:37.885 24291-24291 BasePlayer com.android.player D onPlayerState-->state:STATE_PREPARE,message:播放准备中
2024-04-12 17:36:37.886 24291-24291 IVideoPlayer com.android.player D startPlayer-->source:http://127.0.0.1:38961/https%3A%2F%2Fdeveloper.android.google.cn%2Fstatic%2Fvideos%2Fdesign%2Fui%2Fhero.mp4
2024-04-12 17:36:37.887 24291-24291 BasePlayer com.android.player D onPlayerState-->state:STATE_BUFFER,message:缓冲开始
2024-04-12 17:36:37.888 24291-24291 DecorView[] com.android.player D getWindowModeFromSystem windowmode is 1
2024-04-12 17:36:37.889 24291-24554 System.out com.android.player I [okhttp]:check permission begin!
2024-04-12 17:36:37.889 24291-24554 System.out com.android.player I [okhttp]:not MMS!
2024-04-12 17:36:37.889 24291-24554 System.out com.android.player I [okhttp]:not Email!
2024-04-12 17:36:37.889 24291-24554 System.out com.android.player I [socket]:check permission begin!
2024-04-12 17:36:37.891 24291-24554 System.out com.android.player I [OkHttp] sendRequest>>
2024-04-12 17:36:37.891 24291-24554 System.out com.android.player I [OkHttp] sendRequest<<
2024-04-12 17:36:37.894 24291-24291 TextureView com.android.player D getHardwareLayer, createNewSurface:true
2024-04-12 17:36:37.894 24291-24291 BufferQueueConsumer com.android.player I [](id:5ee30000000b,api:0,p:-1,c:24291) connect(): controlledByApp=true
2024-04-12 17:36:37.921 24291-24554 System.out com.android.player I [okhttp]:check permission begin!
2024-04-12 17:36:37.921 24291-24554 System.out com.android.player I [okhttp]:not MMS!
2024-04-12 17:36:37.921 24291-24554 System.out com.android.player I [okhttp]:not Email!
2024-04-12 17:36:37.922 24291-24554 System.out com.android.player I [OkHttp] sendRequest>>
2024-04-12 17:36:37.922 24291-24554 System.out com.android.player I [OkHttp] sendRequest<<
2024-04-12 17:36:37.927 24291-24554 System.out com.android.player I [okhttp]:check permission begin!
2024-04-12 17:36:37.927 24291-24554 System.out com.android.player I [okhttp]:not MMS!
2024-04-12 17:36:37.927 24291-24554 System.out com.android.player I [okhttp]:not Email!
2024-04-12 17:36:37.928 24291-24554 System.out com.android.player I [socket]:check permission begin!
2024-04-12 17:36:37.930 24291-24554 System.out com.android.player I [OkHttp] sendRequest>>
2024-04-12 17:36:37.930 24291-24554 System.out com.android.player I [OkHttp] sendRequest<<
2024-04-12 17:36:37.953 24291-24554 System.out com.android.player I [okhttp]:check permission begin!
2024-04-12 17:36:37.953 24291-24554 System.out com.android.player I [okhttp]:not MMS!
2024-04-12 17:36:37.953 24291-24554 System.out com.android.player I [okhttp]:not Email!
2024-04-12 17:36:37.953 24291-24554 System.out com.android.player I [OkHttp] sendRequest>>
2024-04-12 17:36:37.953 24291-24554 System.out com.android.player I [OkHttp] sendRequest<<
2024-04-12 17:36:38.958 24291-24554 System.out com.android.player I [okhttp]:check permission begin!
2024-04-12 17:36:38.958 24291-24554 System.out com.android.player I [okhttp]:not MMS!
2024-04-12 17:36:38.959 24291-24554 System.out com.android.player I [okhttp]:not Email!
2024-04-12 17:36:38.960 24291-24554 System.out com.android.player I [socket]:check permission begin!
2024-04-12 17:36:38.962 24291-24554 System.out com.android.player I [OkHttp] sendRequest>>
2024-04-12 17:36:38.962 24291-24554 System.out com.android.player I [OkHttp] sendRequest<<
2024-04-12 17:36:38.997 24291-24554 System.out com.android.player I [okhttp]:check permission begin!
2024-04-12 17:36:38.997 24291-24554 System.out com.android.player I [okhttp]:not MMS!
2024-04-12 17:36:38.997 24291-24554 System.out com.android.player I [okhttp]:not Email!
2024-04-12 17:36:38.998 24291-24554 System.out com.android.player I [OkHttp] sendRequest>>
2024-04-12 17:36:38.998 24291-24554 System.out com.android.player I [OkHttp] sendRequest<<
2024-04-12 17:36:41.008 24291-24554 System.out com.android.player I [okhttp]:check permission begin!
2024-04-12 17:36:41.008 24291-24554 System.out com.android.player I [okhttp]:not MMS!
2024-04-12 17:36:41.008 24291-24554 System.out com.android.player I [okhttp]:not Email!
2024-04-12 17:36:41.009 24291-24554 System.out com.android.player I [socket]:check permission begin!
2024-04-12 17:36:41.014 24291-24554 System.out com.android.player I [OkHttp] sendRequest>>
2024-04-12 17:36:41.015 24291-24554 System.out com.android.player I [OkHttp] sendRequest<<
2024-04-12 17:36:41.063 24291-24554 System.out com.android.player I [okhttp]:check permission begin!
2024-04-12 17:36:41.063 24291-24554 System.out com.android.player I [okhttp]:not MMS!
2024-04-12 17:36:41.064 24291-24554 System.out com.android.player I [okhttp]:not Email!
2024-04-12 17:36:41.064 24291-24554 System.out com.android.player I [OkHttp] sendRequest>>
2024-04-12 17:36:41.065 24291-24554 System.out com.android.player I [OkHttp] sendRequest<<
2024-04-12 17:36:41.077 24291-24553 ExoPlayerImplInternal com.android.player E Playback error
com.google.android.exoplayer2.ExoPlaybackException: Source error
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:632)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:604)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:236)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: java.net.ProtocolException: Unexpected status line: &��A���F����Z���f���il�Qޘ��O�x�����w�ۨ�s;���@�:Y��#B��#��t�9��6�G*�H8�-����M-��h_�wY������=���I��ܦ��}�Q�.�l-�������J>#b���]ox6T9�o�י�����ޖ:(.���QJ���R�8*��x�8�LhE�C�f���������d$U����5����z�w=q�]���^�E(�,��쀐�??3!7����^���3�n�27ߓ�F�m��3�������ڑW�_6i�D�;����{�@�{�� NA� ��դ���S���q�w\��#�݂��??=,�sS��s�����Z��*��/�����zF#r�f��/)u���-��f�o�.�%�����>�_�Ϟ��S�H������`�� uy���@ˣ{�Q�0��Q�Od�۠��W���C"��9���_4�����,��Վ��54~Eܒ"���E��c� ��+�J��6�^�8����6 �����N�p��cS�t���[�~��&J�.��j��d�����"�R��p��� ���??���h@%��������J2Z��8B���vV%="t�;6ʒ� ���{'�`|5穦5�-�aQ+��+3)�t�A�����dY��&����{j��.�j��~�R]��$+���Ϻ����EےOU� ��j_��f��s��~��"��"(`ʭ�)=���� �� �����K,6�J<�U��ޯo$� �9Z~qJ�@���@����H���N֭$xݢ�M�^�o��/��uZ�0�k�iĞ�|߹�g�zF� �Y�k?��v�t*�yK �@I�������\��:��b��{���2���9��q kA�ݷv4B���q������'w���BU�-d�Q�R)��)*�O`����K�E|���n���:�m���T<]^FU"/A��HH�O�t�OA����爩aɔq�?M[�����h�xз6Y�%j�u�����K���#kJ�%}s�фb�����j҇��"��*9B,�2�X/�� �03�O��S�Vv���SZ|�gXEc+�ő�M�y�p��� �C>�K���3i���q��W��+��S�z��шd|��fL���
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:373)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:258)
at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1005)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2024-04-12 17:36:41.077 24291-24553 ExoPlayerImplInternal com.android.player E Caused by: java.net.ProtocolException: Unexpected status line: &��A���F����Z���f���il�Qޘ��O�x�����w�ۨ�s;���@�:Y��#B��#��t�9��6�G*�H8�-����M-��h_�wY������=���I��ܦ��}�Q�.�l-�������J>#b���]ox6T9�o�י�����ޖ:(.���QJ���R�8*��x�8�LhE�C�f���������d$U����5����z�w=q�]���^�E(�,��쀐�??3!7����^���3�n�27ߓ�F�m��3�������ڑW�_6i�D�;����{�@�{�� NA� ��դ���S���q�w\��#�݂��??=,�sS��s�����Z��*��/�����zF#r�f��/)u���-��f�o�.�%�����>�_�Ϟ��S�H������`�� uy���@ˣ{�Q�0��Q�Od�۠��W���C"��9���_4�����,��Վ��54~Eܒ"���E��c� ��+�J��6�^�8����6 �����N�p��cS�t���[�~��&J�.��j��d�����"�R��p��� ���??���h@%��������J2Z��8B���vV%="t�;6ʒ� ���{'�`|5穦5�-�aQ+��+3)�t�A�����dY��&����{j��.�j��~�R]��$+���Ϻ����EےOU� ��j_��f��s��~��"��"(`ʭ�)=���� �� �����K,6�J<�U��ޯo$� �9Z~qJ�@���@����H���N֭$xݢ�M�^�o��/��uZ�0�k�iĞ�|߹�g�zF� �Y�k?��v�t*�yK �@I�������\��:��b��{���2���9��q kA�ݷv4B���q������'w���BU�-d�Q�R)��)*�O`����K�E|���n���:�m���T<]^FU"/A��HH�O�t�OA����爩aɔq�?M[�����h�xз6Y�%j�u�����K���#kJ�%}s�фb�����j҇��"��*9B,�2�X/�� �03�O��S�Vv���SZ|�gXEc+�ő�M�y�p��� �C>�K���3i���q��W��+��S�z��шd|��fL���
at com.android.okhttp.internal.http.StatusLine.parse(StatusLine.java:56)
at com.android.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:188)
at com.android.okhttp.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:129)
at com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:770)
at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:642)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:475)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:542)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:550)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:367)
... 7 more
2024-04-12 17:36:41.081 24291-24291 IVideoPlayer com.android.player E onError,what:2001,extra:0,reCount:0
2024-04-12 17:36:41.081 24291-24291 BasePlayer com.android.player D onPlayerState-->state:STATE_ERROR,message:2001
2024-04-12 17:36:41.090 24291-24291 DecorView[] com.android.player D getWindowModeFromSystem windowmode is 1
//播放出现上诉问题
mVideoPlayer.setDataSource(VideoCache.getInstance().getPlayUrl(mUrl));
//这种方式播放没有问题
mVideoPlayer.setDataSource(mUrl);
应该是缓存实现有问题。
如何播放本地TF卡里面的音视频文件?我将本地TF卡里面的音视频文件路径通过setDataSource()方法设置,然后异步加载播放,但是没有能成功播放。
你好,我发现ijk有些直链播放不了,系统内核和Exo内核可以播放,Ijk内核播放不了,比如这个链接,另外Ijk内核播放视频一跳一跳的,一下子跳一段
https://s5.bfbfvip.com/video/bailianchengshen/第57集/index.m3u8
提示这个: 播放失败,请检查视频文件地址有效性
我目前用的gsy,看了iplayer感觉很不错,无缝转场、全局悬浮、预缓存都比gsy强。不过有几点小建议
1、文档说明增加exo版本号说明
2、BasePlayer关于生命周期的控制可以用Lifecycle,目前有很多都是在baseActivity实现
3、demo中悬浮窗在手指拖动的第一时间位置会往下跳动,悬浮窗功能没必要内置在BasePlayer。悬浮窗不属于播放器的功能,只需提供demo。悬浮窗的适配也会占用大量的精力。
4、横竖屏UI布局 gsy是提供了两套布局
5、对于自定义布局 各种ControlView 感觉不太直观
感觉开源这么好的框架👍
感觉这个库应该是无需大幅度自定义UI的情况下上手最简单的了,有两个不理解
看文档写的toolBarView.showMenus(true,true,true);//是否显示投屏\悬浮窗\功能等按钮,仅限竖屏情况下,横屏模式下强制不显示。但是拉伸倍速这些功能全屏不也会用到吗。
另有没有方法可以在SDK提供的标题栏上面额外增加一些自定义按钮呢,譬如截图、下载等
主要按demo调用以下方法播放视频:
mVideoPlayer.setOnPlayerActionListener(new OnPlayerEventListener() {
@OverRide
public AbstractMediaPlayer createMediaPlayer() {
Log.e("TAG","mCurrentMediaCore="+mCurrentMediaCore+" url="+mUrl);
if (1 == mCurrentMediaCore) {
return IjkPlayerFactory.create().createPlayer(context);//IJK解码器
} else if (2 == mCurrentMediaCore) {
return ExoPlayerFactory.create().createPlayer(context);//EXO解码器
} else {
return null;//播放器内部默认的
}
}
public void start(String url) {
if (null != mVideoPlayer) {
this.mUrl=url;
mVideoPlayer.setLoop(false);
mVideoPlayer.setZoomModel(IMediaPlayer.MODE_ZOOM_CROPPING);
mVideoPlayer.setProgressCallBackSpaceTime(300);
mVideoPlayer.getController().setTitle("测试播放地址");//视频标题(默认视图控制器横屏可见)
mVideoPlayer.setDataSource(TextUtils.isEmpty(url)? PATH :url);//播放地址设置
mVideoPlayer.prepareAsync();//开始异步准备播放
}
}
报错信息如下:
E/IJKMEDIA: SDL_JNI_ThreadDestroyed: [28526] didn't call SDL_JNI_DetachThreadEnv() explicity
E/IJKMEDIA: error:00000000:lib(0):func(0):reason(0)
E/IJKMEDIA: https://service.easytaxi.hk:9085/live/00000000018003466468_2.live.ts: I/O error
E/tv.danmaku.ijk.media.player.IjkMediaPlayer: Error (-10000,0)
E/IVideoPlayer: onError,what:-10000,extra:0,reCount:1
我用dlna功能分别拿到b站安卓端和苹果端的直播视频的链接,然后在该应用的 SDK默认播放器示例 -> 测试播放地址 中填入并播放,得到如下情况:
1、ijkplayer 无法播放安卓端和苹果端的链接;
2、exoplayer 可以播放安卓端的链接,但无法播放苹果端的链接。
下面是第1种情况的log:
D/IJKMEDIA: IjkMediaPlayer_setVideoSurface
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)
D/IJKMEDIA: ffpipeline_set_surface()
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)=void
D/IJKMEDIA: IjkMediaPlayer_setVideoSurface
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)
D/IJKMEDIA: ffpipeline_set_surface()
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)=void
D/IJKMEDIA: IjkMediaPlayer_release
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)
D/IJKMEDIA: ffpipeline_set_surface()
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)=void
D/IJKMEDIA: ijkmp_shutdown_l()
D/IJKMEDIA: message_loop exit
I/IJKMEDIA: SDL_JNI_DetachThreadEnv: [4834]
D/BasePlayer: onPlayerState-->state:STATE_RESET,message:结束播放并重置
I/IJKMEDIA: SDL_JNI_DetachThreadEnv: [4835]
D/IJKMEDIA: ijkmp_shutdown_l()=void
D/IJKMEDIA: ijkmp_dec_ref(): ref=0
D/IJKMEDIA: ijkmp_shutdown_l()
D/IJKMEDIA: ijkmp_shutdown_l()=void
E/IJKMEDIA: SDL_JNI_ThreadDestroyed: [4846] didn't call SDL_JNI_DetachThreadEnv() explicity
D/IJKMEDIA: IjkMediaPlayer_native_setup
I/IJKMEDIA: av_version_info: ff4.0--ijk0.8.8--20210426--001
I/IJKMEDIA: ijk_version_info: k0.8.8-44-g15914708
D/IJKMEDIA: ffpipeline_create_from_android()
D/IJKMEDIA: ijkmp_set_inject_opaque(0x29c6)
D/IJKMEDIA: ijkmp_set_inject_opaque()=void
D/IJKMEDIA: ijkmp_set_ijkio_inject_opaque(0x29c6)
D/IJKMEDIA: ijkmp_set_ijkio_inject_opaque()=void
D/IJKMEDIA: ijkmp_android_set_mediacodec_select_callback()
D/IJKMEDIA: ffpipeline_set_mediacodec_select_callback
D/IJKMEDIA: ijkmp_android_set_mediacodec_select_callback()=void
D/IJKMEDIA: IjkMediaPlayer_setOptionLong
I/chatty: uid=10104(com.android.videoplayer) identical 4 lines
D/IJKMEDIA: IjkMediaPlayer_setOptionLong
D/IVideoPlayer: 解码器内核:IJkMediaPlayer
D/IJKMEDIA: IjkMediaPlayer_setOptionLong
D/IJKMEDIA: IjkMediaPlayer_setLoopCount
D/IJKMEDIA: IjkMediaPlayer_setVolume
D/IJKMEDIA: ijkmp_android_set_volume(1.000000, 1.000000)
D/IJKMEDIA: ffpipeline_set_volume
D/IJKMEDIA: ijkmp_android_set_volume(1.000000, 1.000000)=void
D/IJKMEDIA: IjkMediaPlayer_setOptionLong
D/IJKMEDIA: IjkMediaPlayer_setOptionLong
D/IVideoPlayer: 渲染器内核:MediaTextureView
D/BasePlayer: onPlayerState-->state:STATE_PREPARE,message:播放准备中
D/IJKMEDIA: IjkMediaPlayer_setDataSourceAndHeaders
V/IJKMEDIA: setDataSource: path http://14.17.92.17/live-bvc/944383/live_1575476_4103998_1500.flv?expires=1669776067&pt=android&deadline=1669776067&len=0&oi=2004595674&platform=android&qn=64&trid=1000acd8cf4dab72492c8c13851c49b38ea9&uipk=100&uipv=100&nbs=1&uparams=cdn,deadline,len,oi,platform,qn,trid,uipk,uipv,nbs&cdn=cn-gotcha01&upsig=babf3035e77968260285434d2d369223&sk=1304f646dfeb4df8b6e7ff33c167d3ad74346564118ee355b45f1e0db5f3b4f0&p2p_type=8192&src=57345&sl=1&free_type=0&sid=cn-gddg-ct-01-16&chash=1&sche=ban&score=13&usgroup=eg&pp=srt&machinezone=ylf&source=onetier&trace=0&site=d807caf6904404b88cffbdc8cd63275c&order=1&bili_room_id=821119&_nva_ext_=
D/IJKMEDIA: ijkmp_set_data_source(url="http://14.17.92.17/live-bvc/944383/live_1575476_4103998_1500.flv?expires=1669776067&pt=android&deadline=1669776067&len=0&oi=2004595674&platform=android&qn=64&trid=1000acd8cf4dab72492c8c13851c49b38ea9&uipk=100&uipv=100&nbs=1&uparams=cdn,deadline,len,oi,platform,qn,trid,uipk,uipv,nbs&cdn=cn-gotcha01&upsig=babf3035e77968260285434d2d369223&sk=1304f646dfeb4df8b6e7ff33c167d3ad74346564118ee355b45f1e0db5f3b4f0&p2p_type=8192&src=57345&sl=1&free_type=0&sid=cn-gddg-ct-01-16&chash=1&sche=ban&score=13&usgroup=eg&pp=srt&machinezone=ylf&source=onetier&trace=0&site=d807caf6904404b88cffbdc8cd63275c&order=1&bili_room_id=821119&_nva_ext_=")
2022-11-30 09:41:34.014 4671-4671/com.android.videoplayer D/IJKMEDIA: ijkmp_set_data_source(url="http://14.17.92.17/live-bvc/944383/live_1575476_4103998_1500.flv?expires=1669776067&pt=android&deadline=1669776067&len=0&oi=2004595674&platform=android&qn=64&trid=1000acd8cf4dab72492c8c13851c49b38ea9&uipk=100&uipv=100&nbs=1&uparams=cdn,deadline,len,oi,platform,qn,trid,uipk,uipv,nbs&cdn=cn-gotcha01&upsig=babf3035e77968260285434d2d369223&sk=1304f646dfeb4df8b6e7ff33c167d3ad74346564118ee355b45f1e0db5f3b4f0&p2p_type=8192&src=57345&sl=1&free_type=0&sid=cn-gddg-ct-01-16&chash=1&sche=ban&score=13&usgroup=eg&pp=srt&machinezone=ylf&source=onetier&trace=0&site=d807caf6904404b88cffbdc8cd63275c&order=1&bili_room_id=821119&_nva_ext_=")=0
D/IVideoPlayer: startPlayer-->source:http://14.17.92.17/live-bvc/944383/live_1575476_4103998_1500.flv?expires=1669776067&pt=android&deadline=1669776067&len=0&oi=2004595674&platform=android&qn=64&trid=1000acd8cf4dab72492c8c13851c49b38ea9&uipk=100&uipv=100&nbs=1&uparams=cdn,deadline,len,oi,platform,qn,trid,uipk,uipv,nbs&cdn=cn-gotcha01&upsig=babf3035e77968260285434d2d369223&sk=1304f646dfeb4df8b6e7ff33c167d3ad74346564118ee355b45f1e0db5f3b4f0&p2p_type=8192&src=57345&sl=1&free_type=0&sid=cn-gddg-ct-01-16&chash=1&sche=ban&score=13&usgroup=eg&pp=srt&machinezone=ylf&source=onetier&trace=0&site=d807caf6904404b88cffbdc8cd63275c&order=1&bili_room_id=821119&_nva_ext_=
D/IJKMEDIA: IjkMediaPlayer_prepareAsync
D/IJKMEDIA: ijkmp_prepare_async()
I/IJKMEDIA: ===== versions =====
I/IJKMEDIA: ijkplayer : k0.8.8-44-g15914708
I/IJKMEDIA: FFmpeg : ff4.0--ijk0.8.8--20210426--001
I/IJKMEDIA: libavutil : 56.14.100
I/IJKMEDIA: libavcodec : 58.18.100
I/IJKMEDIA: libavformat : 58.12.100
I/IJKMEDIA: libswscale : 5.1.100
I/IJKMEDIA: libswresample: 3.1.100
I/IJKMEDIA: ===== options =====
I/IJKMEDIA: player-opts : enable-accurate-seek = 1
I/IJKMEDIA: player-opts : mediacodec = 0
I/IJKMEDIA: player-opts : mediacodec-auto-rotate = 0
I/IJKMEDIA: player-opts : mediacodec-handle-resolution-change = 0
I/IJKMEDIA: player-opts : reconnect = 30
I/IJKMEDIA: player-opts : loop = 1
I/IJKMEDIA: format-opts : ijkapplication = 0x6f683650a0
I/IJKMEDIA: format-opts : ijkiomanager = 0x6f0f8b8800
I/IJKMEDIA: format-opts : probesize = 200
I/IJKMEDIA: format-opts : analyzemaxduration = 15000
I/IJKMEDIA: format-opts : timeout = 10000
I/IJKMEDIA: ===================
I/IJKMEDIA: SDL_RunThread: [4853] ff_msg_loop
D/IJKMEDIA: message_loop
D/IJKMEDIA: ijkmp_prepare_async()=0
D/IJKMEDIA: FFP_MSG_FLUSH:
I/IJKMEDIA: SDL_RunThread: [4854] ff_vout
I/IJKMEDIA: SDL_RunThread: [4855] ff_read
I/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 1
I/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 131073
D/IJKMEDIA: IjkMediaPlayer_setVideoSurface
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x7fc72627c8)
D/IJKMEDIA: ffpipeline_set_surface()
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x7fc72627c8)=void
I/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 131074
I/IJKMEDIA: tcp did open uri = tcp://14.17.92.17:80, ip = 14.17.92.17
W/IJKMEDIA: HTTP error 403 Forbidden
I/tv.danmaku.ijk.media.player.IjkMediaPlayer: onNativeInvoke 2
E/IJKMEDIA: http://14.17.92.17/live-bvc/944383/live_1575476_4103998_1500.flv?expires=1669776067&pt=android&deadline=1669776067&len=0&oi=2004595674&platform=android&qn=64&trid=1000acd8cf4dab72492c8c13851c49b38ea9&uipk=100&uipv=100&nbs=1&uparams=cdn,deadline,len,oi,platform,qn,trid,uipk,uipv,nbs&cdn=cn-gotcha01&upsig=babf3035e77968260285434d2d369223&sk=1304f646dfeb4df8b6e7ff33c167d3ad74346564118ee355b45f1e0db5f3b4f0&p2p_type=8192&src=57345&sl=1&free_type=0&sid=cn-gddg-ct-01-16&chash=1&sche=ban&score=13&usgroup=eg&pp=srt&machinezone=ylf&source=onetier&trace=0&site=d807caf6904404b88cffbdc8cd63275c&order=1&bili_room_id=821119&_nva_ext_=: Server returned 403 Forbidden (access denied)
I/IJKMEDIA: SDL_JNI_DetachThreadEnv: [4855]
D/IJKMEDIA: FFP_MSG_ERROR: 0
E/tv.danmaku.ijk.media.player.IjkMediaPlayer: Error (-10000,0)
E/IVideoPlayer: onError,what:-10000,extra:0,reCount:0
D/IJKMEDIA: IjkMediaPlayer_setVideoSurface
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)
D/IJKMEDIA: ffpipeline_set_surface()
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)=void
D/IJKMEDIA: IjkMediaPlayer_setVideoSurface
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)
D/IJKMEDIA: ffpipeline_set_surface()
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)=void
D/IJKMEDIA: IjkMediaPlayer_release
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)
D/IJKMEDIA: ffpipeline_set_surface()
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)=void
D/IJKMEDIA: ijkmp_shutdown_l()
D/IJKMEDIA: message_loop exit
I/IJKMEDIA: SDL_JNI_DetachThreadEnv: [4853]
I/IJKMEDIA: SDL_JNI_DetachThreadEnv: [4854]
D/IJKMEDIA: ijkmp_shutdown_l()=void
D/IJKMEDIA: ijkmp_dec_ref(): ref=0
D/IJKMEDIA: ijkmp_shutdown_l()
D/IJKMEDIA: ijkmp_shutdown_l()=void
以下是第2中情况的log:
D/IJKMEDIA: IjkMediaPlayer_setVideoSurface
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)
D/IJKMEDIA: ffpipeline_set_surface()
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)=void
D/IJKMEDIA: IjkMediaPlayer_setVideoSurface
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)
D/IJKMEDIA: ffpipeline_set_surface()
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)=void
D/BasePlayer: onPlayerState-->state:STATE_RESET,message:结束播放并重置
D/IJKMEDIA: IjkMediaPlayer_release
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)
D/IJKMEDIA: ffpipeline_set_surface()
D/IJKMEDIA: ijkmp_set_android_surface(surface=0x0)=void
D/IJKMEDIA: ijkmp_shutdown_l()
D/IJKMEDIA: message_loop exit
I/IJKMEDIA: SDL_JNI_DetachThreadEnv: [6202]
I/IJKMEDIA: SDL_JNI_DetachThreadEnv: [6203]
D/IJKMEDIA: ijkmp_shutdown_l()=void
D/IJKMEDIA: ijkmp_dec_ref(): ref=0
D/IJKMEDIA: ijkmp_shutdown_l()
D/IJKMEDIA: ijkmp_shutdown_l()=void
E/IJKMEDIA: SDL_JNI_ThreadDestroyed: [6221] didn't call SDL_JNI_DetachThreadEnv() explicity
I/ExoPlayerImpl: Init 91e5b09 [ExoPlayerLib/2.18.1] [ktc, 32A11FWT, ktc, 29]
D/IVideoPlayer: 解码器内核:ExoMediaPlayer
D/IVideoPlayer: 渲染器内核:MediaTextureView
D/BasePlayer: onPlayerState-->state:STATE_PREPARE,message:播放准备中
D/IVideoPlayer: startPlayer-->source:http://114.230.222.86/live-bvc/787738/live_22353137_33999663_1500.flv?expires=1669777141&pt=ios&deadline=1669777141&len=0&oi=2004595674&platform=ios&qn=64&trid=100062b35cff31544da899181a775ff2f9d1&uipk=100&uipv=100&nbs=1&uparams=cdn,deadline,len,oi,platform,qn,trid,uipk,uipv,nbs&cdn=cn-gotcha01&upsig=775997e84d823acda21477ef1b20972f&sk=1304f646dfeb4df8b6e7ff33c167d3ad1f8dbd69d43da9418e30b9b2fe3a2407&p2p_type=8192&src=57345&sl=1&free_type=0&sid=cn-jsyz-ct-03-49&chash=1&sche=ban&score=6&usgroup=eg&pp=rtmp&machinezone=ylf&source=onetier&trace=8&site=a2e57cfed9704751a87ea828a34cfe31&order=1&bili_room_id=24476863&_nva_ext_=
D/BasePlayer: onPlayerState-->state:STATE_BUFFER,message:缓冲开始
E/ExoPlayerImplInternal: Playback error
com.google.android.exoplayer2.ExoPlaybackException: Source error
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:632)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:604)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:404)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:258)
at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1005)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
E/IVideoPlayer: onError,what:2004,extra:0,reCount:0
D/BasePlayer: onPlayerState-->state:STATE_ERROR,message:2004
请问该如何解决?
集成了1.0.4.3版本的SDK,发现手势左右滑动快进快退时,总时长显示不正确。
具体就是BaseVideoPlayer-》startFullScreen-》appCompActivity获取为空
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.