diff --git a/PLDroidPlayerDemo/app/build.gradle b/PLDroidPlayerDemo/app/build.gradle
index 24c5f1a..50fa023 100644
--- a/PLDroidPlayerDemo/app/build.gradle
+++ b/PLDroidPlayerDemo/app/build.gradle
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 23
- buildToolsVersion "24.0.0 rc1"
+ compileSdkVersion 22
+ buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.pili.pldroid.playerdemo"
minSdkVersion 9
- targetSdkVersion 23
+ targetSdkVersion 22
versionCode 1
versionName "1.0"
}
@@ -20,6 +20,7 @@ android {
}
dependencies {
- compile 'com.android.support:design:23.2.1'
- compile files('libs/pldroid-player-1.2.3.jar')
+ compile 'com.android.support:appcompat-v7:22+'
+ compile files('libs/pldroid-player-1.3.0.jar')
+ compile 'com.qiniu:happy-dns:0.2.+'
}
diff --git a/PLDroidPlayerDemo/app/libs/pldroid-player-1.2.3.jar b/PLDroidPlayerDemo/app/libs/pldroid-player-1.3.0.jar
similarity index 63%
rename from PLDroidPlayerDemo/app/libs/pldroid-player-1.2.3.jar
rename to PLDroidPlayerDemo/app/libs/pldroid-player-1.3.0.jar
index f38549c..25748e0 100644
Binary files a/PLDroidPlayerDemo/app/libs/pldroid-player-1.2.3.jar and b/PLDroidPlayerDemo/app/libs/pldroid-player-1.3.0.jar differ
diff --git a/PLDroidPlayerDemo/app/src/main/AndroidManifest.xml b/PLDroidPlayerDemo/app/src/main/AndroidManifest.xml
index cdacbcc..43145d9 100644
--- a/PLDroidPlayerDemo/app/src/main/AndroidManifest.xml
+++ b/PLDroidPlayerDemo/app/src/main/AndroidManifest.xml
@@ -5,6 +5,7 @@
+
adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, TEST_ACTIVITY_ARRAY);
mActivitySpinner.setAdapter(adapter);
}
- public void onClickPlaySetting(View v) {
- showPlaySettingDialog();
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ PLNetworkManager.getInstance().stopDnsCacheService(this);
}
public void onClickLocalFile(View v) {
@@ -77,7 +94,16 @@ public void jumpToPlayerActivity(String videopath) {
}
Intent intent = new Intent(this, cls);
intent.putExtra("videoPath", videopath);
- intent.putExtra("mediaCodec", mIsHwCodecEnabled);
+ if (mDecodeTypeRadioGroup.getCheckedRadioButtonId() == R.id.RadioHWDecode) {
+ intent.putExtra("mediaCodec", 1);
+ } else {
+ intent.putExtra("mediaCodec", 0);
+ }
+ if (mStreamingTypeRadioGroup.getCheckedRadioButtonId() == R.id.RadioLiveStreaming) {
+ intent.putExtra("liveStreaming", 1);
+ } else {
+ intent.putExtra("liveStreaming", 0);
+ }
startActivity(intent);
}
@@ -89,32 +115,4 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String videoPath = data.getStringExtra("videoPath");
mEditText.setText(videoPath, TextView.BufferType.EDITABLE);
}
-
- protected void showPlaySettingDialog() {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- final View root = inflater.inflate(R.layout.dialog_setting,null);
- final Spinner codecSpinner = (Spinner) root.findViewById(R.id.CodecSpinner);
- codecSpinner.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, new String[] {
- getString(R.string.sw_decode), getString(R.string.hw_decode)
- }));
- codecSpinner.setSelection(mIsHwCodecEnabled);
- builder.setTitle(getString(R.string.play_setting));
- builder.setView(root);
- final AlertDialog dialog = builder.create();
- dialog.setCancelable(false);
- dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.dlg_ok), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- mIsHwCodecEnabled = codecSpinner.getSelectedItemPosition();
- }
- });
- dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.dlg_cancel), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
-
- }
- });
- dialog.show();
- }
}
diff --git a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLAudioPlayerActivity.java b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLAudioPlayerActivity.java
index bfd3df0..a685afa 100644
--- a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLAudioPlayerActivity.java
+++ b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLAudioPlayerActivity.java
@@ -173,6 +173,12 @@ public boolean onError(PLMediaPlayer mp, int errorCode) {
break;
case PLMediaPlayer.ERROR_CODE_STREAM_DISCONNECTED:
break;
+ case PLMediaPlayer.ERROR_CODE_UNAUTHORIZED:
+ break;
+ case PLMediaPlayer.ERROR_CODE_PREPARE_TIMEOUT:
+ break;
+ case PLMediaPlayer.ERROR_CODE_READ_FRAME_TIMEOUT:
+ break;
case PLMediaPlayer.MEDIA_ERROR_UNKNOWN:
break;
default:
diff --git a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLMediaPlayerActivity.java b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLMediaPlayerActivity.java
index e87213e..f5d7810 100644
--- a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLMediaPlayerActivity.java
+++ b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLMediaPlayerActivity.java
@@ -51,12 +51,14 @@ protected void onCreate(Bundle savedInstanceState) {
mAVOptions = new AVOptions();
- if (isLiveStreaming(mVideoPath)) {
- // the unit of timeout is ms
- mAVOptions.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, 10 * 1000);
- mAVOptions.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, 10 * 1000);
- // Some optimization with buffering mechanism when be set to 1
- mAVOptions.setInteger(AVOptions.KEY_LIVE_STREAMING, 1);
+ int isLiveStreaming = getIntent().getIntExtra("liveStreaming", 1);
+ // the unit of timeout is ms
+ mAVOptions.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, 10 * 1000);
+ mAVOptions.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, 10 * 1000);
+ // Some optimization with buffering mechanism when be set to 1
+ mAVOptions.setInteger(AVOptions.KEY_LIVE_STREAMING, isLiveStreaming);
+ if (isLiveStreaming == 1) {
+ mAVOptions.setInteger(AVOptions.KEY_DELAY_OPTIMIZATION, 1);
}
// 1 -> hw codec enable, 0 -> disable [recommended]
@@ -116,6 +118,7 @@ public void onClickStop(View v) {
mMediaPlayer.reset();
}
mIsStopped = true;
+ mMediaPlayer = null;
}
public void releaseWithoutStop() {
@@ -283,6 +286,15 @@ public boolean onError(PLMediaPlayer mp, int errorCode) {
case PLMediaPlayer.ERROR_CODE_IO_ERROR:
showToastTips("Network IO Error !");
break;
+ case PLMediaPlayer.ERROR_CODE_UNAUTHORIZED:
+ showToastTips("Unauthorized Error !");
+ break;
+ case PLMediaPlayer.ERROR_CODE_PREPARE_TIMEOUT:
+ showToastTips("Prepare timeout !");
+ break;
+ case PLMediaPlayer.ERROR_CODE_READ_FRAME_TIMEOUT:
+ showToastTips("Read frame timeout !");
+ break;
case PLMediaPlayer.MEDIA_ERROR_UNKNOWN:
default:
showToastTips("unknown error !");
@@ -316,13 +328,4 @@ public void run() {
}
});
}
-
- private boolean isLiveStreaming(String url) {
- if (url.startsWith("rtmp://")
- || (url.startsWith("http://") && url.endsWith(".m3u8"))
- || (url.startsWith("http://") && url.endsWith(".flv"))) {
- return true;
- }
- return false;
- }
}
diff --git a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoTextureActivity.java b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoTextureActivity.java
index 0531350..57a1587 100644
--- a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoTextureActivity.java
+++ b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoTextureActivity.java
@@ -48,12 +48,14 @@ protected void onCreate(Bundle savedInstanceState) {
AVOptions options = new AVOptions();
- if (isLiveStreaming(mVideoPath)) {
- // the unit of timeout is ms
- options.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, 10 * 1000);
- options.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, 10 * 1000);
- // Some optimization with buffering mechanism when be set to 1
- options.setInteger(AVOptions.KEY_LIVE_STREAMING, 1);
+ int isLiveStreaming = getIntent().getIntExtra("liveStreaming", 1);
+ // the unit of timeout is ms
+ options.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, 10 * 1000);
+ options.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, 10 * 1000);
+ // Some optimization with buffering mechanism when be set to 1
+ options.setInteger(AVOptions.KEY_LIVE_STREAMING, isLiveStreaming);
+ if (isLiveStreaming == 1) {
+ options.setInteger(AVOptions.KEY_DELAY_OPTIMIZATION, 1);
}
// 1 -> hw codec enable, 0 -> disable [recommended]
@@ -69,7 +71,7 @@ protected void onCreate(Bundle savedInstanceState) {
// mVideoView.setMirror(true);
// You can also use a custom `MediaController` widget
- mMediaController = new MediaController(this, false, isLiveStreaming(mVideoPath));
+ mMediaController = new MediaController(this, false, isLiveStreaming == 1);
mVideoView.setMediaController(mMediaController);
mVideoView.setOnCompletionListener(mOnCompletionListener);
@@ -152,6 +154,15 @@ public boolean onError(PLMediaPlayer mp, int errorCode) {
case PLMediaPlayer.ERROR_CODE_IO_ERROR:
showToastTips("Network IO Error !");
break;
+ case PLMediaPlayer.ERROR_CODE_UNAUTHORIZED:
+ showToastTips("Unauthorized Error !");
+ break;
+ case PLMediaPlayer.ERROR_CODE_PREPARE_TIMEOUT:
+ showToastTips("Prepare timeout !");
+ break;
+ case PLMediaPlayer.ERROR_CODE_READ_FRAME_TIMEOUT:
+ showToastTips("Read frame timeout !");
+ break;
case PLMediaPlayer.MEDIA_ERROR_UNKNOWN:
default:
showToastTips("unknown error !");
@@ -188,13 +199,4 @@ public void run() {
}
});
}
-
- private boolean isLiveStreaming(String url) {
- if (url.startsWith("rtmp://")
- || (url.startsWith("http://") && url.endsWith(".m3u8"))
- || (url.startsWith("http://") && url.endsWith(".flv"))) {
- return true;
- }
- return false;
- }
}
diff --git a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoViewActivity.java b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoViewActivity.java
index f34bf26..44754b1 100644
--- a/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoViewActivity.java
+++ b/PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/PLVideoViewActivity.java
@@ -40,12 +40,14 @@ protected void onCreate(Bundle savedInstanceState) {
AVOptions options = new AVOptions();
- if (isLiveStreaming(mVideoPath)) {
- // the unit of timeout is ms
- options.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, 10 * 1000);
- options.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, 10 * 1000);
- // Some optimization with buffering mechanism when be set to 1
- options.setInteger(AVOptions.KEY_LIVE_STREAMING, 1);
+ int isLiveStreaming = getIntent().getIntExtra("liveStreaming", 1);
+ // the unit of timeout is ms
+ options.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, 10 * 1000);
+ options.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, 10 * 1000);
+ // Some optimization with buffering mechanism when be set to 1
+ options.setInteger(AVOptions.KEY_LIVE_STREAMING, isLiveStreaming);
+ if (isLiveStreaming == 1) {
+ options.setInteger(AVOptions.KEY_DELAY_OPTIMIZATION, 1);
}
// 1 -> hw codec enable, 0 -> disable [recommended]
@@ -68,7 +70,7 @@ protected void onCreate(Bundle savedInstanceState) {
mVideoView.setVideoPath(mVideoPath);
// You can also use a custom `MediaController` widget
- mMediaController = new MediaController(this, false, isLiveStreaming(mVideoPath));
+ mMediaController = new MediaController(this, false, isLiveStreaming == 1);
mVideoView.setMediaController(mMediaController);
}
@@ -151,6 +153,15 @@ public boolean onError(PLMediaPlayer plMediaPlayer, int errorCode) {
case PLMediaPlayer.ERROR_CODE_IO_ERROR:
showToastTips("Network IO Error !");
break;
+ case PLMediaPlayer.ERROR_CODE_UNAUTHORIZED:
+ showToastTips("Unauthorized Error !");
+ break;
+ case PLMediaPlayer.ERROR_CODE_PREPARE_TIMEOUT:
+ showToastTips("Prepare timeout !");
+ break;
+ case PLMediaPlayer.ERROR_CODE_READ_FRAME_TIMEOUT:
+ showToastTips("Read frame timeout !");
+ break;
case PLMediaPlayer.MEDIA_ERROR_UNKNOWN:
default:
showToastTips("unknown error !");
@@ -212,13 +223,4 @@ public void run() {
}
});
}
-
- private boolean isLiveStreaming(String url) {
- if (url.startsWith("rtmp://")
- || (url.startsWith("http://") && url.endsWith(".m3u8"))
- || (url.startsWith("http://") && url.endsWith(".flv"))) {
- return true;
- }
- return false;
- }
}
diff --git a/PLDroidPlayerDemo/app/src/main/jniLibs/arm64-v8a/libpldroidplayer.so b/PLDroidPlayerDemo/app/src/main/jniLibs/arm64-v8a/libpldroidplayer.so
index db4252f..551626b 100755
Binary files a/PLDroidPlayerDemo/app/src/main/jniLibs/arm64-v8a/libpldroidplayer.so and b/PLDroidPlayerDemo/app/src/main/jniLibs/arm64-v8a/libpldroidplayer.so differ
diff --git a/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi-v7a/libpldroidplayer.so b/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi-v7a/libpldroidplayer.so
index e8396d1..67940d4 100755
Binary files a/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi-v7a/libpldroidplayer.so and b/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi-v7a/libpldroidplayer.so differ
diff --git a/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi/libpldroidplayer.so b/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi/libpldroidplayer.so
index 27f893c..ed6f4d0 100755
Binary files a/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi/libpldroidplayer.so and b/PLDroidPlayerDemo/app/src/main/jniLibs/armeabi/libpldroidplayer.so differ
diff --git a/PLDroidPlayerDemo/app/src/main/jniLibs/x86/libpldroidplayer.so b/PLDroidPlayerDemo/app/src/main/jniLibs/x86/libpldroidplayer.so
index 502c4ab..b7bfffc 100755
Binary files a/PLDroidPlayerDemo/app/src/main/jniLibs/x86/libpldroidplayer.so and b/PLDroidPlayerDemo/app/src/main/jniLibs/x86/libpldroidplayer.so differ
diff --git a/PLDroidPlayerDemo/app/src/main/res/layout/activity_main.xml b/PLDroidPlayerDemo/app/src/main/res/layout/activity_main.xml
index dc9f204..40ab824 100644
--- a/PLDroidPlayerDemo/app/src/main/res/layout/activity_main.xml
+++ b/PLDroidPlayerDemo/app/src/main/res/layout/activity_main.xml
@@ -18,6 +18,62 @@
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+ android:text="@string/btn_click_play"
+ android:textSize="12sp"
+ android:onClick="onClickPlay"
+ android:layout_marginLeft="10dp" />
diff --git a/PLDroidPlayerDemo/app/src/main/res/values/strings.xml b/PLDroidPlayerDemo/app/src/main/res/values/strings.xml
index 8431a76..7bb3451 100644
--- a/PLDroidPlayerDemo/app/src/main/res/values/strings.xml
+++ b/PLDroidPlayerDemo/app/src/main/res/values/strings.xml
@@ -11,16 +11,20 @@
Video
Audio
+ 直播
+ 点播
+
播放设置
解码配置
- 软件解码
- 硬件解码
+ 软解
+ 硬解
OK
Cancel
[请选择测试 Activity]:
[输入或选择视频地址]:
+ [请选择播放配置]:
手动输入测试视频地址
本地文件
播放配置
diff --git a/README.md b/README.md
index c8bd76b..c8999e6 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ PLDroidPlayer 是一个适用于 Android 平台的音视频播放器 SDK,可
## 特性
- [x] 基于 [ijkplayer](https://github.com/Bilibili/ijkplayer) ( based on [ffplay](http://ffmpeg.org/) )
-- [x] Android Min API 9
+- [x] Android Min API 9
- [x] 支持 RTMP 和 HLS 协议的直播流媒体播放
- [x] 支持常见的音视频文件播放(MP4、M4A、flv 等)
- [x] 支持 MediaCodec 硬件解码
@@ -14,10 +14,15 @@ PLDroidPlayer 是一个适用于 Android 平台的音视频播放器 SDK,可
- [x] 提供 `PLVideoTextureView` 控件
- [x] 支持多种画面预览模式
- [x] 支持画面旋转(0度,90度,180度,270度)
-- [x] 支持纯音频播放,并支持后台运行
-- [x] 可高度定制化的 `MediaController`
-- [x] 支持 ARM, ARMv7a, ARM64v8a, X86 主流芯片体系架构
+- [x] 支持画面镜像变换
+- [x] 支持播放器音量设置,可实现静音功能
+- [x] 支持纯音频播放
- [x] 支持后台播放
+- [x] 支持首屏秒开
+- [x] 支持直播累积延时优化
+- [x] 支持带 IP 地址的播放 URL
+- [x] 可高度定制化的 `MediaController`
+- [x] 支持 ARM, ARMv7a, ARM64v8a, X86 主流芯片体系架构
## 播放器对比
| - | ijkplayer | PLDroidPlayer |
diff --git a/ReleaseNotes/release-notes-1.3.0.md b/ReleaseNotes/release-notes-1.3.0.md
new file mode 100644
index 0000000..c6a5a4a
--- /dev/null
+++ b/ReleaseNotes/release-notes-1.3.0.md
@@ -0,0 +1,50 @@
+# PLDroidPlayer Release Notes for 1.3.0
+
+本次更新:
+
+## 版本
+
+1. 发布 pldroid-player-1.3.0.jar
+2. 更新 libpldroidplayer.so
+
+## 优化
+
+1. 优化直播累积延时
+2. 优化首开时间
+3. 优化播放器退出耗时较长
+
+## 功能
+
+1. 支持带 IP 地址的播放 URL,支持的格式为:protocol://ip/path?domain=xxxx.com
+ 目前支持的协议为:RTMP、HDL,暂时不支持 HLS 协议
+2. 新增 PLNetworkManager 类,提供 DNS 缓存管理服务
+3. 新增 AVOptions 累积延时相关的配置参数
+4. 新增多种新的回调信息,方便更准确地感知播放过程中的状态变化
+
+## 缺陷
+
+1. 修复动态构建 PLVideoTextureView 导致崩溃的问题
+2. 修复 onError 回调 extra 为 0 的情况
+3. 修复了部分码流的时长解析不准确的问题
+4. 修复点播缓冲过程中,断网操作导致长时间无法恢复的问题
+5. 修复特殊网络情况下,退出播放器时的 ANR 问题
+
+## 更新注意事项
+
+1. 如果需要使用 SDK 提供的 DNS 缓存管理服务,则需要添加如下配置
+
+```
+// 添加 happydns 的依赖
+dependencies {
+ compile 'com.qiniu:happy-dns:0.2.+'
+}
+
+// 添加网络状态监测的权限
+
+
+```
+
+
+
+
+
diff --git a/releases/arm64-v8a/libpldroidplayer.so b/releases/arm64-v8a/libpldroidplayer.so
index db4252f..551626b 100755
Binary files a/releases/arm64-v8a/libpldroidplayer.so and b/releases/arm64-v8a/libpldroidplayer.so differ
diff --git a/releases/armeabi-v7a/libpldroidplayer.so b/releases/armeabi-v7a/libpldroidplayer.so
index e8396d1..67940d4 100755
Binary files a/releases/armeabi-v7a/libpldroidplayer.so and b/releases/armeabi-v7a/libpldroidplayer.so differ
diff --git a/releases/armeabi/libpldroidplayer.so b/releases/armeabi/libpldroidplayer.so
index 27f893c..ed6f4d0 100755
Binary files a/releases/armeabi/libpldroidplayer.so and b/releases/armeabi/libpldroidplayer.so differ
diff --git a/releases/pldroid-player-1.2.3.jar b/releases/pldroid-player-1.3.0.jar
similarity index 63%
rename from releases/pldroid-player-1.2.3.jar
rename to releases/pldroid-player-1.3.0.jar
index f38549c..25748e0 100644
Binary files a/releases/pldroid-player-1.2.3.jar and b/releases/pldroid-player-1.3.0.jar differ
diff --git a/releases/x86/libpldroidplayer.so b/releases/x86/libpldroidplayer.so
index 502c4ab..b7bfffc 100755
Binary files a/releases/x86/libpldroidplayer.so and b/releases/x86/libpldroidplayer.so differ