Skip to content

Commit

Permalink
Merge pull request #588 from tanhx2008/release-1.6.0
Browse files Browse the repository at this point in the history
Release 1.6.0
  • Loading branch information
lawder authored Jun 14, 2017
2 parents 70f346e + 23e405f commit cc5ad73
Show file tree
Hide file tree
Showing 23 changed files with 147 additions and 21 deletions.
13 changes: 9 additions & 4 deletions PLDroidPlayerDemo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@ android {
applicationId "com.pili.pldroid.playerdemo"
minSdkVersion 9
targetSdkVersion 22
versionCode 8
versionName "1.5.1"
versionCode 9
versionName "1.6.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

sourceSets {
main {
jniLibs.srcDirs = ['libs', 'src/main/jniLibs']
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/pldroid-player-1.5.1.jar')
compile files('libs/pldroid-player-1.6.0.jar')
compile 'com.android.support:appcompat-v7:22+'
compile 'com.qiniu:happy-dns:0.2.+'
}
Binary file removed PLDroidPlayerDemo/app/libs/pldroid-player-1.5.1.jar
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions PLDroidPlayerDemo/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.Spinner;
Expand All @@ -29,6 +30,7 @@ public class MainActivity extends AppCompatActivity {
private EditText mEditText;
private RadioGroup mStreamingTypeRadioGroup;
private RadioGroup mDecodeTypeRadioGroup;
private CheckBox mEnableRenderingMsg;

public static final String[] TEST_ACTIVITY_ARRAY = {
"PLMediaPlayerActivity",
Expand Down Expand Up @@ -57,6 +59,8 @@ protected void onCreate(Bundle savedInstanceState) {
mStreamingTypeRadioGroup = (RadioGroup) findViewById(R.id.StreamingTypeRadioGroup);
mDecodeTypeRadioGroup = (RadioGroup) findViewById(R.id.DecodeTypeRadioGroup);

mEnableRenderingMsg = (CheckBox) findViewById(R.id.enableRenderingMsg);

mActivitySpinner = (Spinner) findViewById(R.id.TestSpinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, TEST_ACTIVITY_ARRAY);
mActivitySpinner.setAdapter(adapter);
Expand Down Expand Up @@ -112,6 +116,7 @@ public void jumpToPlayerActivity(String videopath) {
} else {
intent.putExtra("liveStreaming", 0);
}
intent.putExtra("enableRederingMsg", mEnableRenderingMsg.isChecked()? 1 : 0);
startActivity(intent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private void prepare() {

private PLMediaPlayer.OnPreparedListener mOnPreparedListener = new PLMediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(PLMediaPlayer mp) {
public void onPrepared(PLMediaPlayer mp, int preparedTime) {
Log.i(TAG, "On Prepared !");
mMediaPlayer.start();
mIsStopped = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Gravity;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.pili.pldroid.player.AVOptions;
Expand All @@ -38,6 +37,8 @@ public class PLMediaPlayerActivity extends VideoPlayerBaseActivity {
private View mLoadingView;
private AVOptions mAVOptions;

private TextView mStatInfoTextView;

private int mSurfaceWidth = 0;
private int mSurfaceHeight = 0;

Expand All @@ -48,6 +49,8 @@ public class PLMediaPlayerActivity extends VideoPlayerBaseActivity {
private Toast mToast = null;
private boolean mIsLiveStreaming = false;

private long mLastUpdateStatTime = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -56,6 +59,11 @@ protected void onCreate(Bundle savedInstanceState) {
mSurfaceView = (SurfaceView) findViewById(R.id.SurfaceView);
mSurfaceView.getHolder().addCallback(mCallback);

mStatInfoTextView = (TextView) findViewById(R.id.StatInfoTextView);

mSurfaceWidth = getResources().getDisplayMetrics().widthPixels;
mSurfaceHeight = getResources().getDisplayMetrics().heightPixels;

mVideoPath = getIntent().getStringExtra("videoPath");

mAVOptions = new AVOptions();
Expand All @@ -79,6 +87,11 @@ protected void onCreate(Bundle savedInstanceState) {
// whether start play automatically after prepared, default value is 1
mAVOptions.setInteger(AVOptions.KEY_START_ON_PREPARED, 0);

// enable audio/video rendering msg callback
int isEnablRenderingMsg = getIntent().getIntExtra("enableRederingMsg", 0);
mAVOptions.setInteger(AVOptions.KEY_AUDIO_RENDER_MSG, isEnablRenderingMsg);
mAVOptions.setInteger(AVOptions.KEY_VIDEO_RENDER_MSG, isEnablRenderingMsg);

AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
}
Expand Down Expand Up @@ -113,8 +126,6 @@ public void onClickPlay(View v) {

public void onClickPause(View v) {
if (mMediaPlayer != null) {
Log.d(TAG, "bitrate = " + mMediaPlayer.getVideoBitrate() + " bps, fps = " + mMediaPlayer.getVideoFps() +
", resolution = " + mMediaPlayer.getResolutionInline());
mMediaPlayer.pause();
}
}
Expand Down Expand Up @@ -196,8 +207,7 @@ public void surfaceCreated(SurfaceHolder holder) {

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
mSurfaceWidth = width;
mSurfaceHeight = height;

}

@Override
Expand All @@ -209,7 +219,7 @@ public void surfaceDestroyed(SurfaceHolder holder) {

private PLMediaPlayer.OnVideoSizeChangedListener mOnVideoSizeChangedListener = new PLMediaPlayer.OnVideoSizeChangedListener() {
public void onVideoSizeChanged(PLMediaPlayer mp, int width, int height, int videoSar, int videoDen) {
Log.d(TAG, "onVideoSizeChanged: width = " + width + ", height = " + height + ", sar = " + videoSar + ", den = " + videoDen);
Log.i(TAG, "onVideoSizeChanged: width = " + width + ", height = " + height + ", sar = " + videoSar + ", den = " + videoDen);
// resize the display window to fit the screen
if (width != 0 && height != 0) {
float ratioW = (float) width / (float) mSurfaceWidth;
Expand All @@ -226,8 +236,10 @@ public void onVideoSizeChanged(PLMediaPlayer mp, int width, int height, int vide

private PLMediaPlayer.OnPreparedListener mOnPreparedListener = new PLMediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(PLMediaPlayer mp) {
Log.i(TAG, "On Prepared !");
public void onPrepared(PLMediaPlayer mp, int preparedTime) {
Log.i(TAG, "On Prepared ! prepared time = " + preparedTime + " ms");
HashMap<String, String> meta = mMediaPlayer.getMetadata();
Log.i(TAG, "metadata: " + meta.toString());
mMediaPlayer.start();
mIsStopped = false;
}
Expand All @@ -242,11 +254,17 @@ public boolean onInfo(PLMediaPlayer mp, int what, int extra) {
mLoadingView.setVisibility(View.VISIBLE);
break;
case PLMediaPlayer.MEDIA_INFO_BUFFERING_END:
mLoadingView.setVisibility(View.GONE);
break;
case PLMediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START:
mLoadingView.setVisibility(View.GONE);
HashMap<String, String> meta = mMediaPlayer.getMetadata();
Log.i(TAG, "meta: " + meta.toString());
showToastTips(meta.toString());
showToastTips("first video render time: " + extra + "ms");
break;
case PLMediaPlayer.MEDIA_INFO_VIDEO_GOP_TIME:
showToastTips("Gop Time: " + extra);
break;
case PLMediaPlayer.MEDIA_INFO_AUDIO_RENDERING_START:
mLoadingView.setVisibility(View.GONE);
break;
case PLMediaPlayer.MEDIA_INFO_SWITCHING_SW_DECODE:
Log.i(TAG, "Hardware decoding failure, switching software decoding!");
Expand All @@ -262,6 +280,11 @@ public boolean onInfo(PLMediaPlayer mp, int what, int extra) {
@Override
public void onBufferingUpdate(PLMediaPlayer mp, int percent) {
Log.d(TAG, "onBufferingUpdate: " + percent + "%");
long current = System.currentTimeMillis();
if (current - mLastUpdateStatTime > 3000) {
mLastUpdateStatTime = current;
updateStatInfo();
}
}
};

Expand Down Expand Up @@ -386,4 +409,15 @@ public void handleMessage(Message msg) {
prepare();
}
};

private void updateStatInfo() {
long bitrate = mMediaPlayer.getVideoBitrate() / 1024;
final String stat = bitrate + "kbps, " + mMediaPlayer.getVideoFps() + "fps";
runOnUiThread(new Runnable() {
@Override
public void run() {
mStatInfoTextView.setText(stat);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ protected void onCreate(Bundle savedInstanceState) {
protected void onPause() {
super.onPause();
mToast = null;
mVideoView.pause();
mIsActivityPaused = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ protected void onPause() {
super.onPause();
mToast = null;
mIsActivityPaused = true;
mVideoView.pause();
}

@Override
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions PLDroidPlayerDemo/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@

</RadioGroup>

<CheckBox
android:id="@+id/enableRenderingMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="5dp"
android:text="回调音视频时间戳" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@
android:layout_margin="10dp"
android:layout_gravity="bottom" />

<TextView
android:id="@+id/StatInfoTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="20sp"
android:layout_gravity="top|right"
android:layout_margin="20dp" />

</FrameLayout>
7 changes: 5 additions & 2 deletions ReleaseNotes/release-notes-1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
public int getVideoFps();
public long getVideoBitrate();
```
```

## 优化

- 修复了播放过程中切换前后台出现的频繁缓冲问题,防止弱网下频繁缓冲导致 Loading 动画闪烁

## 缺陷

- 修复使用 PLVideoTextureView 硬解从后台切换前台花屏的问题
- 修复了播放过程中切换前后台出现的频繁缓冲问题,防止弱网下频繁缓冲导致 Loading 动画闪烁

## 更新注意事项

Expand Down
56 changes: 56 additions & 0 deletions ReleaseNotes/release-notes-1.6.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# PLDroidPlayer Release Notes for 1.6.0

本次更新:

## 版本

- 发布 pldroid-player-1.6.0.jar
- 更新 libpldroidplayer.so

## 功能

- 新增音视频播放时间戳回调

```
/**
* The rendering video frame.
*
* pts per frame: unit: ms
*
* @see OnInfoListener
*/
public static final int MEDIA_INFO_VIDEO_FRAME_RENDERING = 10004;
/**
* The rendering audio frame.
*
* pts per frame: unit: ms
*
* @see OnInfoListener
*/
public static final int MEDIA_INFO_AUDIO_FRAME_RENDERING = 10005;
// enable audio/video rendering msg callback
int isEnablRenderingMsg = 1;
mAVOptions.setInteger(AVOptions.KEY_AUDIO_RENDER_MSG, isEnablRenderingMsg);
mAVOptions.setInteger(AVOptions.KEY_VIDEO_RENDER_MSG, isEnablRenderingMsg);
```

- `MEDIA_INFO_VIDEO_RENDERING_START` 消息的 `extra` 参数附带首帧时间
- `MEDIA_INFO_AUDIO_RENDERING_START` 消息的 `extra` 参数附带首帧时间
- `OnPreparedListener` 消息的 `onPrepared` 接口增加 `preparedTime` 时间
- 新增 setVideoUri(Uri uri, Map<String, String> headers) 接口,支持自定义消息头

## 缺陷

- 修复部分场景下多线程同步导致的 QOS 模块 NPE 异常
- 兼容不支持 rtmp_live 参数的直播流播放

## 更新注意事项

- **不再需要在** build.gradle 中添加如下配置了:

```
compile 'com.qiniu.pili:pili-android-qos:0.8.+'
```

Binary file modified releases/arm64-v8a/libpldroidplayer.so
Binary file not shown.
Binary file modified releases/armeabi-v7a/libpldroidplayer.so
Binary file not shown.
Binary file modified releases/armeabi/libpldroidplayer.so
Binary file not shown.
Binary file removed releases/pldroid-player-1.5.1.jar
Binary file not shown.
Binary file added releases/pldroid-player-1.6.0.jar
Binary file not shown.
Binary file modified releases/x86/libpldroidplayer.so
Binary file not shown.

0 comments on commit cc5ad73

Please sign in to comment.