Skip to content

Commit

Permalink
Merge pull request #69 from pili-engineering/revert-68-dev
Browse files Browse the repository at this point in the history
Revert "release 1.2.0"
  • Loading branch information
jpxiong committed Apr 28, 2016
2 parents d47bb8e + 414499b commit c5d161c
Show file tree
Hide file tree
Showing 57 changed files with 818 additions and 1,591 deletions.
2 changes: 0 additions & 2 deletions PLDroidPlayerDemo/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
14 changes: 8 additions & 6 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"
applicationId "com.pili.android.playerdemo"
minSdkVersion 9
targetSdkVersion 23
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
Expand All @@ -20,6 +20,8 @@ android {
}

dependencies {
compile 'com.android.support:design:23.2.1'
compile files('libs/pldroid-player-1.2.0.jar')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile files('libs/ijkmediaplayer.jar')
compile files('libs/pldroid-player-1.1.6.jar')
}
Binary file added PLDroidPlayerDemo/app/libs/ijkmediaplayer.jar
Binary file not shown.
Binary file not shown.
Binary file removed PLDroidPlayerDemo/app/libs/pldroid-player-1.2.0.jar
Binary file not shown.
4 changes: 1 addition & 3 deletions PLDroidPlayerDemo/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/lujun/Library/Android/sdk/tools/proguard/proguard-android.txt
# in /Users/jerikc/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
Expand All @@ -15,5 +15,3 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

-keep class com.pili.pldroid.player.** { *; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.pili.pldroid.playerdemo;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
44 changes: 29 additions & 15 deletions PLDroidPlayerDemo/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,46 @@
package="com.pili.pldroid.playerdemo" >

<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.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity">
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PLMediaPlayerActivity"
android:theme="@style/AppThemeFullscreen" />
<activity android:name=".PLAudioPlayerActivity" />
<activity android:name=".PLVideoViewActivity"
android:theme="@style/AppThemeFullscreen" />
<activity android:name=".PLVideoTextureActivity"
android:theme="@style/AppThemeFullscreen" />
<activity android:name=".VideoViewActivity"
android:theme="@style/AppThemeFullscreen" />
<activity android:name=".VideoFileActivity" />
<activity
android:name=".VideoPlayerActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="video/*" />
<data android:mimeType="audio/*" />
<data android:scheme="http" />
<data android:scheme="file" />
</intent-filter>
</activity>
<activity
android:name=".AudioPlayerActivity"
android:label="@string/title_activity_audio_player" >
</activity>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
package com.pili.pldroid.playerdemo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;

import com.pili.pldroid.player.AVOptions;
import com.pili.pldroid.player.AudioPlayer;
import com.pili.pldroid.player.PlayerCode;
import com.pili.pldroid.playerdemo.R;
import com.pili.pldroid.playerdemo.common.Util;
import com.pili.pldroid.playerdemo.widget.MediaController;

import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;

public class AudioPlayerActivity extends Activity implements
IjkMediaPlayer.OnCompletionListener,
IjkMediaPlayer.OnInfoListener,
IjkMediaPlayer.OnErrorListener,
IjkMediaPlayer.OnPreparedListener {
private static final String TAG = "AudioPlayerActivity";
private static final int REQ_DELAY_MILLS = 3000;

private View mBufferingIndicator;
private MediaController mMediaController;
private AudioPlayer mAudioPlayer;

private String mAudioPath;
private Button mBackBtn;
private long mLastPosition = 0;
private boolean mIsLiveStream = false;

private int mReqDelayMills = REQ_DELAY_MILLS;
private boolean mIsCompleted = false;
private Runnable mVideoReconnect;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_player);

mAudioPath = getIntent().getStringExtra("audioPath");

Intent intent = getIntent();
String intentAction = intent.getAction();
if (!TextUtils.isEmpty(intentAction) && intentAction.equals(Intent.ACTION_VIEW)) {
mAudioPath = intent.getDataString();
}

mBackBtn = (Button) findViewById(R.id.back_btn);
mBackBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onBackPressed();
finish();
}
});
mBufferingIndicator = findViewById(R.id.buffering_indicator);

boolean useFastForward = true;
boolean disableProgressBar = false;
// Tip: you can custom the variable depending on your situation
mIsLiveStream = true;
if (mIsLiveStream) {
disableProgressBar = true;
useFastForward = false;
}
mMediaController = new MediaController(this, useFastForward, disableProgressBar);
mAudioPlayer = new AudioPlayer(this);

AVOptions options = new AVOptions();
options.setInteger(AVOptions.KEY_MEDIACODEC, 1); // 1 -> enable, 0 -> disable

Log.i(TAG, "mIsLiveStream:" + mIsLiveStream);
if (mIsLiveStream) {
options.setInteger(AVOptions.KEY_BUFFER_TIME, 1000); // the unit of buffer time is ms
options.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, 8 * 1000); // the unit of timeout is ms
options.setString(AVOptions.KEY_FFLAGS, AVOptions.VALUE_FFLAGS_NOBUFFER); // "nobuffer"
options.setInteger(AVOptions.KEY_LIVE_STREAMING, 1);
}
mAudioPlayer.setAVOptions(options);

mMediaController.setMediaPlayer(mAudioPlayer);
mAudioPlayer.setMediaController(mMediaController);
mAudioPlayer.setOnErrorListener(this);
mAudioPlayer.setOnCompletionListener(this);
mAudioPlayer.setOnInfoListener(this);
mAudioPlayer.setOnPreparedListener(this);
mAudioPlayer.setAudioPath(mAudioPath);

mAudioPlayer.start();
mBufferingIndicator.setVisibility(View.VISIBLE);
}

@Override
public void onCompletion(IMediaPlayer mp) {
Log.d(TAG, "onCompletion");
mIsCompleted = true;
mBufferingIndicator.setVisibility(View.GONE);
}

@Override
public boolean onError(IMediaPlayer mp, int what, int extra) {
Log.d(TAG, "onError what=" + what + ", extra=" + extra);
if (what == -10000) {
if (extra == PlayerCode.EXTRA_CODE_INVALID_URI || extra == PlayerCode.EXTRA_CODE_EOF) {
if (mBufferingIndicator != null)
mBufferingIndicator.setVisibility(View.GONE);
return true;
}
if (mIsCompleted && extra == PlayerCode.EXTRA_CODE_EMPTY_PLAYLIST) {
Log.d(TAG, "mVideoView reconnect!!!");
mVideoReconnect = new Runnable() {
@Override
public void run() {
mAudioPlayer.setAudioPath(mAudioPath);
}
};
mReqDelayMills += 200;
} else if (extra == PlayerCode.EXTRA_CODE_404_NOT_FOUND) {
// NO ts exist
if (mBufferingIndicator != null)
mBufferingIndicator.setVisibility(View.GONE);
} else if (extra == PlayerCode.EXTRA_CODE_IO_ERROR) {
// NO rtmp stream exist
if (mBufferingIndicator != null)
mBufferingIndicator.setVisibility(View.GONE);
}
}
// return true means you handle the onError, hence System wouldn't handle it again(popup a dialog).
return true;
}

@Override
public boolean onInfo(IMediaPlayer mp, int what, int extra) {
Log.d(TAG, "onInfo what=" + what + ", extra=" + extra);
if (what == IMediaPlayer.MEDIA_INFO_BUFFERING_START) {
Log.i(TAG, "onInfo: (MEDIA_INFO_BUFFERING_START)");
if (mBufferingIndicator != null)
mBufferingIndicator.setVisibility(View.VISIBLE);
} else if (what == IMediaPlayer.MEDIA_INFO_BUFFERING_END) {
Log.i(TAG, "onInfo: (MEDIA_INFO_BUFFERING_END)");
if (mBufferingIndicator != null)
mBufferingIndicator.setVisibility(View.GONE);
}
return true;
}

@Override
public void onPrepared(IMediaPlayer mp) {
Log.d(TAG, "onPrepared");
mBufferingIndicator.setVisibility(View.GONE);
mReqDelayMills = REQ_DELAY_MILLS;
}

@Override
public void onResume() {
super.onResume();
mReqDelayMills = REQ_DELAY_MILLS;
Log.i(TAG, "onResume");
if (mAudioPlayer != null && !mIsLiveStream && mLastPosition != 0) {
mAudioPlayer.seekTo(mLastPosition);
mAudioPlayer.start();
}
}

@Override
public void onPause() {
// if (mAudioPlayer != null) {
// mAudioPlayer.pause();
// mLastPosition = mAudioPlayer.getCurrentPosition();
// }
if (mAudioPlayer != null) {
mLastPosition = mAudioPlayer.getCurrentPosition();
mAudioPlayer.stopPlayback();
}
super.onPause();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(mAudioPlayer.onKeyDown(keyCode, event)) {
return true;
}
return super.onKeyDown(keyCode, event);
}

}
Loading

0 comments on commit c5d161c

Please sign in to comment.