Skip to content

Commit

Permalink
Merge pull request #145 from Jhuster/release
Browse files Browse the repository at this point in the history
release 1.2.3
  • Loading branch information
longbai committed Jun 7, 2016
2 parents a360d22 + 2948dc6 commit 58719d5
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 12 deletions.
2 changes: 1 addition & 1 deletion PLDroidPlayerDemo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ android {

dependencies {
compile 'com.android.support:design:23.2.1'
compile files('libs/pldroid-player-1.2.2.jar')
compile files('libs/pldroid-player-1.2.3.jar')
}
Binary file removed PLDroidPlayerDemo/app/libs/pldroid-player-1.2.2.jar
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.PowerManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
Expand Down Expand Up @@ -39,27 +40,29 @@ protected void onCreate(Bundle savedInstanceState) {
mMediaPlayer.setOnInfoListener(mOnInfoListener);
mMediaPlayer.setOnBufferingUpdateListener(mOnBufferingUpdateListener);

mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);

prepare();
}

@Override
protected void onDestroy() {
super.onDestroy();
release();
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.abandonAudioFocus(null);
super.onDestroy();
}

@Override
protected void onResume() {
super.onResume();
mMediaPlayer.start();
// mMediaPlayer.start();
}

@Override
protected void onPause() {
mMediaPlayer.pause();
super.onPause();
// mMediaPlayer.pause();
}

public void onClickPlay(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.PowerManager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Gravity;
Expand Down Expand Up @@ -35,6 +36,7 @@ public class PLMediaPlayerActivity extends AppCompatActivity {

private String mVideoPath = null;
private boolean mIsStopped = false;
private boolean mIsActivityPaused = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -51,6 +53,7 @@ protected void onCreate(Bundle savedInstanceState) {

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);
Expand All @@ -69,10 +72,22 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
protected void onDestroy() {
super.onDestroy();
release();
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.abandonAudioFocus(null);
super.onDestroy();
}

@Override
protected void onResume() {
super.onResume();
mIsActivityPaused = false;
}

@Override
protected void onPause() {
super.onPause();
mIsActivityPaused = true;
}

public void onClickPlay(View v) {
Expand Down Expand Up @@ -103,6 +118,12 @@ public void onClickStop(View v) {
mIsStopped = true;
}

public void releaseWithoutStop() {
if (mMediaPlayer != null) {
mMediaPlayer.setDisplay(null);
}
}

public void release() {
if (mMediaPlayer != null) {
mMediaPlayer.stop();
Expand All @@ -114,7 +135,8 @@ public void release() {
private void prepare() {

if (mMediaPlayer != null) {
release();
mMediaPlayer.setDisplay(mSurfaceView.getHolder());
return;
}

try {
Expand All @@ -130,6 +152,8 @@ private void prepare() {
// set replay if completed
// mMediaPlayer.setLooping(true);

mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);

mMediaPlayer.setDataSource(mVideoPath);
mMediaPlayer.setDisplay(mSurfaceView.getHolder());
mMediaPlayer.prepareAsync();
Expand Down Expand Up @@ -158,7 +182,8 @@ public void surfaceChanged(SurfaceHolder holder, int format, int width, int heig

@Override
public void surfaceDestroyed(SurfaceHolder holder) {
release();
// release();
releaseWithoutStop();
}
};

Expand Down Expand Up @@ -281,6 +306,9 @@ public boolean onError(PLMediaPlayer mp, int errorCode) {
};

private void showToastTips(final String tips) {
if (mIsActivityPaused) {
return;
}
runOnUiThread(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected void onCreate(Bundle savedInstanceState) {

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);
Expand Down Expand Up @@ -80,8 +81,9 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
protected void onPause() {
mVideoView.pause();
super.onPause();
mToast = null;
mVideoView.pause();
}

@Override
Expand All @@ -92,8 +94,8 @@ protected void onResume() {

@Override
protected void onDestroy() {
mVideoView.stopPlayback();
super.onDestroy();
mVideoView.stopPlayback();
}

public void onClickRotate(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class PLVideoViewActivity extends AppCompatActivity {
private Toast mToast = null;
private String mVideoPath = null;
private int mDisplayAspectRatio = PLVideoView.ASPECT_RATIO_FIT_PARENT;
private boolean mIsActivityPaused = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -41,6 +42,7 @@ protected void onCreate(Bundle savedInstanceState) {

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);
Expand Down Expand Up @@ -73,19 +75,22 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onResume() {
super.onResume();
mIsActivityPaused = false;
mVideoView.start();
}

@Override
protected void onPause() {
mVideoView.pause();
super.onPause();
mToast = null;
mIsActivityPaused = true;
mVideoView.pause();
}

@Override
protected void onDestroy() {
mVideoView.stopPlayback();
super.onDestroy();
mVideoView.stopPlayback();
}

public void onClickSwitchScreen(View v) {
Expand Down Expand Up @@ -193,6 +198,9 @@ public void onVideoSizeChanged(PLMediaPlayer plMediaPlayer, int width, int heigh
};

private void showToastTips(final String tips) {
if (mIsActivityPaused) {
return;
}
runOnUiThread(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public MediaController(Context context, boolean useFastForward) {

private boolean initController(Context context) {
mUseFastForward = true;
mContext = context;
mContext = context.getApplicationContext();
mAM = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
return true;
}
Expand Down
Binary file modified PLDroidPlayerDemo/app/src/main/jniLibs/arm64-v8a/libpldroidplayer.so
100644 → 100755
Binary file not shown.
Binary file modified PLDroidPlayerDemo/app/src/main/jniLibs/armeabi-v7a/libpldroidplayer.so
100644 → 100755
Binary file not shown.
Binary file modified PLDroidPlayerDemo/app/src/main/jniLibs/armeabi/libpldroidplayer.so
100644 → 100755
Binary file not shown.
Binary file modified PLDroidPlayerDemo/app/src/main/jniLibs/x86/libpldroidplayer.so
100644 → 100755
Binary file not shown.
24 changes: 24 additions & 0 deletions ReleaseNotes/release-notes-1.2.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# PLDroidPlayer Release Notes for 1.2.3

## 简介
PLDroidPlayer 为 Android 开发者提供直播播放 SDK

## 记录

### 播放器
- 发布 pldroid-player-1.2.3.jar
- 更新 libpldroidplayer.so
- 支持后台播放
- 优化点播的首开时间
- 优化直播过程中的累积延时
- 新增 `setWakeMode``setScreenOnWhilePlaying` 接口
- 新增 `setLooping``isLooping` 接口
- `AVOption` 添加 `prepare timeout` 超时的配置
- 修改 `seekTo` 的参数,类型改为`long`
- 解决播放部分纯音频流的时候,获取不到时长的问题
- 解决从后台切换回来后,播放从头开始加载的问题
- 修复`AudioManager`可能导致的内存泄漏问题

### 播放器 Demo

- 更新 demo ,演示后台播放和`prepare timeout` 超时的配置
Binary file removed releases/pldroid-player-1.2.2.jar
Binary file not shown.
Binary file added releases/pldroid-player-1.2.3.jar
Binary file not shown.

0 comments on commit 58719d5

Please sign in to comment.