Skip to content

Commit

Permalink
Merge pull request #187 from Jhuster/release
Browse files Browse the repository at this point in the history
release 1.3.0
  • Loading branch information
jpxiong authored Jun 29, 2016
2 parents a693808 + 8f66475 commit ac1e5c1
Show file tree
Hide file tree
Showing 21 changed files with 245 additions and 131 deletions.
11 changes: 6 additions & 5 deletions PLDroidPlayerDemo/app/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
Expand All @@ -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.+'
}
Binary file not shown.
1 change: 1 addition & 0 deletions PLDroidPlayerDemo/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
package com.pili.pldroid.playerdemo;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;

import com.pili.pldroid.player.PLNetworkManager;

import java.net.UnknownHostException;

public class MainActivity extends AppCompatActivity {

private static final String DEFAULT_TEST_URL = "rtmp://live.hkstv.hk.lxdns.com/live/hks";

private static final String[] DEFAULT_PLAYBACK_DOMAIN_ARRAY = {
"live.hkstv.hk.lxdns.com"
};

private Spinner mActivitySpinner;
private EditText mEditText;
private int mIsHwCodecEnabled = 0;
private RadioGroup mStreamingTypeRadioGroup;
private RadioGroup mDecodeTypeRadioGroup;

public static final String[] TEST_ACTIVITY_ARRAY = {
"PLMediaPlayerActivity",
Expand All @@ -35,16 +41,27 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

try {
PLNetworkManager.getInstance().startDnsCacheService(this, DEFAULT_PLAYBACK_DOMAIN_ARRAY);
} catch (UnknownHostException e) {
e.printStackTrace();
}

mEditText = (EditText)findViewById(R.id.VideoPathEdit);
mEditText.setText(DEFAULT_TEST_URL);

mStreamingTypeRadioGroup = (RadioGroup) findViewById(R.id.StreamingTypeRadioGroup);
mDecodeTypeRadioGroup = (RadioGroup) findViewById(R.id.DecodeTypeRadioGroup);

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);
}

public void onClickPlaySetting(View v) {
showPlaySettingDialog();
@Override
protected void onDestroy() {
super.onDestroy();
PLNetworkManager.getInstance().stopDnsCacheService(this);
}

public void onClickLocalFile(View v) {
Expand Down Expand Up @@ -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);
}

Expand All @@ -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<String>(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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -116,6 +118,7 @@ public void onClickStop(View v) {
mMediaPlayer.reset();
}
mIsStopped = true;
mMediaPlayer = null;
}

public void releaseWithoutStop() {
Expand Down Expand Up @@ -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 !");
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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);
Expand Down Expand Up @@ -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 !");
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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);
}

Expand Down Expand Up @@ -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 !");
Expand Down Expand Up @@ -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;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified PLDroidPlayerDemo/app/src/main/jniLibs/x86/libpldroidplayer.so
Binary file not shown.
Loading

0 comments on commit ac1e5c1

Please sign in to comment.