From bb2bf19b563826092e71532bceef3f1c96551781 Mon Sep 17 00:00:00 2001 From: jiajunhui <13579abc,./> Date: Tue, 4 Aug 2020 11:01:20 +0800 Subject: [PATCH] publish 3.3.7 --- README.md | 6 +++--- .../taurus/avplayer/ui/MusicPlayActivity.java | 11 +++++------ build.gradle | 5 ++++- exoplayer/bintray.gradle | 2 +- exoplayer/build.gradle | 4 ++-- .../kk/taurus/exoplayer/ExoMediaPlayer.java | 17 ++++++++++++----- ijkplayer/bintray.gradle | 2 +- ijkplayer/build.gradle | 4 ++-- .../com/kk/taurus/ijkplayer/IjkPlayer.java | 19 +++++++++++++++++++ playerbase/bintray.gradle | 2 +- 10 files changed, 50 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index e61687b5..dbee8ac2 100644 --- a/README.md +++ b/README.md @@ -82,18 +82,18 @@ demo示例集成了播放控制组件**ControllerCover**、加载中组件**Load dependencies { //---------如果仅使用MediaPlayer解码,使用以下依赖。---------- //该依赖仅包含MediaPlayer解码 - implementation 'com.kk.taurus.playerbase:playerbase:3.3.6' + implementation 'com.kk.taurus.playerbase:playerbase:3.3.7' //---------如果使用ExoPlayer解码,使用以下依赖。--------- //该依赖包含exoplayer解码和MediaPlayer解码 //注意exoplayer的最小支持SDK版本为16 - implementation 'cn.jiajunhui:exoplayer:336_2111_011' + implementation 'cn.jiajunhui:exoplayer:337_2117_012' //---------如果使用ijkPlayer解码,使用以下依赖。--------- //该依赖包含ijkplayer解码和MediaPlayer解码 - implementation 'cn.jiajunhui:ijkplayer:336_088_007' + implementation 'cn.jiajunhui:ijkplayer:337_088_008' //ijk官方的解码库依赖,较少格式版本且不支持HTTPS。 implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8' # Other ABIs: optional diff --git a/app/src/main/java/com/kk/taurus/avplayer/ui/MusicPlayActivity.java b/app/src/main/java/com/kk/taurus/avplayer/ui/MusicPlayActivity.java index 3b7cd6c5..254407ff 100644 --- a/app/src/main/java/com/kk/taurus/avplayer/ui/MusicPlayActivity.java +++ b/app/src/main/java/com/kk/taurus/avplayer/ui/MusicPlayActivity.java @@ -19,6 +19,9 @@ import com.kk.taurus.playerbase.event.OnErrorEventListener; import com.kk.taurus.playerbase.event.OnPlayerEventListener; +/** + * 音乐播放示例 + */ public class MusicPlayActivity extends AppCompatActivity implements OnPlayerEventListener { private AVPlayer mPlayer; @@ -57,16 +60,12 @@ public void onErrorEvent(int eventCode, Bundle bundle) { }); initMusicWave(); + updateVisualizer(); } @Override public void onPlayerEvent(int eventCode, Bundle bundle) { - switch (eventCode){ - case OnPlayerEventListener.PLAYER_EVENT_ON_PREPARED: - releaseVisualizer(); - updateVisualizer(); - break; - } + } private void initMusicWave() { diff --git a/build.gradle b/build.gradle index 9e9ea450..4a8193ee 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,10 @@ project.ext { ijksdkVersion = '0.8.8', exoplayersdkVersion = '2.11.7', appcompatVersion = '1.1.0', - playerbaseVersion = '3.3.6' + + playerbaseIjkVersion = '337_088_008', + playerbaseExoVersion = '337_2117_012', + playerbaseVersion = '3.3.7' ] } \ No newline at end of file diff --git a/exoplayer/bintray.gradle b/exoplayer/bintray.gradle index fd403737..5f4d3235 100644 --- a/exoplayer/bintray.gradle +++ b/exoplayer/bintray.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' // 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version -version = "336_2111_011" +version = rootProject.ext.playerbaseExoVersion def siteUrl = 'https://github.com/jiajunhui/PlayerBase' // 项目的主页 def gitUrl = 'https://github.com/jiajunhui/PlayerBase.git' // Git仓库的url diff --git a/exoplayer/build.gradle b/exoplayer/build.gradle index cc423ea9..a9c66f6a 100644 --- a/exoplayer/build.gradle +++ b/exoplayer/build.gradle @@ -34,6 +34,6 @@ dependencies { api "com.google.android.exoplayer:exoplayer-dash:$exoplayersdkVersion" api "com.google.android.exoplayer:exoplayer-hls:$exoplayersdkVersion" api "com.google.android.exoplayer:exoplayer-smoothstreaming:$exoplayersdkVersion" -// api "com.kk.taurus.playerbase:playerbase:$playerbaseVersion" - api project(':playerbase') + api "com.kk.taurus.playerbase:playerbase:$playerbaseVersion" +// api project(':playerbase') } \ No newline at end of file diff --git a/exoplayer/src/main/java/com/kk/taurus/exoplayer/ExoMediaPlayer.java b/exoplayer/src/main/java/com/kk/taurus/exoplayer/ExoMediaPlayer.java index d2259c47..035e5372 100644 --- a/exoplayer/src/main/java/com/kk/taurus/exoplayer/ExoMediaPlayer.java +++ b/exoplayer/src/main/java/com/kk/taurus/exoplayer/ExoMediaPlayer.java @@ -34,6 +34,7 @@ import com.google.android.exoplayer2.source.ExtractorMediaSource; import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MergingMediaSource; +import com.google.android.exoplayer2.source.ProgressiveMediaSource; import com.google.android.exoplayer2.source.SingleSampleMediaSource; import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.dash.DashMediaSource; @@ -210,7 +211,7 @@ private MediaSource getMediaSource(Uri uri, com.google.android.exoplayer2.upstre case C.TYPE_OTHER: default: // This is the MediaSource representing the media to be played. - return new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(uri); + return new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(uri); } } @@ -482,17 +483,23 @@ public void onPlayerError(ExoPlaybackException error) { submitErrorEvent(OnErrorEventListener.ERROR_EVENT_UNKNOWN, null); return; } - PLog.e(TAG,error.getMessage()==null?"":error.getMessage()); + String errorMessage = error.getMessage()==null?"":error.getMessage(); + Throwable cause = error.getCause(); + String causeMessage = cause!=null?cause.getMessage():""; + PLog.e(TAG,errorMessage + ", causeMessage = " + causeMessage); + Bundle bundle = BundlePool.obtain(); + bundle.putString("errorMessage", errorMessage); + bundle.putString("causeMessage", causeMessage); int type = error.type; switch (type){ case ExoPlaybackException.TYPE_SOURCE: - submitErrorEvent(OnErrorEventListener.ERROR_EVENT_IO, null); + submitErrorEvent(OnErrorEventListener.ERROR_EVENT_IO, bundle); break; case ExoPlaybackException.TYPE_RENDERER: - submitErrorEvent(OnErrorEventListener.ERROR_EVENT_COMMON, null); + submitErrorEvent(OnErrorEventListener.ERROR_EVENT_COMMON, bundle); break; case ExoPlaybackException.TYPE_UNEXPECTED: - submitErrorEvent(OnErrorEventListener.ERROR_EVENT_UNKNOWN, null); + submitErrorEvent(OnErrorEventListener.ERROR_EVENT_UNKNOWN, bundle); break; } } diff --git a/ijkplayer/bintray.gradle b/ijkplayer/bintray.gradle index 135eabeb..f0d54c5e 100644 --- a/ijkplayer/bintray.gradle +++ b/ijkplayer/bintray.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' // 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version -version = "336_088_007" +version = rootProject.ext.playerbaseIjkVersion def siteUrl = 'https://github.com/jiajunhui/PlayerBase' // 项目的主页 def gitUrl = 'https://github.com/jiajunhui/PlayerBase.git' // Git仓库的url diff --git a/ijkplayer/build.gradle b/ijkplayer/build.gradle index 303f7e48..b76fdbb5 100644 --- a/ijkplayer/build.gradle +++ b/ijkplayer/build.gradle @@ -31,6 +31,6 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') api "tv.danmaku.ijk.media:ijkplayer-java:$ijksdkVersion" -// api "com.kk.taurus.playerbase:playerbase:$playerbaseVersion" - api project(':playerbase') + api "com.kk.taurus.playerbase:playerbase:$playerbaseVersion" +// api project(':playerbase') } diff --git a/ijkplayer/src/main/java/com/kk/taurus/ijkplayer/IjkPlayer.java b/ijkplayer/src/main/java/com/kk/taurus/ijkplayer/IjkPlayer.java index 8d3f4619..dde6482b 100644 --- a/ijkplayer/src/main/java/com/kk/taurus/ijkplayer/IjkPlayer.java +++ b/ijkplayer/src/main/java/com/kk/taurus/ijkplayer/IjkPlayer.java @@ -24,6 +24,7 @@ import com.kk.taurus.playerbase.player.BaseInternalPlayer; import java.util.HashMap; +import java.util.Set; import tv.danmaku.ijk.media.player.IMediaPlayer; import tv.danmaku.ijk.media.player.IjkMediaPlayer; @@ -62,6 +63,24 @@ public IjkPlayer() { IjkMediaPlayer.native_profileBegin("libijkplayer.so"); } + /** + * ijkplayer的配置项设置 + * ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 1); + * + * @param code 对应setOption方法的第一个参数 + * @param bundle 对应第二个和第三个参数,key为配置项的名称,比如mediacodec,value为对应的配置值(long类型) + */ + @Override + public void option(int code, Bundle bundle) { + super.option(code, bundle); + if(bundle!=null){ + Set keySet = bundle.keySet(); + for(String key : keySet){ + mMediaPlayer.setOption(code, key, bundle.getLong(key)); + } + } + } + protected IjkMediaPlayer createPlayer(){ IjkMediaPlayer ijkMediaPlayer = new IjkMediaPlayer(); // ijkMediaPlayer.native_setLogLevel(IjkMediaPlayer.IJK_LOG_DEBUG); diff --git a/playerbase/bintray.gradle b/playerbase/bintray.gradle index 2356ccdc..26ce1a2f 100644 --- a/playerbase/bintray.gradle +++ b/playerbase/bintray.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' // 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version -version = "3.3.6" +version = rootProject.ext.playerbaseVersion def siteUrl = 'https://github.com/jiajunhui/PlayerBase' // 项目的主页 def gitUrl = 'https://github.com/jiajunhui/PlayerBase.git' // Git仓库的url