-
Notifications
You must be signed in to change notification settings - Fork 953
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from pili-engineering/revert-68-dev
Revert "release 1.2.0"
- Loading branch information
Showing
57 changed files
with
818 additions
and
1,591 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
PLDroidPlayerDemo/app/src/androidTest/java/com/pili/pldroid/playerdemo/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
197 changes: 197 additions & 0 deletions
197
PLDroidPlayerDemo/app/src/main/java/com/pili/pldroid/playerdemo/AudioPlayerActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
Oops, something went wrong.